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

Commit

Permalink
Fetch tags with --force due to changes in Git 2.20
Browse files Browse the repository at this point in the history
"Until Git version 2.20, and unlike when pushing with git-push[1], any
updates to refs/tags/* would be accepted without + in the refspec (or
--force). When fetching, we promiscuously considered all tag updates
from a remote to be forced fetches. Since Git version 2.20, fetching
to update refs/tags/* works the same way as when pushing. I.e. any
updates will be rejected without + in the refspec (or --force)."

https://git-scm.com/docs/git-fetch
https://github.com/git/git/blob/master/Documentation/RelNotes/2.20.0.txt#L67-L71
  • Loading branch information
hiddeco committed Jun 24, 2019
1 parent a526626 commit 2fc3a71
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions git/operations.go
Expand Up @@ -126,14 +126,14 @@ func push(ctx context.Context, workingDir, upstream string, refs []string) error

// fetch updates refs from the upstream.
func fetch(ctx context.Context, workingDir, upstream string, refspec ...string) error {
args := append([]string{"fetch", "--tags", upstream}, refspec...)
args := append([]string{"fetch", "--tags", "--force", upstream}, refspec...)
// In git <=2.20 the error started with an uppercase, in 2.21 this
// was changed to be consistent with all other die() and error()
// messages, cast to lowercase to support both versions.
// Ref: https://github.com/git/git/commit/0b9c3afdbfb62936337efc52b4007a446939b96b
if err := execGitCmd(ctx, args, gitCmdConfig{dir: workingDir}); err != nil &&
!strings.Contains(strings.ToLower(err.Error()), "couldn't find remote ref") {
return errors.Wrap(err, fmt.Sprintf("git fetch --tags %s %s", upstream, refspec))
return errors.Wrap(err, fmt.Sprintf("git fetch --tags --force %s %s", upstream, refspec))
}
return nil
}
Expand Down

0 comments on commit 2fc3a71

Please sign in to comment.