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 "$svnurl"
29 # ask git-svn to store everything in the normal non-remote locations
30 GIT_DIR
=. git config svn-remote.svn.fetch
'trunk:refs/heads/master'
31 GIT_DIR
=. git config svn-remote.svn.branches
'branches/*:refs/heads/*'
32 GIT_DIR
=. git config svn-remote.svn.tags
'tags/*:refs/tags/*'
33 # look for additional non-standard directories to fetch
34 # check for standard layout at the same time
37 { svn
ls "$svnurl" 2>/dev
/null ||
:; } | \
38 { while read file; do case $file in
39 # skip the already-handled standard ones and any with a space or tab
41 trunk
/|branches
/|tags
/) foundstd
=1;;
42 # only fetch extra directories from the $svnurl root (not any files)
43 *?
/) GIT_DIR
=. git config
--add svn-remote.svn.fetch
"${file%/}:refs/heads/${file%/}";;
46 # if files found and no standard directories present use a simpler layout
47 if [ -z "$foundstd" ] && [ -n "$foundfile" ]; then
48 GIT_DIR
=. git config
--unset svn-remote.svn.branches
49 GIT_DIR
=. git config
--unset svn-remote.svn.tags
50 GIT_DIR
=. git config
--replace-all svn-remote.svn.fetch
':refs/heads/master'
52 GIT_DIR
=. git svn fetch
--quiet
53 # git svn does not preserve group permissions in the svn subdirectory
54 chmod -R ug
+rw
,o
+r svn
57 httpurl
="${url/darcs:\/\//http://}"
58 "$cfg_basedir"/bin
/darcs-fast-export
--export-marks=$
(pwd)/dfe-marks
"$httpurl" | \
59 git fast-import
--export-marks=$
(pwd)/gfi-marks
60 # This is here because by default only the exit code of
61 # git fast-import is checked
62 [ ${PIPESTATUS[0]} = 0 -a ${PIPESTATUS[1]} = 0 ]
65 # we just remove bzr:// here, a typical bzr url is just
67 bzrurl
="${url#bzr://}"
68 bzr fast-export
--export-marks=$
(pwd)/bfe-marks
"$bzrurl" | \
69 git fast-import
--export-marks=$
(pwd)/gfi-marks
70 [ ${PIPESTATUS[0]} = 0 -a ${PIPESTATUS[1]} = 0 ]
73 git remote
rm origin
>/dev
/null
2>&1 ||
:
74 git remote add
--mirror origin
"$url"
75 GIT_SSL_NO_VERIFY
=1 git remote update
76 git remote prune origin
81 echo "Final touches..."
82 git update-server-info
84 mail -s "[$cfg_name] $proj clone completed" "$mail,$cfg_admin" <<EOT
85 Congratulations! The clone of project $proj just completed.
88 * GitWeb interface: $cfg_gitweburl/$projdir
89 * Project settings: $cfg_webadmurl/editproj.cgi?name=$proj
94 echo "Mirroring finished successfuly!"