Skip to content

Commit

Permalink
Checkout HEAD instead of master
Browse files Browse the repository at this point in the history
In cargo, `HEAD` is updated instead of `master`. This mismatch means
that the two refs can drift, depending on when cargo and this library
last fetched changes.

I believe this change will fix crate-ci/cargo-release#224.

https://github.com/rust-lang/cargo/blob/0b2059e9811caa238a603f0300d9c5fb485000a6/src/cargo/sources/registry/remote.rs#L56
  • Loading branch information
jtgeibel committed Mar 2, 2021
1 parent 183db53 commit 64fab0f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ impl Index {
let mut origin_remote = repo
.find_remote("origin")
.or_else(|_| repo.remote_anonymous(INDEX_GIT_URL))?;
origin_remote.fetch(&["master"], Some(&mut fetch_opts()), None)?;
origin_remote.fetch(&["HEAD"], Some(&mut fetch_opts()), None)?;
let oid = repo.refname_to_id("FETCH_HEAD")?;
let object = repo.find_object(oid, None).unwrap();
repo.reset(&object, git2::ResetType::Hard, None)?;
Expand Down

0 comments on commit 64fab0f

Please sign in to comment.