Skip to content

Commit f60614d

Browse files
committed
Error if there is nothing to pull
1 parent ef3a86c commit f60614d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

josh-sync/src/sync.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,19 @@ impl GitSync {
8181
};
8282
let num_roots_before = num_roots()?;
8383

84+
let sha = cmd!(sh, "git rev-parse HEAD").run().context("FAILED to get current commit")?;
85+
8486
// Merge the fetched commit.
8587
const MERGE_COMMIT_MESSAGE: &str = "Merge from rustc";
8688
cmd!(sh, "git merge FETCH_HEAD --no-verify --no-ff -m {MERGE_COMMIT_MESSAGE}")
8789
.run()
8890
.context("FAILED to merge new commits, something went wrong")?;
8991

92+
let current_sha = cmd!(sh, "git rev-parse HEAD").run().context("FAILED to get current commit")?;
93+
if current_sha == sha {
94+
return Err(anyhow::anyhow!("No merge was performed, nothing to pull"));
95+
}
96+
9097
// Check that the number of roots did not increase.
9198
if num_roots()? != num_roots_before {
9299
bail!("Josh created a new root commit. This is probably not the history you want.");

0 commit comments

Comments
 (0)