From adfe0b29e7f2430e702c1d6259b488997c477fb9 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 13 Aug 2022 15:28:29 -0600 Subject: [PATCH 1/4] feat: validate the minimum required git version Closes: #564 --- diff-sha.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/diff-sha.sh b/diff-sha.sh index 1aad74d5948..d292e623069 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -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") ]]; + 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 From 94a951338ce9b5ffbbbf4242a16c34a14361b111 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 13 Aug 2022 15:29:53 -0600 Subject: [PATCH 2/4] Update diff-sha.sh --- diff-sha.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diff-sha.sh b/diff-sha.sh index d292e623069..e3efddc6eff 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -31,7 +31,7 @@ if [[ $exit_status -ne 0 ]]; then exit 1 fi -if [[ $(__version $GIT_VERSION) -lt $(__version "2.18.0") ]]; +if [[ $(__version $GIT_VERSION) -lt $(__version "2.18.0") ]]; then echo "::error::Invalid git version. Please upgrade git ($GIT_VERSION) to >= (2.18.0)" else echo "Valid git version found: ($GIT_VERSION)" From ec8274f4e26ea48a015489055bcea9b64478d219 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 13 Aug 2022 15:31:08 -0600 Subject: [PATCH 3/4] Update diff-sha.sh Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- diff-sha.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diff-sha.sh b/diff-sha.sh index e3efddc6eff..3c548f577e1 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -31,7 +31,7 @@ if [[ $exit_status -ne 0 ]]; then exit 1 fi -if [[ $(__version $GIT_VERSION) -lt $(__version "2.18.0") ]]; then +if [[ $(__version "$GIT_VERSION") -lt $(__version "2.18.0") ]]; then echo "::error::Invalid git version. Please upgrade git ($GIT_VERSION) to >= (2.18.0)" else echo "Valid git version found: ($GIT_VERSION)" From 5b2a4c6bf8dc50fb1c4f1a5a48b054248d9250a3 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 13 Aug 2022 15:35:50 -0600 Subject: [PATCH 4/4] Update diff-sha.sh --- diff-sha.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/diff-sha.sh b/diff-sha.sh index 3c548f577e1..645885c3661 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -24,7 +24,7 @@ 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=$? +GIT_VERSION=$(git --version | awk '{print $3}'); exit_status=$? if [[ $exit_status -ne 0 ]]; then echo "::error::git not installed" @@ -33,6 +33,7 @@ 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)" + exit 1 else echo "Valid git version found: ($GIT_VERSION)" fi