5 # date -R is linux-only, POSIX equivalent is '+%a, %d %b %Y %T %z'
6 datefmt
='+%a, %d %b %Y %T %z'
8 # darcs fast-export | git fast-import with error handling
10 "$cfg_basedir"/bin
/darcs-fast-export
--export-marks=$
(pwd)/dfe-marks
--import-marks=$
(pwd)/dfe-marks
"$1" | \
11 git fast-import
--export-marks=$
(pwd)/gfi-marks
--import-marks=$
(pwd)/gfi-marks
12 [ ${PIPESTATUS[0]} = 0 -a ${PIPESTATUS[1]} = 0 ]
16 # bzr fast-export | git fast-import with error handling
18 bzr fast-export
--export-marks=$
(pwd)/dfe-marks
--import-marks=$
(pwd)/dfe-marks
"$1" | \
19 git fast-import
--export-marks=$
(pwd)/gfi-marks
--import-marks=$
(pwd)/gfi-marks
20 [ ${PIPESTATUS[0]} = 0 -a ${PIPESTATUS[1]} = 0 ]
24 trap 'if [ $? != 0 ]; then echo "update failed dir: $PWD" >&2; fi; rm -f "$bang_log"' EXIT
27 [ "$cfg_permission_control" != "Hooks" ] ||
umask 000
30 cd "$cfg_reporoot/$proj.git"
32 if check_interval lastrefresh
$cfg_min_mirror_interval; then
33 progress
"= [$proj] update skip (last at $(config_get lastrefresh))"
36 progress
"+ [$proj] update (`date`)"
42 url
="$(config_get baseurl)"
43 mail="$(config_get owner)"
44 statusok
="$(git config --bool gitweb.statusupdates 2>/dev/null || echo true)"
46 [ "$statusok" = "false" -o -z "$mail" ] || mailaddrs
="$mail"
47 [ -z "$cfg_admincc" -o "$cfg_admincc" = "0" -o -z "$cfg_admin" ] ||
48 if [ -z "$mailaddrs" ]; then mailaddrs
="$cfg_admin"; else mailaddrs
="$mailaddrs,$cfg_admin"; fi
50 show_progress
=1 bang git for-each-ref
--format '%(refname) %(objectname)' >.refs-before
53 svn
://* | svn
+http
://* | svn
+https
://*)
54 # update the git svn url to match baseurl
57 if [ "$svnurl" != "$(git config --get svn-remote.svn.url || :)" ]; then
58 bang config_set_raw svn-remote.svn.url
"$svnurl"
59 bang git config
-f svn
/.metadata svn-remote.svn.reposRoot
"$svnurl"
61 # remove any stale *.lock files greater than 1 hour old in case
62 # git-svn was killed on the last update because it took too long
63 find svn
-type f
-name '*.lock' -mmin +60 -print0 |
xargs -0 rm -f
64 GIT_DIR
=. bang git svn fetch
--quiet
65 # git svn does not preserve group permissions in the svn subdirectory
66 chmod -R ug
+rw
,o
+r svn
69 httpurl
="${url/darcs:\/\//http://}"
70 bang git_darcs_fetch
"$httpurl"
73 bzrurl
="${url#bzr://}"
74 bang git_bzr_fetch
"$bzrurl"
77 [ "$url" = "$(git config --get remote.origin.url || :)" ] || bang config_set_raw remote.origin.url
"$url"
78 GIT_SSL_NO_VERIFY
=1 bang git remote update
79 bang 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 ||
:
92 bang git update-server-info
93 bang config_set lastrefresh
"$(date "$datefmt")"
95 # Look at which refs changed and trigger ref-change for these
96 show_progress
=1 bang git for-each-ref
--format '%(refname) %(objectname)' >.refs-after
97 sockpath
="$cfg_chroot/etc/taskd.socket"
98 if [ -S "$sockpath" ] && ! cmp -s .refs-before .refs-after
; then
99 join -j 1 .refs-before .refs-after |
100 while read ref old new
; do
101 [ "$old" != "$new" ] ||
continue
102 echo "ref-change %$proj% $proj $old $new $ref" | nc.openbsd
-w 1 -U "$sockpath"
104 join -j 1 -v 1 .refs-before .refs-after |
105 while read ref old
; do
106 echo "ref-change %$proj% $proj $old 0000000000000000000000000000000000000000 $ref" | nc.openbsd
-w 1 -U "$sockpath"
108 join -j 1 -v 2 .refs-before .refs-after |
109 while read ref new
; do
110 echo "ref-change %$proj% $proj 0000000000000000000000000000000000000000 $new $ref" | nc.openbsd
-w 1 -U "$sockpath"
114 rm -f .refs-before .refs-after
116 if [ -e .banged
]; then
117 [ -z "$mailaddrs" ] ||
119 echo "$proj update succeeded - failure recovery"
120 echo "this status message may be disabled on the project admin page"
121 } |
mail -s "[$cfg_name] $proj update succeeded" "$mailaddrs"
125 progress
"- [$proj] update (`date`)"