CI: Fix checkers tripping over empty GitHub Actions references

When the internal git reference is nonexistent, GitHub Actions seems
to convert that value into a hash made up of only zeroes. As that
hash will be commit-ish it will pass verification.

git cat-file will fail if the provided reference cannot be resolved
in the repository so should be the safer choice.
This commit is contained in:
PatTheMav 2023-08-16 23:38:56 +02:00 committed by Ryan Foster
parent 3a347fe327
commit ea8ea39e29
5 changed files with 5 additions and 5 deletions

View file

@ -38,7 +38,7 @@ runs:
shopt -s extglob
shopt -s dotglob
if ! git rev-parse --verify ${GIT_BASE_REF} &> /dev/null; then
if ! git cat-file -e "${GIT_BASE_REF}" &> /dev/null; then
echo "::warning::Provided base reference ${GIT_BASE_REF} is invalid"
if [[ "${USE_FALLBACK}" == 'true' ]]; then
GIT_BASE_REF='HEAD~1'

View file

@ -46,7 +46,7 @@ runs:
shopt -s extglob
shopt -s globstar
if ! git rev-parse --verify "${GITHUB_REF_BEFORE}" &> /dev/null; then
if ! git cat-file -e "${GITHUB_REF_BEFORE}" &> /dev/null; then
GITHUB_REF_BEFORE='4b825dc642cb6eb9a060e54bf8d69288fbee4904'
fi

View file

@ -43,7 +43,7 @@ runs:
: Run clang-format 🐉
if (( ${+RUNNER_DEBUG} )) setopt XTRACE
if ! git rev-parse --verify ${GITHUB_REF_BEFORE} &> /dev/null; then
if ! git cat-file -e ${GITHUB_REF_BEFORE} &> /dev/null; then
GITHUB_REF_BEFORE='4b825dc642cb6eb9a060e54bf8d69288fbee4904'
fi

View file

@ -42,7 +42,7 @@ runs:
: Run cmake-format 🎛️
if (( ${+RUNNER_DEBUG} )) setopt XTRACE
if ! git rev-parse --verify ${GITHUB_REF_BEFORE} &> /dev/null; then
if ! git cat-file -e ${GITHUB_REF_BEFORE} &> /dev/null; then
GITHUB_REF_BEFORE='4b825dc642cb6eb9a060e54bf8d69288fbee4904'
fi

View file

@ -42,7 +42,7 @@ runs:
: Run swift-format 🔥
if (( ${+RUNNER_DEBUG} )) setopt XTRACE
if ! git rev-parse --verify ${GITHUB_REF_BEFORE} &> /dev/null; then
if ! git cat-file -e ${GITHUB_REF_BEFORE} &> /dev/null; then
GITHUB_REF_BEFORE='4b825dc642cb6eb9a060e54bf8d69288fbee4904'
fi