Skip to content

Commit

Permalink
fix: do retry when git config failed
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlJi committed Dec 3, 2024
1 parent f8c3fbf commit eed8899
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions internal/linters/go/golangci_lint/golangci_lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,29 @@ func (g *gitConfigModifier) Modify(cfg *config.Linter) (*config.Linter, error) {

args := []string{
fmt.Sprintf(`
# delete the old git config
%s
currentConfig=$(%s)
if ! echo "$currentConfig" | grep -q "${ACCESS_TOKEN}" || [ -z "$currentConfig" ]; then
# add the new git config
%s
fi
configure_git() {
# delete the old git config
%s || return 1
currentConfig=$(%s) || return 1
if ! echo "$currentConfig" | grep -q "${ACCESS_TOKEN}" || [ -z "$currentConfig" ]; then
# add the new git config
%s || return 1
fi
return 0
}
max_retries=3
retry_delay=1
i=1
while [ $i -le $max_retries ]; do
if configure_git; then
break
else
sleep $retry_delay
fi
i=$((i+1))
done
`,
deleteOldConfigCmd,
currentConfigCmd,
Expand Down

0 comments on commit eed8899

Please sign in to comment.