From 2a1c2e05ba66103c5dc86c4d91859b92204f0bb6 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Thu, 8 Dec 2022 20:04:33 -0800 Subject: [PATCH] cli: when colocated with Git, export refs on snapshot This fixes the bug described in the previous commit. Because we now print the message about failed exports also while snapshotting, we may end up reporting it twice on one command. I'm not sure it's worth worrying about that. We can deal with that later if it turns out to be a common complaint. --- CHANGELOG.md | 3 +++ src/cli_util.rs | 6 ++++++ tests/test_git_colocated.rs | 3 +-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae6e7a1e2..2fa327e41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed bugs +* When sharing the working copy with a Git repo, we used to forget to export + branches to Git when only the working copy had changed. That's now fixed. + ### Contributors Thanks to the people who made this release happen! diff --git a/src/cli_util.rs b/src/cli_util.rs index 04c7f2559..999ca2dac 100644 --- a/src/cli_util.rs +++ b/src/cli_util.rs @@ -743,6 +743,12 @@ impl WorkspaceCommandHelper { )?; } + if self.working_copy_shared_with_git { + let git_repo = self.repo.store().git_repo().unwrap(); + let failed_branches = git::export_refs(mut_repo, &git_repo)?; + print_failed_git_export(ui, &failed_branches)?; + } + self.repo = tx.commit(); } locked_wc.finish(self.repo.op_id().clone()); diff --git a/tests/test_git_colocated.rs b/tests/test_git_colocated.rs index 40ca66f8b..6c5694f71 100644 --- a/tests/test_git_colocated.rs +++ b/tests/test_git_colocated.rs @@ -120,13 +120,12 @@ fn test_git_colocated_export_branches_on_snapshot() { @ fab22d1acf5bb9c5aa48cb2c3dd2132072a359ca foo o 0000000000000000000000000000000000000000 "###); - // TODO: The branch should point to the modified commit insta::assert_snapshot!(git_repo .find_reference("refs/heads/foo") .unwrap() .target() .unwrap() - .to_string(), @"438471f3fbf1004298d8fb01eeb13663a051a643"); + .to_string(), @"fab22d1acf5bb9c5aa48cb2c3dd2132072a359ca"); } #[test]