From 94b74d587ef9da0ce75b4d4b505a313f7ff0f0fd Mon Sep 17 00:00:00 2001 From: Hidde Beydals Date: Mon, 1 Apr 2019 12:50:16 +0200 Subject: [PATCH] Cast error msg to lowercase to support Git 2.21 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, casting it to lowercase enables support for both versions. Ref: https://github.com/git/git/commit/0b9c3afdbfb62936337efc52b4007a446939b96b --- git/operations.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/git/operations.go b/git/operations.go index 5e664e569..26419daed 100644 --- a/git/operations.go +++ b/git/operations.go @@ -120,8 +120,12 @@ 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...) + // 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(err.Error(), "Couldn't find remote ref") { + !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 nil