From 6bc1d81622f669611a08bd0570da0f63b2b02825 Mon Sep 17 00:00:00 2001 From: Philip Metzger Date: Tue, 2 May 2023 16:30:25 +0200 Subject: [PATCH] run: Teach `run` to resolve revsets and about `jobs`. This also adds `jobs`, the argument reading the thread count to use and `shell_command`. While we're at it, make `execute` a no-op and teach `run` to resolve the passed revsets. I also fixed a my missunderstanding of `clap`, so the command is parsed correctly. `jj run 'mine() & ~origin@remote --jobs 4` is now parsed correctly. --- cli/src/commands/run.rs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/cli/src/commands/run.rs b/cli/src/commands/run.rs index 6b1ebb261a..4d5443a330 100644 --- a/cli/src/commands/run.rs +++ b/cli/src/commands/run.rs @@ -1,5 +1,8 @@ //! This file contains the internal implementation of `run`. -use crate::cli_util::{user_error, CommandError, CommandHelper, RevisionArg}; + +use crate::cli_util::{ + resolve_multiple_nonempty_revsets, user_error, CommandError, CommandHelper, RevisionArg, +}; use crate::ui::Ui; /// Run a command across a set of revisions. @@ -11,24 +14,30 @@ use crate::ui::Ui; /// # Example /// /// # Run pre-commit on your local work -/// $ jj run 'pre-commit.py .github/pre-commit.yaml' -r (main..@) -j 4 +/// $ jj run 'pre-commit run .github/pre-commit.yaml' -r (trunk()..@) -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. + shell_command: String, + /// A no-op option to match the interface of `git bisect -x`. #[arg(long, short, alias = "x")] - command: String, + command: bool, /// The revisions to change. + /// Multiple revsets are accepted and the work will be done on a + /// intersection of them. #[arg(long, short, default_value = "@")] revisions: Vec, + /// How many processes should run in parallel, uses by default all cores. + #[arg(long, short)] + jobs: Option, } -pub fn cmd_run( - _ui: &mut Ui, - _command: &CommandHelper, - _args: &RunArgs, -) -> Result<(), CommandError> { +pub fn cmd_run(ui: &mut Ui, command: &CommandHelper, args: &RunArgs) -> Result<(), CommandError> { + let workspace_command = command.workspace_helper(ui)?; + let _resolved_commits = + resolve_multiple_nonempty_revsets(&args.revisions, &workspace_command, ui)?; Err(user_error("This is a stub, do not use")) }