Skip to content

Commit

Permalink
fix: handle errors for repositories without any previous commit histo…
Browse files Browse the repository at this point in the history
…ry (#404)

* fix: Handle errors for repositories without any previous commit history

Fixes: #365

* Update diff-sha.sh
  • Loading branch information
jackton1 authored Feb 26, 2022
1 parent f5d5eb9 commit a53d74f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion diff-sha.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ if [[ -z $GITHUB_BASE_REF ]]; then
CURRENT_BRANCH=$TARGET_BRANCH

if [[ -z $INPUT_BASE_SHA ]]; then
PREVIOUS_SHA=$(git rev-list --no-merges -n 1 HEAD^1 2>&1) && exit_status=$? || exit_status=$?
if [[ $(git rev-list --count HEAD) -gt 1 ]]; then
PREVIOUS_SHA=$(git rev-list --no-merges -n 1 HEAD^1 2>&1) && exit_status=$? || exit_status=$?
else
PREVIOUS_SHA=$CURRENT_SHA
fi
else
PREVIOUS_SHA=$INPUT_BASE_SHA && exit_status=$? || exit_status=$?
TARGET_BRANCH=$(git name-rev --name-only "$PREVIOUS_SHA" 2>&1) && exit_status=$? || exit_status=$?
Expand Down

0 comments on commit a53d74f

Please sign in to comment.