-
Notifications
You must be signed in to change notification settings - Fork 349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cli: implement jj gerrit send
for sending changes to Gerrit
#2845
Open
thoughtpolice
wants to merge
3
commits into
main
Choose a base branch
from
aseipp/push-uytvkxyqyspn
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+694
−1
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ include = [ | |
"/tests/", | ||
"!*.pending-snap", | ||
"!*.snap*", | ||
"/tests/[email protected]" | ||
"/tests/[email protected]", | ||
] | ||
|
||
[[bin]] | ||
|
@@ -64,6 +64,7 @@ esl01-renderdag = { workspace = true } | |
futures = { workspace = true } | ||
git2 = { workspace = true } | ||
gix = { workspace = true } | ||
hex = { workspace = true } | ||
indexmap = { workspace = true } | ||
indoc = { workspace = true } | ||
itertools = { workspace = true } | ||
|
@@ -74,6 +75,7 @@ once_cell = { workspace = true } | |
pest = { workspace = true } | ||
pest_derive = { workspace = true } | ||
pollster = { workspace = true } | ||
rand = { workspace = true } | ||
rayon = { workspace = true } | ||
regex = { workspace = true } | ||
rpassword = { workspace = true } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 2024 The Jujutsu Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use std::fmt::Debug; | ||
|
||
use clap::Subcommand; | ||
|
||
use crate::cli_util::CommandHelper; | ||
use crate::command_error::CommandError; | ||
use crate::commands::gerrit; | ||
use crate::ui::Ui; | ||
|
||
/// Interact with Gerrit Code Review. | ||
#[derive(Subcommand, Clone, Debug)] | ||
pub enum GerritCommand { | ||
/// Send changes to Gerrit for code review, or update existing changes. | ||
/// | ||
/// Sending in a set of revisions to Gerrit creates a single "change" for | ||
/// each revision included in the revset. This change is then available for | ||
/// review on your Gerrit instance. | ||
/// | ||
/// This command modifies each commit in the revset to include a `Change-Id` | ||
/// footer in its commit message if one does not already exist. Note that | ||
/// this ID is NOT compatible with jj IDs, and is Gerrit-specific. | ||
/// | ||
/// If a change already exists for a given revision (i.e. it contains the | ||
/// same `Change-Id`), this command will update the contents of the existing | ||
/// change to match. | ||
/// | ||
/// Note: this command takes 1-or-more revsets arguments, each of which can | ||
/// resolve to multiple revisions; so you may post trees or ranges of | ||
/// commits to Gerrit for review all at once. | ||
Send(gerrit::send::SendArgs), | ||
} | ||
|
||
pub fn cmd_gerrit( | ||
ui: &mut Ui, | ||
command: &CommandHelper, | ||
subcommand: &GerritCommand, | ||
) -> Result<(), CommandError> { | ||
match subcommand { | ||
GerritCommand::Send(review) => gerrit::send::cmd_send(ui, command, review), | ||
} | ||
} | ||
|
||
mod send; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't remember if this was discussed earlier, but have we considered making this a transient hash of the JJ change ID that isn't actually stored in the committee description?
I've implemented something roughly similar to what you've done, and one problem I had was that when I run JJ split you end up with, by default, two commits with the same gerrit change ID.
That being said, I consider this a very good improvement over the current behaviour, so I'd recommend we submit as is even if we were to change it to that in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like using jj change hex as Change-Id (see #4477 (comment)) but I'm not sure if we can get away with not storing it explicitly -- splits could get very confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even git interactions could get weird (
git commit --amend --no-edit
, for example).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that a hybrid approach where we don't store it explicitly automatically, but if you have manually stored it explicitly then we use that Change-ID would work relatively well. It'd also work well with splits by providing reasonable defaults, but could be overridden if required.
Re splits, it should work just fine as long as the user knows exactly what's gonna happen with the split (specifically,
jj split
to associate the change-ID with the second one, andjj commit
to associate the Change-ID with the first one). Maybe we need something likejj change-id swap foo bar
orjj change-id set -r foo <change-id>
.