Browse Source

Build: Ensure upstream check works even when using info logging (#23804)

The LoggedExec task does not capture output when info logging is
enabled. This commit changes the upstream check to use Exec directly,
so as not to break when info logging is enabled.
Ryan Ernst 8 years ago
parent
commit
a903aabbd6
1 changed files with 9 additions and 1 deletions
  1. 9 1
      distribution/bwc-zip/build.gradle

+ 9 - 1
distribution/bwc-zip/build.gradle

@@ -35,11 +35,19 @@ task createClone(type: LoggedExec) {
   commandLine = ['git', 'clone', rootDir, checkoutDir]
   commandLine = ['git', 'clone', rootDir, checkoutDir]
 }
 }
 
 
-task findUpstream(type: LoggedExec) {
+// we use regular Exec here to ensure we always get output, regardless of logging level
+task findUpstream(type: Exec) {
   dependsOn createClone
   dependsOn createClone
   workingDir = checkoutDir
   workingDir = checkoutDir
   commandLine = ['git', 'remote', '-v']
   commandLine = ['git', 'remote', '-v']
+  ignoreExitValue = true
+  ByteArrayOutputStream output = new ByteArrayOutputStream()
+  standardOutput = output
   doLast {
   doLast {
+    if (execResult.exitValue != 0) {
+      output.toString('UTF-8').eachLine { line -> logger.error(line) }
+      execResult.assertNormalExitValue()
+    }
     project.ext.upstreamExists = false
     project.ext.upstreamExists = false
     output.toString('UTF-8').eachLine {
     output.toString('UTF-8').eachLine {
       if (it.contains("upstream")) {
       if (it.contains("upstream")) {