mirror of
https://github.com/tj-actions/changed-files
synced 2025-01-30 09:35:15 +00:00
feat: validate the minimum required git version (#572)
* feat: validate the minimum required git version Closes: #564 * Update diff-sha.sh * Update diff-sha.sh Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update diff-sha.sh Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
0c7f7d1ce7
commit
7dd9711c64
1 changed files with 15 additions and 1 deletions
16
diff-sha.sh
16
diff-sha.sh
|
@ -17,13 +17,27 @@ if [[ -n $INPUT_PATH ]]; then
|
||||||
cd "$REPO_DIR"
|
cd "$REPO_DIR"
|
||||||
fi
|
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 | awk '{print $3}'); exit_status=$?
|
||||||
|
|
||||||
if [[ $exit_status -ne 0 ]]; then
|
if [[ $exit_status -ne 0 ]]; then
|
||||||
echo "::error::git not installed"
|
echo "::error::git not installed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
||||||
|
|
||||||
echo "::debug::Getting HEAD SHA..."
|
echo "::debug::Getting HEAD SHA..."
|
||||||
|
|
||||||
if [[ -z $INPUT_SHA ]]; then
|
if [[ -z $INPUT_SHA ]]; then
|
||||||
|
|
Loading…
Reference in a new issue