3 # Invoked from taskd/taskd.pl
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)"
23 echo "Initiating mirroring..."
25 svn
://* | svn
+http
://* | svn
+https
://*)
26 # we just remove svn+ here, so svn+http://... becomes http://...
28 GIT_DIR
=. git svn init
-s --prefix=svn-origin
/ "$svnurl"
29 # ask git-svn to store branches under svn-origin/heads/* instead of svn-origin/*
30 GIT_DIR
=. git config svn-remote.svn.branches \
31 "$(git config --get svn-remote.svn.branches | \
32 sed 's|:refs/remotes/svn-origin/\*$|:refs/remotes/svn-origin/heads/*|')"
33 GIT_DIR
=. git svn fetch
34 # Neat Trick suggested by Miklos Vajna
35 GIT_DIR
=. git config remote.origin.url .
36 GIT_DIR
=. git config remote.origin.fetch
'+refs/remotes/svn-origin/heads/*:refs/heads/*'
37 GIT_DIR
=. git config
--add remote.origin.fetch
'+refs/remotes/svn-origin/trunk:refs/heads/master'
38 GIT_DIR
=. git config
--add remote.origin.fetch
'+refs/remotes/svn-origin/tags/*:refs/tags/*'
42 httpurl
="${url/darcs:\/\//http://}"
43 "$cfg_basedir"/bin
/darcs-fast-export
--export-marks=$
(pwd)/dfe-marks
"$httpurl" | \
44 git fast-import
--export-marks=$
(pwd)/gfi-marks
45 # This is here because by default only the exit code of
46 # git fast-import is checked
47 [ ${PIPESTATUS[0]} = 0 -a ${PIPESTATUS[1]} = 0 ]
50 # we just remove bzr:// here, a typical bzr url is just
52 bzrurl
="${url#bzr://}"
53 bzr fast-export
--export-marks=$
(pwd)/bfe-marks
"$bzrurl" | \
54 git fast-import
--export-marks=$
(pwd)/gfi-marks
55 [ ${PIPESTATUS[0]} = 0 -a ${PIPESTATUS[1]} = 0 ]
58 git remote
rm origin
>/dev
/null
2>&1 ||
:
59 git remote add
--mirror origin
"$url"
60 GIT_SSL_NO_VERIFY
=1 git remote update
61 git remote prune origin
66 echo "Final touches..."
67 git update-server-info
69 mail -s "[$cfg_name] $proj clone completed" "$mail,$cfg_admin" <<EOT
70 Congratulations! The clone of project $proj just completed.
73 * GitWeb interface: $cfg_gitweburl/$projdir
74 * Project settings: $cfg_webadmurl/editproj.cgi?name=$proj
79 echo "Mirroring finished successfuly!"