3
0
Fork 0
mirror of https://github.com/tj-actions/changed-files synced 2025-01-16 23:17:49 +00:00

fix: handle errors for repositories without any previous commit history (#404)

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

Fixes: #365

* Update diff-sha.sh
This commit is contained in:
Tonye Jack 2022-02-26 05:09:14 -05:00 committed by GitHub
parent f5d5eb9133
commit a53d74f700
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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=$?