Skip to content

Commit

Permalink
cli: basic jj gerrit send implementation
Browse files Browse the repository at this point in the history
This implements the most basic workflow for submitting changes to Gerrit,
through a verb called 'send'. This verb is intended to be distinct from the word
'submit', which for Gerrit means 'merge a change into the repository.'

Given a list of revsets (specified by multiple `-r` options), this will parse
the footers of every commit, collect them, insert a `Change-Id` (if one doesn't
already exist), and then push them into the given remote.

Because the argument is a revset, you may submit entire trees of changes at
once, including multiple trees of independent changes, e.g.

    jj gerrit send -r foo:: -r baz::

There are many other improvements that can be applied on top of this, including
a ton of consistency and "does this make sense?" checks. However, it is flexible
and a good starting point, and you can in fact both submit and cycle reviews
with this interface.

Signed-off-by: Austin Seipp <[email protected]>
  • Loading branch information
thoughtpolice committed Feb 23, 2024
1 parent b71273f commit 08e210b
Show file tree
Hide file tree
Showing 4 changed files with 446 additions and 0 deletions.
49 changes: 49 additions & 0 deletions cli/src/commands/gerrit/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// 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::{CommandError, CommandHelper};
use crate::commands::gerrit;
use crate::ui::Ui;

/// Interact with Gerrit Code Review.
#[derive(Subcommand, Clone, Debug)]
pub enum GerritCommand {
/// Send in revisions to Gerrit for code review; this is the primary way to
/// create changes or update changes for code review.
///
/// This command modifies each commit in the revset to include a `Change-Id`
/// footer in its commit message if one does not already exist. This ID is
/// NOT compatible with jj IDs, and is a Gerrit-specific ID.
///
/// Note: this command takes a revset as an argument, and will send in all
/// revisions in the revset to Gerrit appropriately, so you may post trees
/// or ranges of commits to Gerrit for review.
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;
Loading

0 comments on commit 08e210b

Please sign in to comment.