From baef7f1da270a932dcd89a9ea812a03c308e07a6 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sat, 21 Oct 2023 07:09:29 +0900 Subject: [PATCH] cli: show stats if multiple branches are tracked/untracked Just like the other branch commands. --- cli/src/commands/branch.rs | 14 ++++++++++++++ cli/tests/test_branch_command.rs | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/cli/src/commands/branch.rs b/cli/src/commands/branch.rs index 98de4595a..eccd37ba6 100644 --- a/cli/src/commands/branch.rs +++ b/cli/src/commands/branch.rs @@ -496,6 +496,13 @@ fn cmd_branch_track( .track_remote_branch(&name.branch, &name.remote); } tx.finish(ui)?; + if names.len() > 1 { + writeln!( + ui.stderr(), + "Started tracking {} remote branches.", + names.len() + )?; + } Ok(()) } @@ -527,6 +534,13 @@ fn cmd_branch_untrack( .untrack_remote_branch(&name.branch, &name.remote); } tx.finish(ui)?; + if names.len() > 1 { + writeln!( + ui.stderr(), + "Stopped tracking {} remote branches.", + names.len() + )?; + } Ok(()) } diff --git a/cli/tests/test_branch_command.rs b/cli/tests/test_branch_command.rs index dcac38d15..3baa64b9c 100644 --- a/cli/tests/test_branch_command.rs +++ b/cli/tests/test_branch_command.rs @@ -778,7 +778,9 @@ fn test_branch_track_untrack_patterns() { // Track by pattern let (_, stderr) = test_env.jj_cmd_ok(&repo_path, &["branch", "track", "glob:feature?@origin"]); - insta::assert_snapshot!(stderr, @""); + insta::assert_snapshot!(stderr, @r###" + Started tracking 2 remote branches. + "###); insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###" feature1: omvolwpu 1336caed commit @git: omvolwpu 1336caed commit