8 # date -R is linux-only, POSIX equivalent is '+%a, %d %b %Y %T %z'
9 datefmt
='+%a, %d %b %Y %T %z'
11 # darcs fast-export | git fast-import with error handling
13 "$cfg_basedir"/bin
/darcs-fast-export
--export-marks=$
(pwd)/dfe-marks
--import-marks=$
(pwd)/dfe-marks
"$1" | \
14 git fast-import
--export-marks=$
(pwd)/gfi-marks
--import-marks=$
(pwd)/gfi-marks
15 [ ${PIPESTATUS[0]} = 0 -a ${PIPESTATUS[1]} = 0 ]
19 # bzr fast-export | git fast-import with error handling
21 bzr fast-export
--export-marks=$
(pwd)/dfe-marks
--import-marks=$
(pwd)/dfe-marks
"$1" | \
22 git fast-import
--export-marks=$
(pwd)/gfi-marks
--import-marks=$
(pwd)/gfi-marks
23 [ ${PIPESTATUS[0]} = 0 -a ${PIPESTATUS[1]} = 0 ]
27 trap 'if [ $? != 0 ]; then echo "update failed dir: $PWD" >&2; fi; rm -f "$bang_log"' EXIT
30 [ "$cfg_permission_control" != "Hooks" ] ||
umask 000
33 cd "$cfg_reporoot/$proj.git"
35 if check_interval lastrefresh
$cfg_min_mirror_interval; then
36 progress
"= [$proj] update skip (last at $(config_get lastrefresh))"
39 progress
"+ [$proj] update (`date`)"
45 url
="$(config_get baseurl)"
46 mail="$(config_get owner || :)"
47 statusok
="$(git config --bool gitweb.statusupdates 2>/dev/null || echo true)"
49 [ "$statusok" = "false" -o -z "$mail" ] || mailaddrs
="$mail"
50 [ -z "$cfg_admincc" -o "$cfg_admincc" = "0" -o -z "$cfg_admin" ] ||
51 if [ -z "$mailaddrs" ]; then mailaddrs
="$cfg_admin"; else mailaddrs
="$mailaddrs,$cfg_admin"; fi
53 show_progress
=1 bang git for-each-ref
--format '%(refname) %(objectname)' |
sort -k1b,1 >.refs-before
56 svn
://* | svn
+http
://* | svn
+https
://*)
57 # Update the git svn url to match baseurl but be cognizant of any
58 # needed prefix changes. See the comments in taskd/clone.sh about
59 # why we need to put up with a prefix in the first place.
62 svnurlold
="$(config_get svnurl || :)"
63 if [ "$svnurl" != "$svnurlold" ]; then
64 # We better already have an svn-remote.svn.fetch setting
65 bang
test -n "$(git config --get-all svn-remote.svn.fetch || :)"
66 # the only way to truly know what the proper prefix is
67 # is to attempt a fresh git-svn init -s on the new url
68 rm -rf svn-new-url ||
:
69 # We require svn info to succeed on the URL otherwise it's
70 # simply not a valid URL and without using -s on the init it
71 # will not otherwise be tested until the fetch
72 bang
eval 'svn --non-interactive info "$svnurl" > /dev/null'
73 bang mkdir svn-new-url
74 GIT_DIR
=svn-new-url bang git init
--bare --quiet
75 # We initially use -s for the init which will possibly shorten
76 # the URL. However, the shortening can fail if a password is
77 # not required for the longer version but is for the shorter,
78 # so try again without -s if the -s version fails.
79 cmdstr
='git svn init -s "$svnurl" < /dev/null > /dev/null 2>&1 || '
80 cmdstr
="$cmdstr"'git svn init "$svnurl" < /dev/null > /dev/null 2>&1'
81 GIT_DIR
=svn-new-url bang
eval "$cmdstr"
82 gitsvnurl
="$(GIT_DIR=svn-new-url git config --get svn-remote.svn.url || :)"
83 gitsvnfetch
="$(GIT_DIR=svn-new-url git config --get svn-remote.svn.fetch || :)"
84 gitsvnprefixnew
="${gitsvnfetch%%:*}"
85 gitsvnprefixnew
="${gitsvnfetch%/*}"
86 [ -z "$gitsvnprefixnew" ] || gitsvnprefixnew
="$gitsvnprefixnew/"
87 rm -rf svn-new-url ||
:
88 # Using GIT_DIR= with bang leaves it set to svn-new-url, so reset it to .
90 if [ "$gitsvnurl" != "$(git config --get svn-remote.svn.url || :)" ]; then
91 # The url has been changed.
92 # We must update the url and replace the prefix on all config items
93 gitsvnfetch
="$(git config --get-all svn-remote.svn.fetch | head -1 || :)"
94 gitsvnprefixold
="${gitsvnfetch%%:*}"
95 gitsvnprefixold
="${gitsvnprefixold%/*}"
96 [ -z "$gitsvnprefixold" ] || gitsvnprefixold
="$gitsvnprefixold/"
97 git config
--remove-section 'svn-remote.svnnew' 2>/dev
/null ||
:
98 git config
'svn-remote.svnnew.url' "$gitsvnurl"
99 { git config
--get-regexp '^svn-remote\.svn\.' ||
:; } | \
100 { while read sname sval
; do
102 svn-remote.svn.fetch|svn-remote.svn.branches|svn-remote.svn.tags
)
103 sname
="${sname#svn-remote.svn.}"
104 sval
="${sval#$gitsvnprefixold}"
105 bang git config
--add "svn-remote.svnnew.$sname" "${gitsvnprefixnew}$sval"
108 bang git config
-f svn
/.metadata svn-remote.svn.reposRoot
"$gitsvnurl"
109 bang git config
--remove-section svn-remote.svn
110 bang git config
--rename-section svn-remote.svnnew svn-remote.svn
112 bang config_set svnurl
"$svnurl"
114 # remove any stale *.lock files greater than 1 hour old in case
115 # git-svn was killed on the last update because it took too long
116 find svn
-type f
-name '*.lock' -mmin +60 -print0 |
xargs -0 rm -f
117 GIT_DIR
=. bang git svn fetch
--quiet < /dev
/null
118 # git svn does not preserve group permissions in the svn subdirectory
119 chmod -R ug
+rw
,o
+r svn
120 # git svn also leaves behind ref turds that end with @nnn
121 # We get rid of them now
123 { while read sha1 ref
; do
125 ?
*@
[1-9]|?
*@
[1-9][0-9]|?
*@
[1-9][0-9][0-9]|?
*@
[1-9][0-9][0-9][0-9]|\
126 ?
*@
[1-9][0-9][0-9][0-9][0-9]|?
*@
[1-9][0-9][0-9][0-9][0-9][0-9]|\
127 ?
*@
[1-9][0-9][0-9][0-9][0-9][0-9][0-9]|\
128 ?
*@
[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9])
129 git update-ref
-d "$ref"
134 httpurl
="${url/darcs:\/\//http://}"
135 bang git_darcs_fetch
"$httpurl"
138 bzrurl
="${url#bzr://}"
139 bang git_bzr_fetch
"$bzrurl"
142 [ "$url" = "$(git config --get remote.origin.url || :)" ] || bang config_set_raw remote.origin.url
"$url"
143 GIT_SSL_NO_VERIFY
=1 bang git remote update
144 GIT_SSL_NO_VERIFY
=1 bang git remote prune origin
148 # The objects subdirectories permissions must be updated now.
149 # In the case of a dumb http clone, the permissions will not be correct
150 # (missing group write) despite the core.sharedrepository=1 setting!
151 # The objects themselves seem to have the correct permissions.
152 # This problem appears to have been fixed in the most recent git versions.
154 [ "$cfg_permission_control" != "Hooks" ] || perms
=go
+w
155 chmod $perms $
(find objects
-maxdepth 1 -type d
) 2>/dev
/null ||
:
157 bang git update-server-info
158 bang config_set lastrefresh
"$(date "$datefmt")"
160 # Look at which refs changed and trigger ref-change for these
161 show_progress
=1 bang git for-each-ref
--format '%(refname) %(objectname)' |
sort -k1b,1 >.refs-after
162 sockpath
="$cfg_chroot/etc/taskd.socket"
163 if [ -S "$sockpath" ] && ! cmp -s .refs-before .refs-after
; then
164 join -j 1 .refs-before .refs-after |
165 while read ref old new
; do
166 [ "$old" != "$new" ] ||
continue
167 echo "ref-change %$proj% $proj $old $new $ref" | nc.openbsd
-w 1 -U "$sockpath"
169 join -j 1 -v 1 .refs-before .refs-after |
170 while read ref old
; do
171 echo "ref-change %$proj% $proj $old 0000000000000000000000000000000000000000 $ref" | nc.openbsd
-w 1 -U "$sockpath"
173 join -j 1 -v 2 .refs-before .refs-after |
174 while read ref new
; do
175 echo "ref-change %$proj% $proj 0000000000000000000000000000000000000000 $new $ref" | nc.openbsd
-w 1 -U "$sockpath"
177 git config gitweb.lastchange
"$(date '+%a, %d %b %Y %T %z')"
178 git for-each-ref
--sort=-committerdate --format='%(committerdate:iso8601)' \
179 --count=1 refs
/heads
> info
/lastactivity
182 rm -f .refs-before .refs-after
184 if [ -e .banged
]; then
185 [ -z "$mailaddrs" ] ||
187 echo "$proj update succeeded - failure recovery"
188 echo "this status message may be disabled on the project admin page"
189 } |
mail -s "[$cfg_name] $proj update succeeded" "$mailaddrs" ||
:
193 progress
"- [$proj] update (`date`)"