cli: add context to checkout/abandon messages triggered by automated git import

Otherwise, it's unclear why "jj status" abandoned commits for example.
This commit is contained in:
Yuya Nishihara 2023-10-01 17:35:38 +09:00
parent 8579bc479f
commit 480efc1503
6 changed files with 17 additions and 3 deletions

View file

@ -838,6 +838,7 @@ impl WorkspaceCommandHelper {
self.finish_transaction(ui, tx)?; self.finish_transaction(ui, tx)?;
} }
} }
writeln!(ui, "Done importing changes from the underlying Git repo.")?;
Ok(()) Ok(())
} }

View file

@ -371,6 +371,7 @@ fn test_log_git_head() {
std::fs::write(repo_path.join("file"), "foo\n").unwrap(); std::fs::write(repo_path.join("file"), "foo\n").unwrap();
let stdout = test_env.jj_cmd_success(&repo_path, &["log", "--color=always"]); let stdout = test_env.jj_cmd_success(&repo_path, &["log", "--color=always"]);
insta::assert_snapshot!(stdout, @r###" 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 @ rlvkpnrz test.user@example.com 2001-02-03 04:05:09.000 +07:00 50aaf475
initial initial
qpvuntsm test.user@example.com 2001-02-03 04:05:07.000 +07:00 master HEAD@git 230dd059 qpvuntsm test.user@example.com 2001-02-03 04:05:07.000 +07:00 master HEAD@git 230dd059

View file

@ -160,6 +160,7 @@ fn test_git_colocated_rebase_on_import() {
insta::assert_snapshot!(get_log_output(&test_env, &workspace_root), @r###" insta::assert_snapshot!(get_log_output(&test_env, &workspace_root), @r###"
Abandoned the following commits: Abandoned the following commits:
rlvkpnrz 45fbe1af master | modify a file rlvkpnrz 45fbe1af master | modify a file
Done importing changes from the underlying Git repo.
@ 7f96185cfbe36341d0f9a86ebfaeab67a5922c7e @ 7f96185cfbe36341d0f9a86ebfaeab67a5922c7e
4bcbeaba9a4b309c5f45a8807fbf5499b9714315 master HEAD@git add a file 4bcbeaba9a4b309c5f45a8807fbf5499b9714315 master HEAD@git add a file
0000000000000000000000000000000000000000 0000000000000000000000000000000000000000
@ -212,6 +213,7 @@ fn test_git_colocated_branches() {
kkmpptxz 35605592 master | (empty) bar kkmpptxz 35605592 master | (empty) bar
Working copy now at: yqosqzyt 096dc80d (empty) (no description set) Working copy now at: yqosqzyt 096dc80d (empty) (no description set)
Parent commit : qpvuntsm 230dd059 (empty) (no description set) Parent commit : qpvuntsm 230dd059 (empty) (no description set)
Done importing changes from the underlying Git repo.
@ 096dc80da67094fbaa6683e2a205dddffa31f9a8 @ 096dc80da67094fbaa6683e2a205dddffa31f9a8
1e6f0b403ed2ff9713b5d6b1dc601e4804250cda master foo 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 // The old working-copy commit gets abandoned, but the whole branch should not
// be abandoned. (#1042) // be abandoned. (#1042)
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
Done importing changes from the underlying Git repo.
@ 0521ce3b8c4e29aab79f3c750e2845dcbc4c3874 @ 0521ce3b8c4e29aab79f3c750e2845dcbc4c3874
a86754f975f953fa25da4265764adc0c62e9ce6b master HEAD@git A a86754f975f953fa25da4265764adc0c62e9ce6b master HEAD@git A
66f4d1806ae41bd604f69155dece64062a0056cf B 66f4d1806ae41bd604f69155dece64062a0056cf B
@ -364,6 +367,7 @@ fn test_git_colocated_squash_undo() {
test_env.jj_cmd_success(&repo_path, &["ci", "-m=A"]); test_env.jj_cmd_success(&repo_path, &["ci", "-m=A"]);
// Test the setup // Test the setup
insta::assert_snapshot!(get_log_output_divergence(&test_env, &repo_path), @r###" insta::assert_snapshot!(get_log_output_divergence(&test_env, &repo_path), @r###"
Done importing changes from the underlying Git repo.
@ rlvkpnrzqnoo 8f71e3b6a3be @ rlvkpnrzqnoo 8f71e3b6a3be
qpvuntsmwlqt a86754f975f9 A master HEAD@git qpvuntsmwlqt a86754f975f9 A master HEAD@git
zzzzzzzzzzzz 000000000000 zzzzzzzzzzzz 000000000000

View file

@ -262,6 +262,7 @@ fn test_git_fetch_from_remote_named_git() {
test_env.jj_cmd_success(&repo_path, &["git", "remote", "rename", "git", "bar"]); test_env.jj_cmd_success(&repo_path, &["git", "remote", "rename", "git", "bar"]);
let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list"]); let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list"]);
insta::assert_snapshot!(stdout, @r###" insta::assert_snapshot!(stdout, @r###"
Done importing changes from the underlying Git repo.
git: mrylzrtu 76fc7466 message git: mrylzrtu 76fc7466 message
"###); "###);
} }

View file

@ -50,9 +50,12 @@ fn test_gitsubmodule_print_gitmodules() {
&["git", "submodule", "print-gitmodules", "-r", "@-"], &["git", "submodule", "print-gitmodules", "-r", "@-"],
); );
insta::assert_snapshot!(stdout, @r###" insta::assert_snapshot!(stdout, @r###"
name:old Done importing changes from the underlying Git repo.
url:https://github.com/old/old.git name:old
path:old url:https://github.com/old/old.git
path:old
"###); "###);
let stdout = let stdout =

View file

@ -164,6 +164,7 @@ fn test_init_git_colocated() {
init_git_repo(&workspace_root, false); init_git_repo(&workspace_root, false);
let stdout = test_env.jj_cmd_success(&workspace_root, &["init", "--git-repo", "."]); let stdout = test_env.jj_cmd_success(&workspace_root, &["init", "--git-repo", "."]);
insta::assert_snapshot!(stdout, @r###" insta::assert_snapshot!(stdout, @r###"
Done importing changes from the underlying Git repo.
Initialized repo in "." Initialized repo in "."
"###); "###);
@ -211,6 +212,7 @@ fn test_init_git_colocated_gitlink() {
assert!(workspace_root.join(".git").is_file()); assert!(workspace_root.join(".git").is_file());
let stdout = test_env.jj_cmd_success(&workspace_root, &["init", "--git-repo", "."]); let stdout = test_env.jj_cmd_success(&workspace_root, &["init", "--git-repo", "."]);
insta::assert_snapshot!(stdout, @r###" insta::assert_snapshot!(stdout, @r###"
Done importing changes from the underlying Git repo.
Initialized repo in "." 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(); 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", "."]); let stdout = test_env.jj_cmd_success(&workspace_root, &["init", "--git-repo", "."]);
insta::assert_snapshot!(stdout, @r###" insta::assert_snapshot!(stdout, @r###"
Done importing changes from the underlying Git repo.
Initialized repo in "." 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(); 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", "."]); let stdout = test_env.jj_cmd_success(&workspace_root, &["init", "--git-repo", "."]);
insta::assert_snapshot!(stdout, @r###" insta::assert_snapshot!(stdout, @r###"
Done importing changes from the underlying Git repo.
Initialized repo in "." Initialized repo in "."
"###); "###);