From 480efc1503fd8e19e8d28804e843bbdaf5a2856e Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sun, 1 Oct 2023 17:35:38 +0900 Subject: [PATCH] cli: add context to checkout/abandon messages triggered by automated git import Otherwise, it's unclear why "jj status" abandoned commits for example. --- cli/src/cli_util.rs | 1 + cli/tests/test_commit_template.rs | 1 + cli/tests/test_git_colocated.rs | 4 ++++ cli/tests/test_git_fetch.rs | 1 + cli/tests/test_git_submodule.rs | 9 ++++++--- cli/tests/test_init_command.rs | 4 ++++ 6 files changed, 17 insertions(+), 3 deletions(-) diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index d7291dfb3..b4c41859c 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -838,6 +838,7 @@ impl WorkspaceCommandHelper { self.finish_transaction(ui, tx)?; } } + writeln!(ui, "Done importing changes from the underlying Git repo.")?; Ok(()) } diff --git a/cli/tests/test_commit_template.rs b/cli/tests/test_commit_template.rs index 68f5c2ddd..9871c67b6 100644 --- a/cli/tests/test_commit_template.rs +++ b/cli/tests/test_commit_template.rs @@ -371,6 +371,7 @@ fn test_log_git_head() { std::fs::write(repo_path.join("file"), "foo\n").unwrap(); let stdout = test_env.jj_cmd_success(&repo_path, &["log", "--color=always"]); insta::assert_snapshot!(stdout, @r###" + Done importing changes from the underlying Git repo. @ rlvkpnrz test.user@example.com 2001-02-03 04:05:09.000 +07:00 50aaf475 │ initial ◉ qpvuntsm test.user@example.com 2001-02-03 04:05:07.000 +07:00 master HEAD@git 230dd059 diff --git a/cli/tests/test_git_colocated.rs b/cli/tests/test_git_colocated.rs index e76f19c1a..57125ce0b 100644 --- a/cli/tests/test_git_colocated.rs +++ b/cli/tests/test_git_colocated.rs @@ -160,6 +160,7 @@ fn test_git_colocated_rebase_on_import() { insta::assert_snapshot!(get_log_output(&test_env, &workspace_root), @r###" Abandoned the following commits: rlvkpnrz 45fbe1af master | modify a file + Done importing changes from the underlying Git repo. @ 7f96185cfbe36341d0f9a86ebfaeab67a5922c7e ◉ 4bcbeaba9a4b309c5f45a8807fbf5499b9714315 master HEAD@git add a file ◉ 0000000000000000000000000000000000000000 @@ -212,6 +213,7 @@ fn test_git_colocated_branches() { kkmpptxz 35605592 master | (empty) bar Working copy now at: yqosqzyt 096dc80d (empty) (no description set) Parent commit : qpvuntsm 230dd059 (empty) (no description set) + Done importing changes from the underlying Git repo. @ 096dc80da67094fbaa6683e2a205dddffa31f9a8 │ ◉ 1e6f0b403ed2ff9713b5d6b1dc601e4804250cda master foo ├─╯ @@ -347,6 +349,7 @@ fn test_git_colocated_external_checkout() { // The old working-copy commit gets abandoned, but the whole branch should not // be abandoned. (#1042) insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" + Done importing changes from the underlying Git repo. @ 0521ce3b8c4e29aab79f3c750e2845dcbc4c3874 ◉ a86754f975f953fa25da4265764adc0c62e9ce6b master HEAD@git A │ ◉ 66f4d1806ae41bd604f69155dece64062a0056cf B @@ -364,6 +367,7 @@ fn test_git_colocated_squash_undo() { test_env.jj_cmd_success(&repo_path, &["ci", "-m=A"]); // Test the setup insta::assert_snapshot!(get_log_output_divergence(&test_env, &repo_path), @r###" + Done importing changes from the underlying Git repo. @ rlvkpnrzqnoo 8f71e3b6a3be ◉ qpvuntsmwlqt a86754f975f9 A master HEAD@git ◉ zzzzzzzzzzzz 000000000000 diff --git a/cli/tests/test_git_fetch.rs b/cli/tests/test_git_fetch.rs index de03a7afd..e984ccb58 100644 --- a/cli/tests/test_git_fetch.rs +++ b/cli/tests/test_git_fetch.rs @@ -262,6 +262,7 @@ fn test_git_fetch_from_remote_named_git() { test_env.jj_cmd_success(&repo_path, &["git", "remote", "rename", "git", "bar"]); let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list"]); insta::assert_snapshot!(stdout, @r###" + Done importing changes from the underlying Git repo. git: mrylzrtu 76fc7466 message "###); } diff --git a/cli/tests/test_git_submodule.rs b/cli/tests/test_git_submodule.rs index e6cbe9d14..7a4b834e7 100644 --- a/cli/tests/test_git_submodule.rs +++ b/cli/tests/test_git_submodule.rs @@ -50,9 +50,12 @@ fn test_gitsubmodule_print_gitmodules() { &["git", "submodule", "print-gitmodules", "-r", "@-"], ); insta::assert_snapshot!(stdout, @r###" - name:old - url:https://github.com/old/old.git - path:old + Done importing changes from the underlying Git repo. + name:old + url:https://github.com/old/old.git + path:old + + "###); let stdout = diff --git a/cli/tests/test_init_command.rs b/cli/tests/test_init_command.rs index 1902715b7..7f0f5e088 100644 --- a/cli/tests/test_init_command.rs +++ b/cli/tests/test_init_command.rs @@ -164,6 +164,7 @@ fn test_init_git_colocated() { init_git_repo(&workspace_root, false); let stdout = test_env.jj_cmd_success(&workspace_root, &["init", "--git-repo", "."]); insta::assert_snapshot!(stdout, @r###" + Done importing changes from the underlying Git repo. Initialized repo in "." "###); @@ -211,6 +212,7 @@ fn test_init_git_colocated_gitlink() { assert!(workspace_root.join(".git").is_file()); let stdout = test_env.jj_cmd_success(&workspace_root, &["init", "--git-repo", "."]); insta::assert_snapshot!(stdout, @r###" + Done importing changes from the underlying Git repo. Initialized repo in "." "###); @@ -244,6 +246,7 @@ fn test_init_git_colocated_symlink_directory() { std::os::unix::fs::symlink(git_repo_path.join(".git"), workspace_root.join(".git")).unwrap(); let stdout = test_env.jj_cmd_success(&workspace_root, &["init", "--git-repo", "."]); insta::assert_snapshot!(stdout, @r###" + Done importing changes from the underlying Git repo. Initialized repo in "." "###); @@ -282,6 +285,7 @@ fn test_init_git_colocated_symlink_gitlink() { std::os::unix::fs::symlink(git_workdir_path.join(".git"), workspace_root.join(".git")).unwrap(); let stdout = test_env.jj_cmd_success(&workspace_root, &["init", "--git-repo", "."]); insta::assert_snapshot!(stdout, @r###" + Done importing changes from the underlying Git repo. Initialized repo in "." "###);