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>
This commit is contained in:
Manos Pitsidianakis 2024-12-05 16:43:27 +02:00
parent 2257b91b40
commit a1c9524f74
No known key found for this signature in database
GPG key ID: 7729C7707F7E09D0

View file

@ -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}"