bd0187bc5261803b745eea13e642a18feb19460e
[m6w6/btr] / bin / btr-hook
1 #!/bin/bash
2
3 export BTR_BINDIR=$(realpath $(dirname $0)/)
4 export BTR_LIBDIR=$(realpath $(dirname $0)/../share/btr)
5 BTR_BANNER="Install btr hook into your VCS reporitory."
6
7 . $BTR_LIBDIR/common.sh
8 . $BTR_LIBDIR/btr.sh
9
10 btr-parseopts "$@"
11 btr-setup false
12
13 if $BTR_VERBOSE
14 then
15 btr-conf-show
16 fi
17
18 btr-confirm "Everything setup. Do you want to install the '$BTR_EXTRA_ARGS' hook for '$BTR_SOURCE_RULES'?"
19
20 case "$BTR_SOURCE_RULES" in
21 git)
22 case "$BTR_EXTRA_ARGS" in
23 post-commit|post-applypatch|post-merge|post-checkout)
24 BTR_HOOK_FILE="${BTR_SOURCE_ARGS:-.}/.git/hooks/$BTR_EXTRA_ARGS"
25 (
26 if test -f "$BTR_HOOK_FILE"
27 then
28 grep -Esv '^BTR_' "$BTR_HOOK_FILE"
29 else
30 echo "#!/bin/bash"
31 fi
32 echo $(btr-conf-dump) "'$BTR_BINDIR/btr' -qy &"
33 ) >"$BTR_HOOK_FILE.tmp" && \
34 chmod +x "$BTR_HOOK_FILE.tmp" && \
35 mv "$BTR_HOOK_FILE.tmp" "$BTR_HOOK_FILE" && \
36 $SAY "Installed into $BTR_HOOK_FILE"
37 ;;
38 esac
39 ;;
40 *)
41 error "Sorry, I don't know how to install the '$BTR_EXTRA_ARGS' for '$BTR_SOURCE_RULES'."
42 esac
43
44 # vim: noet