Add $blamejs for the incremental blame view
[girocco/ztw.git] / clone.sh
blob738faad3e299928bd0f85b574610a2218c76e9bf
1 #!/bin/bash
3 export PATH=/home/pasky/bin:$PATH
5 set -e
7 proj="$1"
9 clone_project() {
10 log="$(mktemp -t repomgr-XXXXXX)"
11 url="$(cat base_url)"
12 mail="$(cat owner)"
14 bang() {
15 if ! "$@" >>"$log" 2>&1; then
17 echo "$* failed with error code $?"
18 echo "Log follows:"
19 cat "$log"
20 } | mail -s "[repo.or.cz] $proj clone failed" "$mail",pasky@ucw.cz
22 # This removes any remnants from /srv/git/$proj.git _and_ gets rid
23 # of the group record.
24 perl -I/home/repo/repomgr/cgi -MGit::RepoCGI -e 'Git::RepoCGI::Project->ghost('"'$proj'"')->delete;'
25 cd "$basedir" && rm -r "$proj"/* && rmdir -p "$proj"
26 rm "$log"
27 exit 1
31 ref=()
32 if [ -s objects/info/alternates ]; then
33 ref=(--reference "$(cat objects/info/alternates | sed 's/\.\.\/\.\.\/\.\./\/srv\/git/;s/objects$//')")
35 bang git clone "${ref[@]}" --bare "$url" repodir
36 ! [ -d /srv/git/"$proj".git ]
37 lproj="$(echo "$proj" | sed 's/^\(.*\/\)\(.*\)/\1/')"
38 if [ z"$lproj" != z"$proj" ]; then
39 bang mkdir -m 0775 -p /srv/git/"$lproj"
41 bang mv repodir /srv/git/"$proj".git
42 bang chmod g+w base_url owner description homepage README.html
43 bang mv base_url owner description homepage README.html /srv/git/"$proj".git/
44 #bang mv objects/info/alternates /srv/git/"$proj".git/objects/info/alternates # git clone should've set up that for us
45 GIT_DIR=/srv/git/"$proj".git bang git config --bool --add mirror.allowed true
46 GIT_DIR=/srv/git/"$proj".git bang git update-server-info
47 cd "$basedir" && rm -r "$proj"/* && rmdir -p "$proj"
48 # NO bang AT THIS POINT! rm -r depends on cwd.
49 echo "Congratulations! You can adjust the project settings in the future at http://repo.or.cz/m/p/editproj.cgi." | mail -s "[repo.or.cz] $proj clone completed" "$mail",pasky@ucw.cz
50 rm "$log"
53 basedir=$(pwd)
55 if [ -f "$proj"/base_url ]; then
56 cd "$proj"
57 clone_project
58 else
59 # a collection of subprojects
60 find "$proj" -name base_url |
61 sed -e 's/\/base_url$//' |
62 while read proj; do
63 (cd "$proj" && clone_project) || :
64 done