Skip to content

Commit 23e2607

Browse files
committed
Log a message if the background worker resets HEAD
Background workers obtain a lock on the registry index so a reset should only occur if the last job modified the index but failed to push its commits, or the index was mutated externally (ex: to delete crates).
1 parent c24f74a commit 23e2607

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/git.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,18 @@ impl Repository {
252252

253253
pub fn reset_head(&self) -> Result<(), PerformError> {
254254
let mut origin = self.repository.find_remote("origin")?;
255+
let original_head = self.head_oid()?;
255256
origin.fetch(
256257
&["refs/heads/*:refs/heads/*"],
257258
Some(&mut Self::fetch_options(&self.credentials)),
258259
None,
259260
)?;
260261
let head = self.head_oid()?;
262+
263+
if head != original_head {
264+
println!("Resetting index from {} to {}", original_head, head);
265+
}
266+
261267
let obj = self.repository.find_object(head, None)?;
262268
self.repository.reset(&obj, git2::ResetType::Hard, None)?;
263269
Ok(())

0 commit comments

Comments
 (0)