Debian Codegraph @

t/t-install-custom-hooks-path.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 . "$(dirnamescip-shell system . . dirname. "$0")/testlib.sh"
4
5 # These tests rely on behavior found in 2.9.0 to perform themselves,
6 # specifically:
7 # - core.hooksPath support
8 ensure_git_version_isnt $VERSION_LOWER "2.9.0"
9
10 assert_hooksscip-shell shell shell-project 0.0.0 assert_hooks().() {
11 local hooks_dir="$1"
12 [scip-shell system . . `[`. -e "$hooks_dir/pre-push" ]
13 [scip-shell system . . `[`. ! -e ".git/pre-push" ]
14 [scip-shell system . . `[`. -e "$hooks_dir/post-checkout" ]
15 [scip-shell system . . `[`. ! -e ".git/post-checkout" ]
16 [scip-shell system . . `[`. -e "$hooks_dir/post-commit" ]
17 [scip-shell system . . `[`. ! -e ".git/post-commit" ]
18 [scip-shell system . . `[`. -e "$hooks_dir/post-merge" ]
19 [scip-shell system . . `[`. ! -e ".git/post-merge" ]
20 }
21
22 refute_hooksscip-shell shell shell-project 0.0.0 refute_hooks().() {
23 local hooks_dir="$1"
24 [scip-shell system . . `[`. ! -e "$hooks_dir/pre-push" ]
25 [scip-shell system . . `[`. ! -e "$hooks_dir/post-checkout" ]
26 [scip-shell system . . `[`. ! -e "$hooks_dir/post-commit" ]
27 [scip-shell system . . `[`. ! -e "$hooks_dir/post-merge" ]
28 }
29
30 begin_test "install with supported core.hooksPath"
31 (
32 set -e
33
34 repo_name="supported-custom-hooks-path"
35 gitscip-shell system . . git. init "$repo_name"
36 cd "$repo_name"
37
38 hooks_dir="custom_hooks_dir"
39 mkdirscip-shell system . . mkdir. -p "$hooks_dir"
40
41 gitscip-shell system . . git. config --local core.hooksPath "$hooks_dir"
42
43 gitscip-shell system . . git. lfs install 2>&1 | teescip-shell system . . tee. install.log
44 grepscip-shell system . . grep. "Updated Git hooks" install.log
45
46 assert_hooksscip-shell shell shell-project 0.0.0 assert_hooks(). "$hooks_dir"
47 )
48 end_test
49
50 begin_test "install with supported core.hooksPath in subdirectory"
51 (
52 set -e
53
54 repo_name="supported-custom-hooks-path-subdir"
55 gitscip-shell system . . git. init "$repo_name"
56 cd "$repo_name"
57
58 hooks_dir="custom_hooks_dir"
59
60 mkdirscip-shell system . . mkdir. subdir
61
62 gitscip-shell system . . git. config --local core.hooksPath "$hooks_dir"
63
64 (cd subdir && gitscip-shell system . . git. lfs install 2>&1 | teescip-shell system . . tee. install.log)
65 grepscip-shell system . . grep. "Updated Git hooks" subdir/install.log
66
67 assert_hooksscip-shell shell shell-project 0.0.0 assert_hooks(). "$hooks_dir"
68 refute_hooksscip-shell shell shell-project 0.0.0 refute_hooks(). "subdir/$hooks_dir"
69 )
70 end_test
71
72 begin_test "install with supported expandable core.hooksPath"
73 (
74 set -e
75
76 repo_name="supported-custom-hooks-expandable-path"
77 gitscip-shell system . . git. init "$repo_name"
78 cd "$repo_name"
79
80 hooks_dir="~/custom_hooks_dir"
81 mkdirscip-shell system . . mkdir. -p "$hooks_dir"
82
83 gitscip-shell system . . git. config --local core.hooksPath "$hooks_dir"
84
85 gitscip-shell system . . git. lfs install 2>&1 | teescip-shell system . . tee. install.log
86 grepscip-shell system . . grep. "Updated Git hooks" install.log
87
88 assert_hooksscip-shell shell shell-project 0.0.0 assert_hooks(). "$HOME/custom_hooks_dir"
89 )
90 end_test