Skip to content

Commit

Permalink
chore(git): ignore git config exit code
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalbreuninger committed Jan 14, 2025
1 parent 613f7d3 commit b35dbf3
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pkg/gitcredentials/gitcredentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,9 @@ func GetHTTPPath(ctx context.Context, params GetHttpPathParameters) (string, err

// Check if we need to respect gits `credential.useHttpPath`
// The actual format for the key is `credential.$PROTOCOL://$HOST.useHttpPath`, i.e. `credential.https://github.com.useHttpPath`
// We need to ignore the error as git will always exit with 1 if the key doesn't exist
configKey := fmt.Sprintf("credential.%s://%s.useHttpPath", params.Protocol, params.Host)
out, err := git.CommandContext(ctx, "config", "--get", configKey).Output()
if err != nil {
return "", fmt.Errorf("inspect useHttpPath for host %s: %w", params.Host, err)
}
out, _ := git.CommandContext(ctx, "config", "--get", configKey).Output()
if strings.TrimSpace(string(out)) != "true" {
return "", nil
}
Expand Down

0 comments on commit b35dbf3

Please sign in to comment.