-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpre-commit.sh
More file actions
executable file
·36 lines (30 loc) · 1.09 KB
/
Copy pathpre-commit.sh
File metadata and controls
executable file
·36 lines (30 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# Format staged java files using google-java-format plugin
echo "Formatting staged files as per Google Java Style Guide"
set -e
# Retrieve staged files
STAGED_FILES_FILE=$(mktemp)
git diff --cached --name-only --diff-filter=d > "${STAGED_FILES_FILE}"
# Process the files
mvn -f pom.xml git-code-format:on-pre-commit -DstagedFilesFile=${STAGED_FILES_FILE}
# Add the files to staging again in case they were modified by the process
while read file; do
git add "${file}"
done <${STAGED_FILES_FILE}
rm ${STAGED_FILES_FILE}
# Run Tests
echo "Running tests to ensure minimum required code coverage is met :)"
mvn clean verify
# Runninng Static Analysis on staged files
echo "Runninng Static Analysis on staged files"
set -e
# Retrieve staged files
STAGED_FILES_FILE=$(mktemp)
git diff --cached --name-only --diff-filter=d > "${STAGED_FILES_FILE}"
# Process the files
mvn -f pom.xml spotbugs:check -DstagedFilesFile=${STAGED_FILES_FILE}
# Add the files to staging again in case they were modified by the process
while read file; do
git add "${file}"
done <${STAGED_FILES_FILE}
rm ${STAGED_FILES_FILE}