Skip to content

Commit 1c057d7

Browse files
committed
Merge pull request #7 from cloudevelops/add-submodule-support
Add support for submodule check
2 parents bd092ff + 058dc0c commit 1c057d7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pre-commit

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ if [ ! -z "$hook_symlink" ]; then
1414
subhook_root="$(dirname $hook_symlink)/commit_hooks"
1515
fi
1616

17+
# If using submodules, we need to read proper subhook root
18+
if [ -f "$git_root/.git" ]; then
19+
IFS=": "
20+
while read -r name value
21+
do
22+
if [ $name == "gitdir" ]; then
23+
submodule_hookdir=$value
24+
fi
25+
done < "$git_root/.git"
26+
if [ ! -z "$submodule_hookdir" ]; then
27+
subhook_root="$git_root/$submodule_hookdir/hooks/commit_hooks"
28+
fi
29+
fi
30+
1731
for changedfile in `git diff --cached --name-only --diff-filter=ACM`; do
1832
#check puppet manifest syntax
1933
if type puppet >/dev/null 2>&1; then

0 commit comments

Comments
 (0)