You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ds...@apache.org on 2024/01/15 18:30:01 UTC

(solr) branch branch_9x updated: Build: validation.git.failOnModified default to isCIBuild (#2196)

This is an automated email from the ASF dual-hosted git repository.

dsmiley pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new 61bd41baa9a Build: validation.git.failOnModified default to isCIBuild (#2196)
61bd41baa9a is described below

commit 61bd41baa9a4d8d6ab448986cd8922e8e8ea3566
Author: David Smiley <ds...@apache.org>
AuthorDate: Mon Jan 15 13:27:54 2024 -0500

    Build: validation.git.failOnModified default to isCIBuild (#2196)
---
 gradle/globals.gradle               |  2 +-
 gradle/validation/git-status.gradle | 14 ++++++++++++--
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/gradle/globals.gradle b/gradle/globals.gradle
index f08a033b118..48131b3003b 100644
--- a/gradle/globals.gradle
+++ b/gradle/globals.gradle
@@ -168,6 +168,6 @@ allprojects {
     // detect if we run in CI environment by looking at existence of env vars:
     // "CI": Github (https://docs.github.com/en/actions/learn-github-actions/environment-variables)
     // anything starting with "JENKINS_" or "HUDSON_": Jenkins/Hudson (https://jenkins.thetaphi.de/env-vars.html/)
-    isCIBuild = System.getenv().keySet().find { it ==~ /(?i)((JENKINS|HUDSON)(_\w+)?|CI)/ } != null
+    isCIBuild = System.getenv().keySet().any { it ==~ /(?i)((JENKINS|HUDSON)(_\w+)?|CI)/ }
   }
 }
diff --git a/gradle/validation/git-status.gradle b/gradle/validation/git-status.gradle
index 5ce6195bf93..b34cf831ef7 100644
--- a/gradle/validation/git-status.gradle
+++ b/gradle/validation/git-status.gradle
@@ -103,8 +103,18 @@ configure(rootProject) {
           files.collect {file -> "  - ${file} ${fileStatus}" }
         }.sort()
 
-        def checkProp = "validation.git.failOnModified"
-        failOrWarn(checkProp, "Working copy is not a clean git checkout", offenders)
+        if (offenders ) {
+          def propName = "validation.git.failOnModified"
+          def shouldFail = Boolean.valueOf(propertyOrDefault(propName, isCIBuild))
+          def msg = "Working copy is not a clean git checkout" +
+                  (shouldFail ? " (skip with -P${propName}=false)" : "") + ":\n${offenders.join("\n")}"
+
+          if (shouldFail) {
+            throw new GradleException(msg)
+          } else {
+            logger.warn("NOTE: ${msg}")
+          }
+        }
       }
     }
   }