3 # Invoked from taskd/taskd.pl
10 [ "$cfg_permission_control" != "Hooks" ] ||
umask 000
13 proj
="${projdir%.git}"
15 cd "$cfg_reporoot/$projdir"
16 trap "echo '@OVER@'; touch .clone_failed" EXIT
17 url
="$(config_get baseurl)"
19 if [ "$cfg_project_owners" = "source" ]; then
20 config_set owner
"$(stat -c %U "$url" 2>/dev/null)"
23 mail="$(config_get owner)"
26 echo "Initiating mirroring..."
28 svn
://* | svn
+http
://* | svn
+https
://*)
29 # we just remove svn+ here, so svn+http://... becomes http://...
31 GIT_DIR
=. git svn init
-s "$svnurl"
32 # ask git-svn to store everything in the normal non-remote locations
33 GIT_DIR
=. git config svn-remote.svn.fetch
'trunk:refs/heads/master'
34 GIT_DIR
=. git config svn-remote.svn.branches
'branches/*:refs/heads/*'
35 GIT_DIR
=. git config svn-remote.svn.tags
'tags/*:refs/tags/*'
36 # look for additional non-standard directories to fetch
37 # check for standard layout at the same time
40 { svn
ls "$svnurl" 2>/dev
/null ||
:; } | \
41 { while read file; do case $file in
42 # skip the already-handled standard ones and any with a space or tab
44 trunk
/|branches
/|tags
/) foundstd
=1;;
45 # only fetch extra directories from the $svnurl root (not any files)
46 *?
/) GIT_DIR
=. git config
--add svn-remote.svn.fetch
"${file%/}:refs/heads/${file%/}";;
49 # if files found and no standard directories present use a simpler layout
50 if [ -z "$foundstd" ] && [ -n "$foundfile" ]; then
51 GIT_DIR
=. git config
--unset svn-remote.svn.branches
52 GIT_DIR
=. git config
--unset svn-remote.svn.tags
53 GIT_DIR
=. git config
--replace-all svn-remote.svn.fetch
':refs/heads/master'
55 GIT_DIR
=. git svn fetch
--quiet
56 # git svn does not preserve group permissions in the svn subdirectory
57 chmod -R ug
+rw
,o
+r svn
60 httpurl
="${url/darcs:\/\//http://}"
61 "$cfg_basedir"/bin
/darcs-fast-export
--export-marks=$
(pwd)/dfe-marks
"$httpurl" | \
62 git fast-import
--export-marks=$
(pwd)/gfi-marks
63 # This is here because by default only the exit code of
64 # git fast-import is checked
65 [ ${PIPESTATUS[0]} = 0 -a ${PIPESTATUS[1]} = 0 ]
68 # we just remove bzr:// here, a typical bzr url is just
70 bzrurl
="${url#bzr://}"
71 bzr fast-export
--export-marks=$
(pwd)/bfe-marks
"$bzrurl" | \
72 git fast-import
--export-marks=$
(pwd)/gfi-marks
73 [ ${PIPESTATUS[0]} = 0 -a ${PIPESTATUS[1]} = 0 ]
76 git remote
rm origin
>/dev
/null
2>&1 ||
:
77 git remote add
--mirror origin
"$url"
78 GIT_SSL_NO_VERIFY
=1 git remote update
79 git remote prune origin
83 # The objects subdirectories permissions must be updated now.
84 # In the case of a dump http clone, the permissions will not be correct
85 # (missing group write) despite the core.sharedrepository=1 setting!
86 # The objects themselves seem to have the correct permissions.
87 # This problem appears to have been fixed in the most recent git versions.
89 [ "$cfg_permission_control" != "Hooks" ] || perms
=go
+w
90 chmod $perms $
(find objects
-maxdepth 1 -type d
) 2>/dev
/null ||
:
93 echo "Final touches..."
94 git update-server-info
96 mail -s "[$cfg_name] $proj clone completed" "$mail,$cfg_admin" <<EOT
97 Congratulations! The clone of project $proj just completed.
100 * GitWeb interface: $cfg_gitweburl/$projdir
101 * Project settings: $cfg_webadmurl/editproj.cgi?name=$proj
106 echo "Mirroring finished successfuly!"
107 rm .clone_in_progress