summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-09-02 06:38:49 (GMT)
committerTobias Markmann <tm@ayena.de>2015-09-02 06:38:49 (GMT)
commit397d008fc066694130fed8137891a6bb755ddeb2 (patch)
tree97276ccdc381ac376c9a66b3bac74416a033e7e8
parentcc91cf95c7b9a154e857005a02c40ad67346af03 (diff)
downloadswift-397d008fc066694130fed8137891a6bb755ddeb2.zip
swift-397d008fc066694130fed8137891a6bb755ddeb2.tar.bz2
Restrict pre-commit copyright check to added files
Previously the pre-commit would require a correct copyright header on all files, including modified files that only have a couple lines changed. Now, a correct copyright file header is only required on new files added to the repository. Test-Information: Changed git author information to a new user and tried committing a changed file, and afterwards a new file. Only the commit of a new file failed due to missing copyright header. It was accepted after setting BSD header. Change-Id: I8e1324846fd904a72728e7c01da4c98f49a77282
-rwxr-xr-xBuildTools/Git/Hooks/pre-commit13
1 files changed, 9 insertions, 4 deletions
diff --git a/BuildTools/Git/Hooks/pre-commit b/BuildTools/Git/Hooks/pre-commit
index ad0945e..987f127 100755
--- a/BuildTools/Git/Hooks/pre-commit
+++ b/BuildTools/Git/Hooks/pre-commit
@@ -2,22 +2,27 @@
2 2
3IFS=' 3IFS='
4' 4'
5 5
6echo "Checking tabs & copyrights ..." 6echo "Checking tabs & copyrights ..."
7for file in $(git diff --cached --diff-filter=A --name-only); do
8 if [ ! -f $file ]; then
9 continue
10 fi
11 if ! BuildTools/Copyrighter.py check-copyright $file; then
12 echo "ERROR: '$file' has a copyright error. Aborting commit."
13 exit -1
14 fi
15done
7for file in $(git diff --cached --name-only); do 16for file in $(git diff --cached --name-only); do
8 if [ ! -f $file ]; then 17 if [ ! -f $file ]; then
9 continue 18 continue
10 fi 19 fi
11 if ! BuildTools/CheckTabs.py $file; then 20 if ! BuildTools/CheckTabs.py $file; then
12 echo "ERROR: '$file' contains expanded tabs. Aborting commit." 21 echo "ERROR: '$file' contains expanded tabs. Aborting commit."
13 exit -1 22 exit -1
14 fi 23 fi
15 if ! BuildTools/Copyrighter.py check-copyright $file; then
16 echo "ERROR: '$file' has a copyright error. Aborting commit."
17 exit -1
18 fi
19 if ! BuildTools/CheckHeaders.py $file; then 24 if ! BuildTools/CheckHeaders.py $file; then
20 echo "ERROR: '$file' failed header sanity test. Aborting commit." 25 echo "ERROR: '$file' failed header sanity test. Aborting commit."
21 exit -1 26 exit -1
22 fi 27 fi
23done 28done