]> git.mar77i.info Git - admin/blob - post-receive.sh
add rcfiles, bigintmandel
[admin] / post-receive.sh
1 #!/usr/bin/env bash
2
3 read -r -d '' hook <<'EOF'
4 #!/usr/bin/env bash
5 while read _ _ refname; do
6 if [[ "${refname}" == refs/heads/master ]]; then
7 . <(git show master:post-receive.sh)
8 break
9 fi
10 done
11 EOF
12
13 print_and_run() {
14 printf ">>>"
15 for (( i = 1; i < $# + 1; i++ )); do
16 printf ' %q' "${!i}"
17 done
18 printf "\n"
19 "$@"
20 }
21
22 update_post_receive_hook() {
23 local stat_cmd="\$(stat -c %a hooks/post-receive)"
24 print_and_run bash -c "cat >hooks/post-receive <<'EOF'"$'\n'"${hook}"$'\nEOF\n'
25 print_and_run bash -c "[[ ${stat_cmd} == 755 ]] || chmod 755 hooks/post-receive"
26 }
27
28 if [[ "${1}" == --install ]]; then
29 if (( $# > 1 )); then
30 echo "Error: No further arguments expected." >&2
31 exit 1
32 fi
33 update_post_receive_hook
34 exit
35 fi
36
37 hook_hash="$(printf '%s' "${hook}"|sha256sum| cut -d\ -f1)"
38 [[ -f "${dest}" ]] && current_hash="$(sha256sum hooks/post-receive| cut -d\ -f1)"
39 [[ "${hook_hash}" != "${current_hash}" ]] && update_post_receive_hook
40
41 update_gitweb_theme() {
42 local theme_css_dest="${HOME}/gitweb/gitweb-theme.css"
43 print_and_run bash -c "git show master:gitweb-theme.css > \"${theme_css_dest}\""
44 }
45
46 update_gitweb_configs() {
47 print_and_run bash -c 'python <(git show master:gitweb_configs.py)'
48 }
49
50 tasks=(update_gitweb_theme update_gitweb_configs)
51
52 for task in "${tasks[@]}"; do
53 "${task}"
54 done