Skip to content

Commit

Permalink
Fix grammar for message when only one commit is abandoned after Git i…
Browse files Browse the repository at this point in the history
…mport

Before:

- "Abandoned 1 commits that are no longer reachable."

After:

- "Abandoned 1 commit that is no longer reachable."
  • Loading branch information
emesterhazy committed Mar 2, 2024
1 parent a335321 commit 3f3ede1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
7 changes: 6 additions & 1 deletion cli/src/git_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,12 @@ pub fn print_git_import_stats(
}
}

if !stats.abandoned_commits.is_empty() {
if stats.abandoned_commits.len() == 1 {
writeln!(
ui.stderr(),
"Abandoned 1 commit that is no longer reachable."
)?;
} else if !stats.abandoned_commits.is_empty() {
writeln!(
ui.stderr(),
"Abandoned {} commits that are no longer reachable.",
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/test_branch_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ fn test_branch_track_untrack() {
branch: feature2@origin [updated] untracked
branch: feature3@origin [new] tracked
branch: main@origin [updated] tracked
Abandoned 1 commits that are no longer reachable.
Abandoned 1 commit that is no longer reachable.
"###);
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
feature1: sptzoqmo 7b33f629 commit 1
Expand Down
4 changes: 2 additions & 2 deletions cli/tests/test_git_colocated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ fn test_git_colocated_rebase_on_import() {
"###);
insta::assert_snapshot!(stderr, @r###"
Reset the working copy parent to the new Git HEAD.
Abandoned 1 commits that are no longer reachable.
Abandoned 1 commit that is no longer reachable.
Done importing changes from the underlying Git repo.
"###);
}
Expand Down Expand Up @@ -356,7 +356,7 @@ fn test_git_colocated_branches() {
◉ 0000000000000000000000000000000000000000
"###);
insta::assert_snapshot!(stderr, @r###"
Abandoned 1 commits that are no longer reachable.
Abandoned 1 commit that is no longer reachable.
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.
Expand Down
8 changes: 4 additions & 4 deletions cli/tests/test_git_fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ fn test_git_fetch_some_of_many_branches() {
insta::assert_snapshot!(stderr, @r###"
branch: a1@origin [updated] tracked
branch: b@origin [updated] tracked
Abandoned 1 commits that are no longer reachable.
Abandoned 1 commit that is no longer reachable.
"###);
insta::assert_snapshot!(get_log_output(&test_env, &target_jj_repo_path), @r###"
◉ 01d115196c39 descr_for_b b?? b@origin
Expand Down Expand Up @@ -760,7 +760,7 @@ fn test_git_fetch_some_of_many_branches() {
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r###"
branch: a2@origin [updated] tracked
Abandoned 1 commits that are no longer reachable.
Abandoned 1 commit that is no longer reachable.
"###);
insta::assert_snapshot!(get_log_output(&test_env, &target_jj_repo_path), @r###"
◉ 31c7d94b1f29 descr_for_a2 a2
Expand Down Expand Up @@ -1124,7 +1124,7 @@ fn test_git_fetch_removed_branch() {
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r###"
branch: a2@origin [deleted] untracked
Abandoned 1 commits that are no longer reachable.
Abandoned 1 commit that is no longer reachable.
"###);
insta::assert_snapshot!(get_log_output(&test_env, &target_jj_repo_path), @r###"
◉ c7d4bdcbc215 descr_for_b b
Expand Down Expand Up @@ -1204,7 +1204,7 @@ fn test_git_fetch_removed_parent_branch() {
insta::assert_snapshot!(stderr, @r###"
branch: a1@origin [deleted] untracked
branch: trunk1@origin [deleted] untracked
Abandoned 1 commits that are no longer reachable.
Abandoned 1 commit that is no longer reachable.
"###);
insta::assert_snapshot!(get_log_output(&test_env, &target_jj_repo_path), @r###"
◉ c7d4bdcbc215 descr_for_b b
Expand Down

0 comments on commit 3f3ede1

Please sign in to comment.