Skip to content

Commit 256213a

Browse files
committed
Allow dependency's rev to refer to a ref by name
1 parent 72aee9e commit 256213a

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/cargo/sources/git/utils.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -799,13 +799,17 @@ pub fn fetch(
799799
refspecs.push(String::from("HEAD:refs/remotes/origin/HEAD"));
800800
}
801801

802-
// For `rev` dependencies we don't know what the rev will point to. To
803-
// handle this situation we fetch all branches and tags, and then we
804-
// pray it's somewhere in there.
805-
GitReference::Rev(_) => {
806-
refspecs.push(String::from("refs/heads/*:refs/remotes/origin/*"));
807-
refspecs.push(String::from("HEAD:refs/remotes/origin/HEAD"));
808-
tags = true;
802+
GitReference::Rev(rev) => {
803+
if rev.starts_with("refs/") {
804+
refspecs.push(format!("{0}:{0}", rev));
805+
} else {
806+
// We don't know what the rev will point to. To handle this
807+
// situation we fetch all branches and tags, and then we pray
808+
// it's somewhere in there.
809+
refspecs.push(String::from("refs/heads/*:refs/remotes/origin/*"));
810+
refspecs.push(String::from("HEAD:refs/remotes/origin/HEAD"));
811+
tags = true;
812+
}
809813
}
810814
}
811815

0 commit comments

Comments
 (0)