Allow dependency's rev to refer to a ref by name

This commit is contained in:
David Tolnay 2021-08-30 18:15:05 -07:00
parent 72aee9e815
commit 256213a655
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -799,13 +799,17 @@ pub fn fetch(
refspecs.push(String::from("HEAD:refs/remotes/origin/HEAD"));
}
// For `rev` dependencies we don't know what the rev will point to. To
// handle this situation we fetch all branches and tags, and then we
// pray it's somewhere in there.
GitReference::Rev(_) => {
refspecs.push(String::from("refs/heads/*:refs/remotes/origin/*"));
refspecs.push(String::from("HEAD:refs/remotes/origin/HEAD"));
tags = true;
GitReference::Rev(rev) => {
if rev.starts_with("refs/") {
refspecs.push(format!("{0}:{0}", rev));
} else {
// We don't know what the rev will point to. To handle this
// situation we fetch all branches and tags, and then we pray
// it's somewhere in there.
refspecs.push(String::from("refs/heads/*:refs/remotes/origin/*"));
refspecs.push(String::from("HEAD:refs/remotes/origin/HEAD"));
tags = true;
}
}
}