-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1881 from jplag/feature/gitPreCommit
Added pre-commit hook checking spotless
- Loading branch information
Showing
7 changed files
with
77 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/sh | ||
|
||
echo "Running pre commit checks" | ||
|
||
hasJavaFiles=0 | ||
hasJsFiles=0 | ||
|
||
files=`git diff --name-only --cached` | ||
while read name | ||
do | ||
if [[ $name == report-viewer* ]] | ||
then | ||
hasJsFiles=1 | ||
fi | ||
|
||
if [[ $name == *.java ]] | ||
then | ||
hasJavaFiles=1 | ||
fi | ||
done <<< "$files" | ||
|
||
if [[ $hasJsFiles -gt 0 ]] | ||
then | ||
echo "Running report viewer pre commit checks" | ||
cd report-viewer | ||
../gitHooks/scripts/reportViewerPreCommit | ||
if [ $? -gt 0 ] | ||
then | ||
exit 1 | ||
fi | ||
cd .. | ||
fi | ||
|
||
if [[ $hasJavaFiles -gt 0 ]] | ||
then | ||
echo "Running java pre commit checks" | ||
gitHooks/scripts/javaPreCommit | ||
if [ $? -gt 0 ] | ||
then | ||
exit 1 | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
if ! command -v mvn &> /dev/null #checks if maven is installed | ||
then | ||
echo "Maven is not installed. Spotless will not be checked" | ||
exit 0 | ||
fi | ||
|
||
#prevents the shell from aborting if maven returns a non zero exit code | ||
set +e | ||
echo Checking spotless | ||
mvn spotless:check &> /dev/null | ||
exitCode=$? | ||
|
||
if [ $exitCode -gt 0 ] | ||
then | ||
echo "Spotless failed. Please run 'mvn spotless:apply' to fix." | ||
fi | ||
exit $exitCode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
if ! command -v npm &> /dev/null #checks if npm is installed | ||
then | ||
echo "Npm is not installed. Linter check will be skipped" | ||
exit 0 | ||
fi | ||
|
||
npx lint-staged |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters