]> git.armaanb.net Git - bin.git/blob - git-mirror
git-mirror: fix git running in the wrong directory
[bin.git] / git-mirror
1 #!/usr/bin/sh -e
2
3 case ${1} in
4   -h | --help)
5     echo "Usage: git-mirror [path to repos] [path to log file] [html directory]"
6     echo "relative paths are not supported."
7     exit 1
8     ;;
9 esac
10
11 [ -z ${3} ] && echo "not enough arguments" && exit 1
12 [ -z $(which stagit) ] && echo "please install stagit" && exit 1
13
14 cd ${1}
15
16 [ -d ${3} ] || mkdir ${3}
17 stagit-index ./* > ${3}/index.html
18 cp /usr/share/doc/stagit/style.css ${3}
19
20 while :; do
21   find ${1} -maxdepth 2 -name '*.git' | \
22     while read dir; do
23       newdir=${3}/$(basename ${dir} .git)
24       [ -d ${newdir} ] || mkdir ${newdir}
25       cd ${newdir}
26       stagit ${dir}
27       cp /usr/share/doc/stagit/style.css .
28       git -C ${dir} fetch --tags
29       echo $(date -Iseconds) ' | ' ${dir} | tee -a ${2}
30       echo $(tail -n 1500 ${2}) > ${2}
31     done
32   sleep 600
33 done