Skip to content

Commit

Permalink
Merge pull request #4 from Start-Out/feature/tools
Browse files Browse the repository at this point in the history
PATCH: git-hooks Tool scripts
  • Loading branch information
trentonyo authored Aug 6, 2024
2 parents 59d71e7 + 2a5f062 commit 2610630
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Starterfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,15 @@ tools:
check: |
npm install semver
./scripts/check-git.bat
SET EXIT_CODE=%ERRORLEVEL%
npm uninstall semver
exit /b %EXIT_CODE%
check: |
npm install semver
bash ./scripts/check-git.bash
EXIT_CODE=$?
npm uninstall semver
exit $EXIT_CODE
install: git config --local core.hooksPath .githooks/
uninstall: git config --local --unset core.hooksPath

Expand Down
4 changes: 3 additions & 1 deletion scripts/check-git.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ GIT_VERSION=$(echo $VERSION_STRING | awk '{print $3}')

if [[ $(semver "$GIT_VERSION" -r ">=$REQUIRED_VERSION") ]]; then
echo "Git version is greater than or equal to $REQUIRED_VERSION"
echo "-- FAILING CHECK In order to install git hooks"
exit 1
else
echo "Git version is less than $REQUIRED_VERSION"
exit 1
echo "-- Unable to install git hooks"
fi
2 changes: 1 addition & 1 deletion scripts/check-git.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ set REQUIRED_VERSION=2.9.0
for /f "tokens=3 USEBACKQ" %%F in (`git --version`) do (
set GIT_VERSION=%%F
)
node -e " var semver = require('semver'); var gitVersion = '%GIT_VERSION%'; gitVersion = gitVersion.split('.').slice(0, 3).join('.'); if(semver.gte(gitVersion, '%REQUIRED_VERSION%')) console.log('Git version is greater than or equal to %REQUIRED_VERSION% (%GIT_VERSION%)'); else console.log('Git version is less than %REQUIRED_VERSION% (%GIT_VERSION%)'); process.exit(1);"
node -e " var semver = require('semver'); var gitVersion = '%GIT_VERSION%'; gitVersion = gitVersion.split('.').slice(0, 3).join('.'); if(semver.gte(gitVersion, '%REQUIRED_VERSION%')) console.log('Git version is greater than or equal to %REQUIRED_VERSION% (%GIT_VERSION%)\n-- FAILING CHECK In order to install git hooks'); process.exit(1); else console.log('Git version is less than %REQUIRED_VERSION% (%GIT_VERSION%)\n-- Unable to install git hooks');"

0 comments on commit 2610630

Please sign in to comment.