diff options
| -rwxr-xr-x | tools/git-post-receive-hook | 23 | ||||
| -rwxr-xr-x | tools/git-update-mirror | 94 |
2 files changed, 23 insertions, 94 deletions
diff --git a/tools/git-post-receive-hook b/tools/git-post-receive-hook new file mode 100755 index 00000000..70d259e7 --- /dev/null +++ b/tools/git-post-receive-hook | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | prefix="${0%/*}/notifications" # $GIT_DIR/hooks/notifications | ||
| 4 | recipient='Nagios Plugin Commits <nagiosplug-checkins@lists.sourceforge.net>' | ||
| 5 | maxcommits=100 | ||
| 6 | maxdiffsize=$((300 * 1024)) | ||
| 7 | gitweburl='http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug' | ||
| 8 | gitnotify="$prefix/git-notify.pl" | ||
| 9 | statefile="$prefix/git-notify.dat" | ||
| 10 | |||
| 11 | exec "$gitnotify" \ | ||
| 12 | -m "$recipient" \ | ||
| 13 | -n "$maxcommits" \ | ||
| 14 | -s "$maxdiffsize" \ | ||
| 15 | -t "$statefile" \ | ||
| 16 | -u "$gitweburl" \ | ||
| 17 | -A \ | ||
| 18 | -C \ | ||
| 19 | -H \ | ||
| 20 | -S \ | ||
| 21 | -T \ | ||
| 22 | -X \ | ||
| 23 | -z | ||
diff --git a/tools/git-update-mirror b/tools/git-update-mirror deleted file mode 100755 index e258a123..00000000 --- a/tools/git-update-mirror +++ /dev/null | |||
| @@ -1,94 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # | ||
| 3 | # Copyright (c) 2009 Nagios Plugins Development Team | ||
| 4 | # | ||
| 5 | # This program is free software: you can redistribute it and/or modify | ||
| 6 | # it under the terms of the GNU General Public License as published by | ||
| 7 | # the Free Software Foundation, either version 3 of the License, or | ||
| 8 | # (at your option) any later version. | ||
| 9 | # | ||
| 10 | # This program is distributed in the hope that it will be useful, | ||
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | # GNU General Public License for more details. | ||
| 14 | # | ||
| 15 | # You should have received a copy of the GNU General Public License | ||
| 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 17 | |||
| 18 | set -e | ||
| 19 | set -u | ||
| 20 | |||
| 21 | prefix='/home/git' | ||
| 22 | |||
| 23 | PATH="$prefix/opt/git/bin:/bin:/usr/bin" | ||
| 24 | export PATH | ||
| 25 | |||
| 26 | gitnotify="$prefix/libexec/git-notify" | ||
| 27 | recipient='Nagios Plugins Commit List <nagiosplug-checkins@lists.sourceforge.net>' | ||
| 28 | maxcommits=100 | ||
| 29 | maxdiffsize=$((300 * 1024)) | ||
| 30 | gitweburl='http://repo.or.cz/w' | ||
| 31 | tempprefix='/dev/shm' | ||
| 32 | fourtyzeros=$(printf '%.40u' 0) | ||
| 33 | myself=${0##*/} | ||
| 34 | |||
| 35 | checkrefs() | ||
| 36 | { | ||
| 37 | turn=$1 | ||
| 38 | |||
| 39 | git show-ref | while read object ref | ||
| 40 | do | ||
| 41 | refdir="$tempdir/${ref%/*}" | ||
| 42 | reffile="$tempdir/$ref" | ||
| 43 | |||
| 44 | if [ $turn -eq 2 -a -f "$reffile" ] \ | ||
| 45 | && grep "^1 $object$" "$reffile" >'/dev/null' | ||
| 46 | then # The ref has not been modified. | ||
| 47 | rm -f "$reffile" | ||
| 48 | else | ||
| 49 | mkdir -p "$refdir" | ||
| 50 | echo "$turn $object" >>"$reffile" | ||
| 51 | fi | ||
| 52 | done | ||
| 53 | } | ||
| 54 | |||
| 55 | if [ $# -lt 1 ] | ||
| 56 | then | ||
| 57 | echo >&2 "Usage: $myself <repository> ..." | ||
| 58 | exit 1 | ||
| 59 | fi | ||
| 60 | |||
| 61 | tempdir=$(mktemp -d "$tempprefix/$myself.XXXXXX") | ||
| 62 | tempfile=$(mktemp "$tempprefix/$myself.XXXXXX") | ||
| 63 | trap 'rm -rf "$tempdir" "$tempfile"' EXIT | ||
| 64 | |||
| 65 | for repository in "$@" | ||
| 66 | do | ||
| 67 | cd "$repository" | ||
| 68 | |||
| 69 | checkrefs 1 | ||
| 70 | if ! git remote update --prune >"$tempfile" 2>&1 | ||
| 71 | then | ||
| 72 | cat >&2 "$tempfile" | ||
| 73 | exit 1 | ||
| 74 | fi | ||
| 75 | git fetch --quiet --tags | ||
| 76 | checkrefs 2 | ||
| 77 | |||
| 78 | find "$tempdir" -type 'f' -print | while read reffile | ||
| 79 | do | ||
| 80 | ref=${reffile#$tempdir/} | ||
| 81 | old=$(awk '$1 == "1" { print $2; exit }' "$reffile") | ||
| 82 | new=$(awk '$1 == "2" { print $2; exit }' "$reffile") | ||
| 83 | old=${old:-$fourtyzeros} | ||
| 84 | new=${new:-$fourtyzeros} | ||
| 85 | |||
| 86 | echo "$old" "$new" "$ref" | ||
| 87 | done | $gitnotify \ | ||
| 88 | -m "$recipient" \ | ||
| 89 | -n "$maxcommits" \ | ||
| 90 | -s "$maxdiffsize" \ | ||
| 91 | -u "$gitweburl" | ||
| 92 | |||
| 93 | cd "$OLDPWD" | ||
| 94 | done | ||
