Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Force fetch tags on checkout local working clone #2184

Merged
merged 1 commit into from
Jun 26, 2019
Merged
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
12 changes: 12 additions & 0 deletions git/working.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ func (r *Repo) Clone(ctx context.Context, conf Config) (*Checkout, error) {
}

r.mu.RLock()
// Here is where we mimic `git fetch --tags --force`, but
// _without_ overwriting head refs. This is only required for a
// `Checkout` and _not_ for `Repo` as (bare) mirrors will happily
// accept any ref changes to tags.
//
// NB: do this before any other fetch actions, as otherwise we may
// get an 'existing tag clobber' error back.
if err := fetch(ctx, repoDir, r.dir, `'+refs/tags/*:refs/tags/*'`); err != nil {
os.RemoveAll(repoDir)
r.mu.RUnlock()
return nil, err
}
if err := fetch(ctx, repoDir, r.dir, realNotesRef+":"+realNotesRef); err != nil {
os.RemoveAll(repoDir)
r.mu.RUnlock()
Expand Down