Skip to content

Commit

Permalink
fix printing of Git changes
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdubiel committed Oct 11, 2016
1 parent 35bcb8b commit df733ed
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
@@ -0,0 +1,21 @@
package pl.allegro.tech.build.axion.release

import org.gradle.testkit.runner.TaskOutcome

class VerifyReleaseIntegrationTest extends BaseIntegrationTest {

def "should print changes in Git as seen by axion-release"() {
given:
buildFile('')
temporaryFolder.newFile('my-uncommitted-file') << "hello"

when:
def result = runGradle('verifyRelease', '-Prelease.dryRun', '-Prelease.localOnly')

then:
result.output.contains("Unstaged changes:")
result.output.contains('my-uncommitted-file')
result.task(":verifyRelease").outcome == TaskOutcome.SUCCESS
}

}
Expand Up @@ -28,11 +28,12 @@ class VerifyReleaseTask extends DefaultTask {
if (checksRules.checkUncommittedChanges) {
boolean uncommittedChanges = repository.checkUncommittedChanges()
project.logger.quiet("Looking for uncommitted changes.. ${uncommittedChanges ? 'FAILED' : ''}")
if (uncommittedChanges && !dryRun) {
if (uncommittedChanges) {
changesPrinter.printChanges()

throw new IllegalStateException("There are uncommitted files in your repository - can't release. " +
"See above for list of all changes.")
if (!dryRun) {
throw new IllegalStateException("There are uncommitted files in your repository - can't release. " +
"See above for list of all changes.")
}
}
} else {
project.logger.quiet('Skipping uncommitted changes check')
Expand Down
Expand Up @@ -35,7 +35,7 @@ class GitChangesPrinter implements ScmChangesPrinter {

private void printChangeset(String type, Set<String> changes) {
if (!changes.empty) {
changes.each { outputLine(style, type, it) }
changes.each { outputLine(type, it) }
}
}

Expand Down

0 comments on commit df733ed

Please sign in to comment.