summaryrefslogtreecommitdiffstats
path: root/tools/git-update-mirror
diff options
context:
space:
mode:
Diffstat (limited to 'tools/git-update-mirror')
-rwxr-xr-xtools/git-update-mirror94
1 files changed, 0 insertions, 94 deletions
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
18set -e
19set -u
20
21prefix='/home/git'
22
23PATH="$prefix/opt/git/bin:/bin:/usr/bin"
24export PATH
25
26gitnotify="$prefix/libexec/git-notify"
27recipient='Nagios Plugins Commit List <nagiosplug-checkins@lists.sourceforge.net>'
28maxcommits=100
29maxdiffsize=$((300 * 1024))
30gitweburl='http://repo.or.cz/w'
31tempprefix='/dev/shm'
32fourtyzeros=$(printf '%.40u' 0)
33myself=${0##*/}
34
35checkrefs()
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
55if [ $# -lt 1 ]
56then
57 echo >&2 "Usage: $myself <repository> ..."
58 exit 1
59fi
60
61tempdir=$(mktemp -d "$tempprefix/$myself.XXXXXX")
62tempfile=$(mktemp "$tempprefix/$myself.XXXXXX")
63trap 'rm -rf "$tempdir" "$tempfile"' EXIT
64
65for repository in "$@"
66do
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"
94done