Skip to content

Commit

Permalink
Fix fetching when no branch is specified (#148)
Browse files Browse the repository at this point in the history
While the configuration with `revision` and without a `branch` is not
recommended, and fetching all branches is not very efficient, there are
such `protofetch.toml` files in the wild, so we need to maintain the
compatibility with them.
  • Loading branch information
rtimush authored Aug 1, 2024
1 parent 728c8a5 commit e5a4e8e
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/git/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,9 @@ impl<'a> ProtoGitRepository<'a> {
let mut refspecs = Vec::with_capacity(3);
if let Revision::Pinned { revision } = &specification.revision {
refspecs.push(format!("+refs/tags/{}:refs/tags/{}", revision, revision));
// Some protofetch.toml files specify branch in the revision field, so we
// need to fetch branches as well to maintain compatibility.
refspecs.push(format!(
"+refs/heads/{}:refs/remotes/origin/{}",
revision, revision
));
// Some protofetch.toml files specify branch in the revision field,
// or do not specify the branch at all, so we need to fetch all branches.
refspecs.push("+refs/heads/*:refs/remotes/origin/*".to_owned());
}
if let Some(branch) = &specification.branch {
refspecs.push(format!(
Expand Down

0 comments on commit e5a4e8e

Please sign in to comment.