Skip to content

Commit

Permalink
Merge pull request #729 from tj-actions/chore/update-debug-message
Browse files Browse the repository at this point in the history
  • Loading branch information
jackton1 committed Oct 31, 2022
2 parents bcba9b1 + 1e6b143 commit e793a5d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions diff-sha.sh
Expand Up @@ -18,12 +18,12 @@ if [[ -n $INPUT_PATH ]]; then
cd "$REPO_DIR"
fi

echo "Verifying git version..."

function __version() {
echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }';
}

echo "Verifying git version..."

GIT_VERSION=$(git --version | awk '{print $3}') && exit_status=$? || exit_status=$?

if [[ $exit_status -ne 0 ]]; then
Expand All @@ -32,7 +32,7 @@ if [[ $exit_status -ne 0 ]]; then
fi

if [[ $(__version "$GIT_VERSION") -lt $(__version "2.18.0") ]]; then
echo "::error::Invalid git version. Please upgrade git ($GIT_VERSION) to >= (2.18.0)"
echo "::error::Invalid git version. Please upgrade ($GIT_VERSION) to >= (2.18.0)"
exit 1
else
echo "Valid git version found: ($GIT_VERSION)"
Expand Down 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 e793a5d

Please sign in to comment.