Skip to content

Commit

Permalink
Merge pull request #3082 from buildkite/ps-179-handle-different-case-…
Browse files Browse the repository at this point in the history
…of-invalid-remote-ref-error

Handle older version of remote ref error message
  • Loading branch information
steveh authored Nov 11, 2024
2 parents a0fe131 + a597df6 commit 1223b00
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions internal/job/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,11 @@ func gitFetch(

const badObject = "fatal: bad object"
const badReference = "fatal: couldn't find remote ref"
const badReferencePreGit221 = "fatal: Couldn't find remote ref"
smelt := map[string]bool{
badObject: false,
badReference: false,
badObject: false,
badReference: false,
badReferencePreGit221: false,
}

if err := sh.Command("git", commandArgs...).Run(ctx, shell.WithStringSearch(smelt)); err != nil {
Expand All @@ -167,8 +169,8 @@ func gitFetch(
return &gitError{error: err, Type: gitErrorFetchBadObject}
}

// "fatal: couldn't find remote ref" can happen when the just the short commit hash is given.
if smelt[badReference] {
// "fatal: [Cc]ouldn't find remote ref" can happen when just the short commit hash is given.
if smelt[badReference] || smelt[badReferencePreGit221] {
return &gitError{error: err, Type: gitErrorFetchBadReference}
}

Expand Down

0 comments on commit 1223b00

Please sign in to comment.