Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions pkg/vendir/fetch/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,20 @@ func (t *Git) fetch(dstPath string, tempArea ctlfetch.TempArea, bundle string) e
}
}

argss = append(argss, []string{"config", "remote.origin.tagOpt", "--tags"})

if bundle != "" {
argss = append(argss, []string{"bundle", "unbundle", bundle})
}

exactRef := false
{
fetchArgs := []string{"fetch", "origin"}
if strings.HasPrefix(t.opts.Ref, "origin/") {
// only fetch the exact ref we're seeking
fetchArgs = append(fetchArgs, t.opts.Ref[7:])
exactRef = true
} else {
// Only fetch tags if not fetching exact ref
argss = append(argss, []string{"config", "remote.origin.tagOpt", "--tags"})
}
if t.opts.Depth > 0 {
fetchArgs = append(fetchArgs, "--depth", strconv.Itoa(t.opts.Depth))
Expand All @@ -201,7 +204,12 @@ func (t *Git) fetch(dstPath string, tempArea ctlfetch.TempArea, bundle string) e
}
}

_, _, err = t.cmdRunner.Run([]string{"-c", "advice.detachedHead=false", "checkout", ref}, env, dstPath)
checkoutRef := ref
if exactRef {
checkoutRef = "FETCH_HEAD"
}

_, _, err = t.cmdRunner.Run([]string{"-c", "advice.detachedHead=false", "checkout", checkoutRef}, env, dstPath)
if err != nil {
return err
}
Expand Down
Loading