Skip to content

Commit

Permalink
fix: check if base sha exists
Browse files Browse the repository at this point in the history
When base branch is out of date (not synced with upstream), the base sha
could have value of `0000000000000000000000000000000000000000`. In such
case differential ShellCheck can't use it to compare with the head sha
and it will exit.
  • Loading branch information
jamacku committed Feb 10, 2025
1 parent c1485df commit 9897406
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ git config --global --add safe.directory "${GITHUB_WORKSPACE:-}"
# Chose correct BASE and HEAD commit for scan
pick_base_and_head_hash || exit 1

# Check if Base sha exists
if [[ "${BASE}" = "0000000000000000000000000000000000000000" ]]; then
echo "::warning:: git: base SHA1 (${BASE}) doesn't exist. Make sure that the base branch is up-to-date."
exit 1
fi

# Make sure we have correct BASE even when force-push was used
# source: https://stackoverflow.com/a/69893210/10221282
# !FIXME: It doesn't seems to work. Seems like action/checkout doesn't fetch all commits, so if we want to support force-pushes we probaly need to do it manually
Expand Down

0 comments on commit 9897406

Please sign in to comment.