Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: colorize inline "jj branch" command hints #2708

Merged
merged 2 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cli/src/commands/branch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
" (this branch will be *deleted permanently* on the remote on the\n next \
`jj git push`. Use `jj branch forget` to prevent this)"
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`)"
)?;
Expand Down
27 changes: 9 additions & 18 deletions cli/tests/test_branch_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ============
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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###"
"###);
Expand All @@ -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
"###);

Expand Down
6 changes: 2 additions & 4 deletions cli/tests/test_git_fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions cli/tests/test_git_push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions cli/tests/test_undo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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"]);
Expand Down