From ea67d63d69a9c2ed63577e80a2e308e724a3f495 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Fri, 15 Dec 2023 21:50:35 +0900 Subject: [PATCH 1/2] cli: remove weird line break from the "jj branch forget" hint The message seems a bit too long, but it doesn't make sense to insert \n in the middle of sentence. --- cli/src/commands/branch.rs | 4 ++-- cli/tests/test_branch_command.rs | 27 +++++++++------------------ cli/tests/test_git_fetch.rs | 6 ++---- cli/tests/test_git_push.rs | 3 +-- cli/tests/test_undo.rs | 6 ++---- 5 files changed, 16 insertions(+), 30 deletions(-) diff --git a/cli/src/commands/branch.rs b/cli/src/commands/branch.rs index b869926821..2c755af3ec 100644 --- a/cli/src/commands/branch.rs +++ b/cli/src/commands/branch.rs @@ -706,8 +706,8 @@ fn cmd_branch_list( if found_non_git_remote { writeln!( formatter, - " (this branch will be *deleted permanently* on the remote on the\n next \ - `jj git push`. Use `jj branch forget` to prevent this)" + " (this branch will be *deleted permanently* on the remote on the next `jj \ + git push`. Use `jj branch forget` to prevent this)" )?; } else { writeln!( diff --git a/cli/tests/test_branch_command.rs b/cli/tests/test_branch_command.rs index 43fd21a7be..7a0881673b 100644 --- a/cli/tests/test_branch_command.rs +++ b/cli/tests/test_branch_command.rs @@ -333,16 +333,13 @@ fn test_branch_delete_glob() { @origin: qpvuntsm 6fbf398c (empty) commit foo-1 (deleted) @origin: qpvuntsm 6fbf398c (empty) commit - (this branch will be *deleted permanently* on the remote on the - next `jj git push`. Use `jj branch forget` to prevent this) + (this branch will be *deleted permanently* on the remote on the next `jj git push`. Use `jj branch forget` to prevent this) foo-3 (deleted) @origin: qpvuntsm 6fbf398c (empty) commit - (this branch will be *deleted permanently* on the remote on the - next `jj git push`. Use `jj branch forget` to prevent this) + (this branch will be *deleted permanently* on the remote on the next `jj git push`. Use `jj branch forget` to prevent this) foo-4 (deleted) @origin: qpvuntsm 6fbf398c (empty) commit - (this branch will be *deleted permanently* on the remote on the - next `jj git push`. Use `jj branch forget` to prevent this) + (this branch will be *deleted permanently* on the remote on the next `jj git push`. Use `jj branch forget` to prevent this) "###); // Malformed glob @@ -583,8 +580,7 @@ fn test_branch_forget_deleted_or_nonexistent_branch() { insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###" feature1 (deleted) @origin: mzyxwzks 9f01a0e0 message - (this branch will be *deleted permanently* on the remote on the - next `jj git push`. Use `jj branch forget` to prevent this) + (this branch will be *deleted permanently* on the remote on the next `jj git push`. Use `jj branch forget` to prevent this) "###); // ============ End of test setup ============ @@ -947,8 +943,7 @@ fn test_branch_list() { local-only: wqnwkozp 4e887f78 (empty) local-only remote-delete (deleted) @origin: mnmymoky 203e60eb (empty) remote-delete - (this branch will be *deleted permanently* on the remote on the - next `jj git push`. Use `jj branch forget` to prevent this) + (this branch will be *deleted permanently* on the remote on the next `jj git push`. Use `jj branch forget` to prevent this) remote-sync: zwtyzrop c761c7ea (empty) remote-sync remote-unsync: wqnwkozp 4e887f78 (empty) local-only @origin (ahead by 1 commits, behind by 1 commits): qpsqxpyq 38ef8af7 (empty) remote-unsync @@ -959,8 +954,7 @@ fn test_branch_list() { local-only: wqnwkozp 4e887f78 (empty) local-only remote-delete (deleted) @origin: mnmymoky 203e60eb (empty) remote-delete - (this branch will be *deleted permanently* on the remote on the - next `jj git push`. Use `jj branch forget` to prevent this) + (this branch will be *deleted permanently* on the remote on the next `jj git push`. Use `jj branch forget` to prevent this) remote-sync: zwtyzrop c761c7ea (empty) remote-sync @origin: zwtyzrop c761c7ea (empty) remote-sync remote-unsync: wqnwkozp 4e887f78 (empty) local-only @@ -1023,8 +1017,7 @@ fn test_branch_list_filtered() { local-keep: kpqxywon c7b4c09c (empty) local-keep remote-delete (deleted) @origin: yxusvupt dad5f298 (empty) remote-delete - (this branch will be *deleted permanently* on the remote on the - next `jj git push`. Use `jj branch forget` to prevent this) + (this branch will be *deleted permanently* on the remote on the next `jj git push`. Use `jj branch forget` to prevent this) remote-keep: nlwprzpn 911e9120 (empty) remote-keep remote-rewrite: xyxluytn e31634b6 (empty) rewritten @origin (ahead by 1 commits, behind by 1 commits): xyxluytn hidden 3e9a5af6 (empty) remote-rewrite @@ -1067,8 +1060,7 @@ fn test_branch_list_filtered() { insta::assert_snapshot!(query(&["remote-delete"]), @r###" remote-delete (deleted) @origin: yxusvupt dad5f298 (empty) remote-delete - (this branch will be *deleted permanently* on the remote on the - next `jj git push`. Use `jj branch forget` to prevent this) + (this branch will be *deleted permanently* on the remote on the next `jj git push`. Use `jj branch forget` to prevent this) "###); insta::assert_snapshot!(query(&["-rbranches(remote-delete)"]), @r###" "###); @@ -1082,8 +1074,7 @@ fn test_branch_list_filtered() { local-keep: kpqxywon c7b4c09c (empty) local-keep remote-delete (deleted) @origin: yxusvupt dad5f298 (empty) remote-delete - (this branch will be *deleted permanently* on the remote on the - next `jj git push`. Use `jj branch forget` to prevent this) + (this branch will be *deleted permanently* on the remote on the next `jj git push`. Use `jj branch forget` to prevent this) remote-keep: nlwprzpn 911e9120 (empty) remote-keep "###); diff --git a/cli/tests/test_git_fetch.rs b/cli/tests/test_git_fetch.rs index 7b97ff5162..bb263e853a 100644 --- a/cli/tests/test_git_fetch.rs +++ b/cli/tests/test_git_fetch.rs @@ -876,8 +876,7 @@ fn test_fetch_undo_what() { insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###" b (deleted) @origin: vpupmnsl hidden c7d4bdcb descr_for_b - (this branch will be *deleted permanently* on the remote on the - next `jj git push`. Use `jj branch forget` to prevent this) + (this branch will be *deleted permanently* on the remote on the next `jj git push`. Use `jj branch forget` to prevent this) "###); // Now, let's demo restoring just the remote-tracking branch. First, let's @@ -886,8 +885,7 @@ fn test_fetch_undo_what() { insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###" b (deleted) @origin: vpupmnsl hidden c7d4bdcb descr_for_b - (this branch will be *deleted permanently* on the remote on the - next `jj git push`. Use `jj branch forget` to prevent this) + (this branch will be *deleted permanently* on the remote on the next `jj git push`. Use `jj branch forget` to prevent this) newbranch: qpvuntsm 230dd059 (empty) (no description set) "###); // Restoring just the remote-tracking state will not affect `newbranch`, but diff --git a/cli/tests/test_git_push.rs b/cli/tests/test_git_push.rs index e3ad26f252..9d9e04867f 100644 --- a/cli/tests/test_git_push.rs +++ b/cli/tests/test_git_push.rs @@ -280,8 +280,7 @@ fn test_git_push_multiple() { insta::assert_snapshot!(stdout, @r###" branch1 (deleted) @origin: lzmmnrxq 45a3aa29 (empty) description 1 - (this branch will be *deleted permanently* on the remote on the - next `jj git push`. Use `jj branch forget` to prevent this) + (this branch will be *deleted permanently* on the remote on the next `jj git push`. Use `jj branch forget` to prevent this) branch2: yqosqzyt 15dcdaa4 (empty) foo @origin (ahead by 1 commits, behind by 1 commits): rlzusymt 8476341e (empty) description 2 my-branch: yqosqzyt 15dcdaa4 (empty) foo diff --git a/cli/tests/test_undo.rs b/cli/tests/test_undo.rs index 685ba1478b..05ea894140 100644 --- a/cli/tests/test_undo.rs +++ b/cli/tests/test_undo.rs @@ -344,8 +344,7 @@ fn test_branch_track_untrack_undo() { @origin: qpvuntsm 270721f5 (empty) commit feature2 (deleted) @origin: qpvuntsm 270721f5 (empty) commit - (this branch will be *deleted permanently* on the remote on the - next `jj git push`. Use `jj branch forget` to prevent this) + (this branch will be *deleted permanently* on the remote on the next `jj git push`. Use `jj branch forget` to prevent this) "###); // Track/untrack can be undone so long as states can be trivially merged. @@ -365,8 +364,7 @@ fn test_branch_track_untrack_undo() { @origin: qpvuntsm 270721f5 (empty) commit feature2 (deleted) @origin: qpvuntsm 270721f5 (empty) commit - (this branch will be *deleted permanently* on the remote on the - next `jj git push`. Use `jj branch forget` to prevent this) + (this branch will be *deleted permanently* on the remote on the next `jj git push`. Use `jj branch forget` to prevent this) "###); test_env.jj_cmd_ok(&repo_path, &["undo"]); From 9a70d5239c892318e803802178432fadb3016aea Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Fri, 15 Dec 2023 21:55:33 +0900 Subject: [PATCH 2/2] cli: colorize inline "jj branch" command hints This is a bit different from the ordinary ui hints, but I feel the colored output is easier to follow. --- cli/src/commands/branch.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/src/commands/branch.rs b/cli/src/commands/branch.rs index 2c755af3ec..35a5a91448 100644 --- a/cli/src/commands/branch.rs +++ b/cli/src/commands/branch.rs @@ -705,13 +705,13 @@ fn cmd_branch_list( .any(|&(remote, _)| remote != git::REMOTE_NAME_FOR_LOCAL_GIT_REPO); if found_non_git_remote { writeln!( - formatter, + formatter.labeled("hint"), " (this branch will be *deleted permanently* on the remote on the next `jj \ git push`. Use `jj branch forget` to prevent this)" )?; } else { writeln!( - formatter, + formatter.labeled("hint"), " (this branch will be deleted from the underlying Git repo on the next `jj \ git export`)" )?;