Browse Source

CI: fix check_dco.sh not working with other repos

Fixes #546

Resolves: <https://git.meli-email.org/meli/meli/issues/546>
Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
Manos Pitsidianakis 7 months ago
parent
commit
a1c9524f
1 changed files with 13 additions and 3 deletions
  1. 13 3
      .gitea/check_dco.sh

+ 13 - 3
.gitea/check_dco.sh

@@ -15,6 +15,7 @@
 
 export GIT_CONFIG_GLOBAL=""
 export GIT_CONFIG_SYSTEM=""
+export GIT_CONFIG_NOSYSTEM=1
 
 ensure_env_var() {
   set | grep -q "^${1}=" || (printf "Environment variable %s missing from process environment, exiting.\n" "${1}"; exit "${2}")
@@ -32,7 +33,12 @@ contains_signoff() {
 }
 
 get_commit_sha() {
-  git rev-parse "${1}"
+  if OUT=$(git rev-parse "${1}"); then
+    printf "%s" "${OUT}"
+    return
+  fi
+  printf "Could not git-rev-parse %s, falling back to HEAD...\n" "${1}" 1>&2
+  git rev-parse HEAD
 }
 
 echo "Debug workflow info:"
@@ -43,10 +49,14 @@ HEAD_REF=$(get_commit_sha "${GITHUB_HEAD_REF}")
 echo "Processed base ref BASE_REF=${BASE_REF}"
 echo "Processed head ref HEAD_REF=${HEAD_REF}"
 
-RANGE="${BASE_REF}^..${HEAD_REF}"
+RANGE="${BASE_REF}..${HEAD_REF}"
 echo "Range to examine is RANGE=${RANGE}"
 
-SHA_LIST=$(git rev-list "${RANGE}")
+if ! SHA_LIST=$(git rev-list "${RANGE}"); then
+  printf "Could not get commit range %s with git rev-list, bailing out...\n" "${RANGE}"
+  exit 0
+fi
+
 echo "SHA list to examine is SHA_LIST="
 echo "---------------------------------------------------------------------"
 echo "${SHA_LIST}"