You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@yetus.apache.org by aw...@apache.org on 2020/09/29 17:54:23 UTC

[yetus] branch main updated: YETUS-1006. Determine git sha (#141)

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

aw pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/yetus.git


The following commit(s) were added to refs/heads/main by this push:
     new f429491  YETUS-1006. Determine git sha (#141)
f429491 is described below

commit f42949116e188894bcf9e94d04a6f4c38a598998
Author: Allen Wittenauer <aw...@apache.org>
AuthorDate: Tue Sep 29 10:54:16 2020 -0700

    YETUS-1006. Determine git sha (#141)
    
    Signed-off-by: Akira Ajisaka <aa...@apache.org>
---
 precommit/src/main/shell/robots.d/circleci.sh   | 2 +-
 precommit/src/main/shell/robots.d/cirrusci.sh   | 2 +-
 precommit/src/main/shell/robots.d/jenkins.sh    | 9 +++++----
 precommit/src/main/shell/robots.d/travisci.sh   | 2 +-
 precommit/src/main/shell/test-patch.d/github.sh | 6 +++---
 precommit/src/main/shell/test-patch.sh          | 8 +++++---
 6 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/precommit/src/main/shell/robots.d/circleci.sh b/precommit/src/main/shell/robots.d/circleci.sh
index b5b6153..9e69917 100755
--- a/precommit/src/main/shell/robots.d/circleci.sh
+++ b/precommit/src/main/shell/robots.d/circleci.sh
@@ -61,7 +61,7 @@ if [[ "${CIRCLECI}" = true ]] &&
       CIRCLECI
 
     # shellcheck disable=SC2034
-    GITHUB_SHA=${CIRCLE_SHA1}
+    GIT_BRANCH_SHA=${CIRCLE_SHA1}
 
     yetus_add_array_element EXEC_MODES Circle_CI
   fi
diff --git a/precommit/src/main/shell/robots.d/cirrusci.sh b/precommit/src/main/shell/robots.d/cirrusci.sh
index a5e6aab..56de9f9 100755
--- a/precommit/src/main/shell/robots.d/cirrusci.sh
+++ b/precommit/src/main/shell/robots.d/cirrusci.sh
@@ -59,7 +59,7 @@ if [[ "${CIRRUS_CI}" == true ]] &&
     CIRRUS_TASK_ID
 
   # shellcheck disable=SC2034
-  GITHUB_SHA=${CIRRUS_BASE_SHA}
+  GIT_BRANCH_SHA=${CIRRUS_BASE_SHA}
 
   # shellcheck disable=SC2034
   BUILD_URL="https://cirrus-ci.com/task/${CIRRUS_TASK_ID}"
diff --git a/precommit/src/main/shell/robots.d/jenkins.sh b/precommit/src/main/shell/robots.d/jenkins.sh
index 813655c..789df13 100755
--- a/precommit/src/main/shell/robots.d/jenkins.sh
+++ b/precommit/src/main/shell/robots.d/jenkins.sh
@@ -103,10 +103,11 @@ if [[ -n "${JENKINS_URL}" && -n "${EXECUTOR_NUMBER}" ]] &&
     GIT_URL \
     JENKINS_URL
 
-  # Enable writes to GitHub Statuses
-  if [[ -z "${GITHUB_SHA}" ]]; then
+  # Jenkins doesn't always define this, so this
+  # dependency is highly unreliable
+  if [[ -n "${GIT_COMMIT}" ]]; then
     # shellcheck disable=SC2034
-    GITHUB_SHA=${GIT_COMMIT}
+    GIT_BRANCH_SHA=${GIT_COMMIT}
   fi
 
   yetus_add_array_element EXEC_MODES Jenkins
@@ -180,4 +181,4 @@ function jenkins_finalreport
 function jenkins_artifact_url
 {
   echo "${BUILD_URL}${BUILD_URL_ARTIFACTS}"
-}
\ No newline at end of file
+}
diff --git a/precommit/src/main/shell/robots.d/travisci.sh b/precommit/src/main/shell/robots.d/travisci.sh
index 7f306fd..8898e3e 100755
--- a/precommit/src/main/shell/robots.d/travisci.sh
+++ b/precommit/src/main/shell/robots.d/travisci.sh
@@ -47,7 +47,7 @@ if [[ "${TRAVIS}" == true ]] &&
   GITHUB_REPO=${TRAVIS_REPO_SLUG}
 
   # shellcheck disable=SC2034
-  GITHUB_SHA=${TRAVIS_PULL_REQUEST_SHA}
+  GIT_BRANCH_SHA=${TRAVIS_PULL_REQUEST_SHA}
 
   add_docker_env \
     TRAVIS \
diff --git a/precommit/src/main/shell/test-patch.d/github.sh b/precommit/src/main/shell/test-patch.d/github.sh
index 20325aa..d9ff015 100755
--- a/precommit/src/main/shell/test-patch.d/github.sh
+++ b/precommit/src/main/shell/test-patch.d/github.sh
@@ -722,7 +722,7 @@ function github_status_write()
     "${githubauth[@]}" \
     -d @"${filename}" \
     --location \
-    "${GITHUB_API_URL}/repos/${GITHUB_REPO}/statuses/${GITHUB_SHA}" \
+    "${GITHUB_API_URL}/repos/${GITHUB_REPO}/statuses/${GIT_BRANCH_SHA}" \
     > /dev/null
 
   retval=$?
@@ -767,8 +767,8 @@ function github_finalreport
     return 0
   fi
 
-  if [[ -z "${GITHUB_SHA}" ]]; then
-    echo "Unknown GITHUB_SHA defined. Skipping."
+  if [[ -z "${GIT_BRANCH_SHA}" ]]; then
+    echo "Unknown GIT_BRANCH_SHA defined. Skipping."
     return 0
   fi
 
diff --git a/precommit/src/main/shell/test-patch.sh b/precommit/src/main/shell/test-patch.sh
index c2dddb0..d5d3aa1 100755
--- a/precommit/src/main/shell/test-patch.sh
+++ b/precommit/src/main/shell/test-patch.sh
@@ -315,9 +315,7 @@ function prepopulate_footer
     add_footer_table "Personality" "${PERSONALITY}"
   fi
 
-  gitrev=$("${GIT}" rev-parse --verify --short HEAD)
-
-  add_footer_table "git revision" "${PATCH_BRANCH} / ${gitrev}"
+  add_footer_table "git revision" "${PATCH_BRANCH} / ${GIT_BRANCH_SHA}"
 }
 
 ## @description  Last minute entries on the footer table
@@ -1276,6 +1274,10 @@ function git_checkout
     fi
   fi
 
+  if [[ -z "${GIT_BRANCH_SHA}" ]]; then
+    GIT_BRANCH_SHA=$("${GIT}" log -1 --format="%H")
+  fi
+
   return 0
 }