Skip to content

Commit ed4e8cd

Browse files
committed
CHAD-17043: Updates and fixes
- Soft linking note fix - Command line arg for running script on a folder - Only checking for copyright in files in SmartThings driver folder
1 parent 660eb54 commit ed4e8cd

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tools/pre-commit

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@
66
# pre-commit
77
#
88
# - Soft link into .git/hooks/pre-commit
9-
# - $ ln -s tools/pre-commit .git/hooks/pre-commit
9+
# - $ ln -s ../../tools/pre-commit .git/hooks/pre-commit
1010
# - Ensure executable
1111

1212
set -e
1313

1414
# Get changed files that are Added or Modified
15-
files=$(git diff --staged --name-only --diff-filter=AM)
15+
if [[ "$1" ]]; then
16+
files=$(find $1 -type f -follow -print)
17+
else
18+
files=$(git diff --staged --name-only --diff-filter=AM)
19+
fi
1620

1721
fail=0
1822
for file in $files; do
@@ -23,7 +27,7 @@ for file in $files; do
2327
[ -f "$file" ] || continue
2428

2529
# Check if file is not empty, is a SmartThings driver and has the copyright header
26-
if [ -s "$file" ] && [[ "$file" =~ "drivers/SmartThings" ]]
30+
if [ -s "$file" ] && [[ "$file" =~ "drivers/SmartThings" ]] \
2731
&& [[ ! $(grep $file -P -e "-{2,} Copyright \d{4}(?:-\d{4})? SmartThings") ]]; then
2832
echo "$file: SmartThings Copyright missing from file"
2933
fail=1

0 commit comments

Comments
 (0)