Skip to content

Commit

Permalink
Fixed bug retrieving the first commit of a pull request
Browse files Browse the repository at this point in the history
  • Loading branch information
jackton1 committed Oct 31, 2022
1 parent 983dfd7 commit 1e6b143
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion diff-sha.sh
Expand Up @@ -111,14 +111,16 @@ if [[ -z $GITHUB_BASE_REF ]]; then
fi

if [[ -z "$PREVIOUS_SHA" || "$PREVIOUS_SHA" == "0000000000000000000000000000000000000000" ]]; then
PREVIOUS_SHA=$(git rev-parse "$(git branch -r --sort=-committerdate | head -1 | xargs)")
PREVIOUS_SHA=$CURRENT_SHA
fi

if [[ "$PREVIOUS_SHA" == "$CURRENT_SHA" ]]; then
if ! git rev-parse "$PREVIOUS_SHA^1" &>/dev/null; then
INITIAL_COMMIT="true"
PREVIOUS_SHA=$(git rev-parse "$CURRENT_SHA")
echo "::warning::Initial commit detected no previous commit found."
else
PREVIOUS_SHA=$(git rev-parse "$PREVIOUS_SHA^1")
fi
else
if [[ -z "$PREVIOUS_SHA" ]]; then
Expand Down

0 comments on commit 1e6b143

Please sign in to comment.