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

feat: validate the minimum required git version #572

Merged
merged 4 commits into from Aug 13, 2022
Merged
Changes from 2 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
15 changes: 14 additions & 1 deletion diff-sha.sh
Expand Up @@ -17,13 +17,26 @@ if [[ -n $INPUT_PATH ]]; then
cd "$REPO_DIR"
fi

git --version 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?

echo "Verifying git version..."

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

GIT_VERSION=$(git --version 1>/dev/null 2>&1 | awk '{print $3}'); exit_status=$?

if [[ $exit_status -ne 0 ]]; then
echo "::error::git not installed"
exit 1
fi

if [[ $(__version $GIT_VERSION) -lt $(__version "2.18.0") ]]; then
jackton1 marked this conversation as resolved.
Show resolved Hide resolved
Fixed Show fixed Hide fixed
echo "::error::Invalid git version. Please upgrade git ($GIT_VERSION) to >= (2.18.0)"
else
echo "Valid git version found: ($GIT_VERSION)"
fi

echo "::debug::Getting HEAD SHA..."

if [[ -z $INPUT_SHA ]]; then
Expand Down