-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wipe checkout directory on git checkout
and git fetch
failure and retry
#2137
Wipe checkout directory on git checkout
and git fetch
failure and retry
#2137
Conversation
6e3ca39
to
6bbd748
Compare
git fetch
failure and retrygit checkout
and git fetch
failure and retry
if b.Config.Repository == "" { | ||
b.shell.Commentf("Skipping checkout, BUILDKITE_REPO is empty") | ||
break | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This used to be on 1197. I've inverted the condition to decrease the indentation.
6bbd748
to
03edbe9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this!
@@ -211,19 +213,19 @@ func (b *BootstrapTester) writeHookScript(m *bintest.Mock, name string, dir stri | |||
body = "#!/bin/sh\n" + strings.Join(append([]string{m.Path}, args...), " ") | |||
} | |||
|
|||
if err := os.MkdirAll(dir, 0700); err != nil { | |||
if err := os.MkdirAll(dir, 0o700); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍👍👍
Co-authored-by: Josh Deprez <[email protected]>
There are a certain class of errors from git in the
defaultCheckoutPhase
that would cause a retry, but before the retry, the checkout directory would be removed. This allows cleaning up in case an unclean exit from git had left the checkout directory in an unrecoverable state.This PR adds failures in
git fetch
andgit checkout
when the exit code is 128 to that class of error. It also fixes the detection of errors for which the check directory needed to be clean, as previously, the detection would fail if the errors were wrapped, and they are wrapped in thedefaultCheckoutPhase
method.I've done some refactoring to reduce the indentation level of the code, so I recommend reviewing with whitespace changes hidden.