From a5eb308eb765df1e22271b839679dde4a87d6a9f Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sun, 30 Oct 2022 20:28:12 -0600 Subject: [PATCH 1/2] fix: bug detecting initial commits --- diff-sha.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index 3dfed91c..e1fc62eb 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -115,9 +115,9 @@ if [[ -z $GITHUB_BASE_REF ]]; then fi if [[ "$PREVIOUS_SHA" == "$CURRENT_SHA" ]]; then - PREVIOUS_SHA=$(git rev-parse "$CURRENT_SHA^1" 2>/dev/null || true) + PARENT_COUNT=$(git show -s --format="%P" "$CURRENT_SHA" | wc -w | xargs) - if [[ -z "$PREVIOUS_SHA" ]]; then + if [[ "$PARENT_COUNT" == "0" ]]; then INITIAL_COMMIT="true" PREVIOUS_SHA=$(git rev-parse "$CURRENT_SHA") echo "::warning::Initial commit detected no previous commit found." From 39518769ff39fcd5181fb4390766d495da539b36 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sun, 30 Oct 2022 20:38:35 -0600 Subject: [PATCH 2/2] Fixed test --- diff-sha.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index e1fc62eb..fe7b6a00 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -115,9 +115,7 @@ if [[ -z $GITHUB_BASE_REF ]]; then fi if [[ "$PREVIOUS_SHA" == "$CURRENT_SHA" ]]; then - PARENT_COUNT=$(git show -s --format="%P" "$CURRENT_SHA" | wc -w | xargs) - - if [[ "$PARENT_COUNT" == "0" ]]; 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."