Skip to content

Commit 007fd8d

Browse files
committed
Clean up preparation commit if no pull was performed
1 parent 5bb1310 commit 007fd8d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

josh-sync/src/sync.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ impl GitSync {
9191

9292
let current_sha = cmd!(sh, "git rev-parse HEAD").run().context("FAILED to get current commit")?;
9393
if current_sha == sha {
94-
return Err(anyhow::anyhow!("No merge was performed, nothing to pull"));
94+
cmd!(sh, "git reset --hard HEAD^")
95+
.run()
96+
.expect("FAILED to clean up after creating the preparation commit");
97+
return Err(anyhow::anyhow!("No merge was performed, nothing to pull. Rolled back the preparation commit."));
9598
}
9699

97100
// Check that the number of roots did not increase.

0 commit comments

Comments
 (0)