taskd/clone.sh: Syntax error fix
[girocco/susan.git] / taskd / clone.sh
blob962c5267e7cf70295e7163739dbb753eaa222add
1 #!/bin/bash
3 # Invoked from taskd/taskd.pl
5 . @basedir@/shlib.sh
7 set -e
9 projdir="$1"
10 proj="${projdir%.git}"
12 cd "$cfg_reporoot/$projdir"
13 trap "echo '@OVER@'; touch .clone_failed" EXIT
14 url="$(config_get baseurl)"
16 if [ "$cfg_project_owners" = "source" ]; then
17 config_set owner "$(stat -c %U "$url" 2>/dev/null)"
20 mail="$(config_get owner)"
22 # Initial mirror
23 echo "Initiating mirroring..."
24 case "$url" in
25 svn://*)
26 GIT_DIR=. git svn init -s "$url"
27 GIT_DIR=. git svn fetch
28 # Neat Trick suggested by Miklos Vajna
29 GIT_DIR=. git config remote.origin.url .
30 GIT_DIR=. git config remote.origin.fetch +refs/remotes/heads/*:refs/heads/*
31 GIT_DIR=. git config remote.origin.fetch +refs/remotes/trunk:refs/heads/master
32 GIT_DIR=. git config remote.origin.fetch +refs/remotes/tags/*:refs/tags/*
33 GIT_DIR=. git fetch
35 darcs://*)
36 httpurl="${url/darcs:\/\//http://}"
37 "$cfg_basedir"/bin/darcs-fast-export --export-marks=$(pwd)/dfe-marks "$httpurl" | \
38 git fast-import --export-marks=$(pwd)/gfi-marks
39 # This is here because by default only the exit code of
40 # git fast-import is checked
41 [ ${PIPESTATUS[0]} = 0 -a ${PIPESTATUS[1]} = 0 ]
43 bzr://*)
44 # we just remove bzr:// here, a typical bzr url is just
45 # "lp:foo"
46 bzrurl="${url#bzr://}"
47 bzr fast-export --export-marks=$(pwd)/bfe-marks "$bzrurl" | \
48 git fast-import --export-marks=$(pwd)/gfi-marks
49 [ ${PIPESTATUS[0]} = 0 -a ${PIPESTATUS[1]} = 0 ]
52 git remote rm origin >/dev/null 2>&1 || :
53 git remote add --mirror origin "$url"
54 git remote update
55 git remote prune origin
57 esac
59 # The rest
60 echo "Final touches..."
61 git update-server-info
62 trap "" EXIT
63 mail -s "[$cfg_name] $proj clone completed" "$mail,$cfg_admin" <<EOT
64 Congratulations! The clone of project $proj just completed.
66 * Source URL: $url
67 * GitWeb interface: $cfg_gitweburl/$projdir
68 * Project settings: $cfg_webadmurl/editproj.cgi?name=$proj
70 Have a lot of fun.
71 EOT
73 echo "Mirroring finished successfuly!"
74 rm .clone_in_progress
75 echo "@OVER@"