Skip to content

Commit b0659a6

Browse files
authored
Merge pull request #6 from git-hook/initialize-submodules-before-invoking-target-post-clone-hook
Initialize submodules before invoking target post clone hook
2 parents ca1ad39 + ca72595 commit b0659a6

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

bin/clone

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
readonly template=$(mktemp -d /tmp/post-clone.XXXXX)
99

1010
teardown() {
11-
rm -rf ${template}
11+
rm -rf "${template}"
1212
}
1313
trap teardown EXIT
1414

1515
init() {
16-
cd ${template}
16+
cd "${template}"
1717
git init
1818
git remote add origin https://github.com/git-hook/post-clone.git
1919
git fetch origin
@@ -22,7 +22,7 @@ init() {
2222
}
2323

2424
main() {
25-
git clone --template=${template} "$@"
25+
git clone --template="${template}" "$@"
2626
}
2727

2828
init &>/dev/null

hooks/post-checkout

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,32 @@
55
# This hook can be used to save metadata about where a git repository
66
# is cloned locally. The intent is to use this information in other
77
# scripts that operate on the cloned git repository.
8-
98
# path to the newly cloned repo on disk
9+
1010
readonly repo=$(git rev-parse --show-toplevel)
1111

1212
main() {
13-
rm -rf -- ${repo}/.git/hooks
13+
rm -rf -- "${repo}/.git/hooks"
14+
initializeSubmodules
1415
installClonedReposHooks
1516
invokeClonedReposPostCloneHook
1617
}
1718

19+
initializeSubmodules() {
20+
git submodule update --init --recursive
21+
}
22+
1823
installClonedReposHooks() {
19-
cd ${repo}/.git
24+
cd "${repo}/.git"
2025
rm -rf hooks
2126
ln -sf ../hooks
2227
cd - >/dev/null
2328
}
2429

2530
invokeClonedReposPostCloneHook() {
26-
local -r post_clone_hook=${repo}/.git/hooks/post-clone
27-
test ! -e ${post_clone_hook} && return
28-
chmod u+x ${post_clone_hook}
31+
local -r post_clone_hook="${repo}/.git/hooks/post-clone"
32+
test ! -e "${post_clone_hook}" && return
33+
chmod u+x "${post_clone_hook}"
2934
${post_clone_hook}
3035
}
3136

0 commit comments

Comments
 (0)