Skip to content
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

Merged
merged 1 commit into from
Jan 13, 2017

Conversation

jeffkl
Copy link
Contributor

@jeffkl jeffkl commented Jan 10, 2017

I'll only be updating cibuild.cmd so ignore the other change as I'm using it to test this.

:: 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
Copy link
Member

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?

Copy link
Member

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.

Copy link
Contributor Author

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...

@jeffkl jeffkl force-pushed the failonchanges branch 4 times, most recently from 5b2cf8a to b78ff40 Compare January 12, 2017 21:12
Copy link
Contributor

@cdmihai cdmihai left a 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.

@jeffkl jeffkl merged commit c2a2a0c into dotnet:xplat Jan 13, 2017
@jeffkl jeffkl deleted the failonchanges branch January 13, 2017 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants