From 64fab0f0fc2078df0782ebb01e15db3cb5af671d Mon Sep 17 00:00:00 2001 From: Justin Geibel Date: Tue, 2 Mar 2021 18:30:18 -0500 Subject: [PATCH] Checkout `HEAD` instead of `master` 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 sunng87/cargo-release#224. https://github.com/rust-lang/cargo/blob/0b2059e9811caa238a603f0300d9c5fb485000a6/src/cargo/sources/registry/remote.rs#L56 --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index c6d1c9c8..f3945f45 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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)?;