-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fail the CI build if there are any uncommitted changes #1535
Conversation
:: Detect if there are any changed files which should fail the build | ||
if DEFINED JENKINS_URL ( | ||
echo Detecting changed files... | ||
git diff --cached HEAD --exit-code |
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.
Isn't a failure here ignored since you go to the next line?
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.
You could maybe do git diff --exit-code HEAD
which should show all diffs between the work tree and HEAD.
Torn on --quiet
versus --exit-code
--it'd be nice to get a list on failure, so I guess I prefer --exit-code
.
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'm no git expert, but it worked when I tested it. I'm going to try this instead:
git --no-pager diff HEAD --word-diff=plain --exit-code
which seems to work...
5b2cf8a
to
b78ff40
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.
Since git status shows the files changed, that sounds good enough, even if git diff does not print anything.
I'll only be updating cibuild.cmd so ignore the other change as I'm using it to test this.