Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update debug message #729

Merged
merged 2 commits into from
Oct 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions diff-sha.sh
Original file line number Diff line number Diff line change
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