mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-02 17:35:18 +00:00
* Add precommit for secret scanning, formatting and license header checking. * Turn off bash debug logging. * Skip precommit checks that apply to all files. There are too many violations to run against all files.
41 lines
780 B
Bash
Executable File
41 lines
780 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set +x
|
|
|
|
if [[ -z ${GITHUB_MODIFIED_FILES} ]]
|
|
then
|
|
modified_files=$(git diff --cached --name-only --diff-filter=ACMR)
|
|
else
|
|
modified_files=${GITHUB_MODIFIED_FILES}
|
|
fi
|
|
|
|
include_list=""
|
|
for file in ${modified_files}
|
|
do
|
|
include_list="${include_list},${file}"
|
|
done
|
|
include_list=${include_list:1}
|
|
|
|
mvn spotless:apply validate -DlicenseUpdateHeaders=true -Dspotless-include-list="${include_list}" > /dev/null || true
|
|
|
|
all_nonconformant_files=$(git diff --name-only --diff-filter=ACMR)
|
|
|
|
for file in ${all_nonconformant_files}
|
|
do
|
|
revert=1
|
|
for modified_file in ${modified_files}
|
|
do
|
|
if [[ "${modified_file}" == "${file}" ]]
|
|
then
|
|
revert=0
|
|
break
|
|
fi
|
|
done
|
|
if [[ ${revert} == 1 ]]
|
|
then
|
|
git checkout -- "${file}"
|
|
fi
|
|
done
|
|
|
|
set -x
|