Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commands: move cmd_run into run.rs.
Browse files Browse the repository at this point in the history
This also does two cosmetic changes, changing `jobs` from a plain usize to a Option<usize>
and making execute a no-op boolean, like the `-r` in describe. It also contains a minor documentation
update to match newer `jj` features and a fix to the `pre-commit` invocation.

While we're at it, teach it to resolve the passed revsets.
PhilipMetzger committed Nov 1, 2023
1 parent 02f7282 commit 2943f7b
Showing 2 changed files with 37 additions and 30 deletions.
33 changes: 3 additions & 30 deletions cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -42,6 +42,7 @@ mod operation;
mod prev;
mod rebase;
mod resolve;
mod run;

use std::collections::HashSet;
use std::fmt::Debug;
@@ -129,7 +130,7 @@ enum Commands {
Restore(RestoreArgs),
#[command(hide = true)]
// TODO: Flesh out.
Run(RunArgs),
Run(run::RunArgs),
Show(ShowArgs),
#[command(subcommand)]
Sparse(SparseArgs),
@@ -280,29 +281,6 @@ struct RestoreArgs {
revision: Option<RevisionArg>,
}

/// Run a command across a set of revisions.
///
///
/// All recorded state will be persisted in the `.jj` directory, so occasionally
/// a `jj run --clean` is needed to clean up disk space.
///
/// # Example
///
/// # Run pre-commit on your local work
/// $ jj run 'pre-commit.py .github/pre-commit.yaml' -r (main..@) -j 4
///
/// This allows pre-commit integration and other funny stuff.
#[derive(clap::Args, Clone, Debug)]
#[command(verbatim_doc_comment)]
struct RunArgs {
/// The command to run across all selected revisions.
#[arg(long, short, alias = "x")]
command: String,
/// The revisions to change.
#[arg(long, short, default_value = "@")]
revisions: Vec<RevisionArg>,
}

/// Split a revision in two
///
/// Starts a diff editor (`meld` by default) on the changes in the revision.
@@ -1259,11 +1237,6 @@ don't make any changes, then the operation will be aborted.
Ok(())
}

// TODO: Move to run.rs
fn cmd_run(_ui: &mut Ui, _command: &CommandHelper, _args: &RunArgs) -> Result<(), CommandError> {
Err(user_error("This is a stub, do not use"))
}

fn make_branch_term(branch_names: &[impl fmt::Display]) -> String {
match branch_names {
[branch_name] => format!("branch {}", branch_name),
@@ -1668,7 +1641,7 @@ pub fn run_command(ui: &mut Ui, command_helper: &CommandHelper) -> Result<(), Co
Commands::Squash(sub_args) => cmd_squash(ui, command_helper, sub_args),
Commands::Unsquash(sub_args) => cmd_unsquash(ui, command_helper, sub_args),
Commands::Restore(sub_args) => cmd_restore(ui, command_helper, sub_args),
Commands::Run(sub_args) => cmd_run(ui, command_helper, sub_args),
Commands::Run(sub_args) => run::cmd_run(ui, command_helper, sub_args),
Commands::Diffedit(sub_args) => diffedit::cmd_diffedit(ui, command_helper, sub_args),
Commands::Split(sub_args) => cmd_split(ui, command_helper, sub_args),
Commands::Merge(sub_args) => merge::cmd_merge(ui, command_helper, sub_args),
34 changes: 34 additions & 0 deletions cli/src/commands/run.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//! This file contains the internal implementation of `run`.
use crate::cli_util::{user_error, CommandError, CommandHelper, RevisionArg};
use crate::ui::Ui;

/// Run a command across a set of revisions.
///
///
/// All recorded state will be persisted in the `.jj` directory, so occasionally
/// a `jj run --clean` is needed to clean up disk space.
///
/// # Example
///
/// # Run pre-commit on your local work
/// $ jj run 'pre-commit.py .github/pre-commit.yaml' -r (main..@) -j 4
///
/// This allows pre-commit integration and other funny stuff.
#[derive(clap::Args, Clone, Debug)]
#[command(verbatim_doc_comment)]
pub struct RunArgs {
/// The command to run across all selected revisions.
#[arg(long, short, alias = "x")]
command: String,
/// The revisions to change.
#[arg(long, short, default_value = "@")]
revisions: Vec<RevisionArg>,
}

pub fn cmd_run(
_ui: &mut Ui,
_command: &CommandHelper,
_args: &RunArgs,
) -> Result<(), CommandError> {
Err(user_error("This is a stub, do not use"))
}

0 comments on commit 2943f7b

Please sign in to comment.