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 cd "$cfg_reporoot/$proj.git"
29 if check_interval lastrefresh
$cfg_min_mirror_interval; then
30 progress
"= [$proj] update skip (last at $(config_get lastrefresh))"
33 progress
"+ [$proj] update (`date`)"
39 url
="$(config_get baseurl)"
40 mail="$(config_get owner)"
41 statusok
="$(git config --bool gitweb.statusupdates 2>/dev/null || echo true)"
43 [ "$statusok" = "false" -o -z "$mail" ] || mailaddrs
="$mail"
44 [ -z "$cfg_admincc" -o "$cfg_admincc" = "0" -o -z "$cfg_admin" ] ||
45 if [ -z "$mailaddrs" ]; then mailaddrs
="$cfg_admin"; else mailaddrs
="$mailaddrs,$cfg_admin"; fi
47 show_progress
=1 bang git for-each-ref
--format '%(refname) %(objectname)' >.refs-before
50 svn
://* | svn
+http
://* | svn
+https
://*)
51 # update the git svn url to match baseurl
54 if [ "$svnurl" != "$(git config --get svn-remote.svn.url || :)" ]; then
55 bang config_set_raw svn-remote.svn.url
"$svnurl"
56 bang git config
-f svn
/.metadata svn-remote.svn.reposRoot
"$svnurl"
58 # remove any stale *.lock files greater than 1 hour old in case
59 # git-svn was killed on the last update because it took too long
60 find svn
-type f
-name '*.lock' -mmin +60 -print0 |
xargs -0 rm -f
61 GIT_DIR
=. bang git svn fetch
--quiet
62 # git svn does not preserve group permissions in the svn subdirectory
63 chmod -R ug
+rw
,o
+r svn
66 httpurl
="${url/darcs:\/\//http://}"
67 bang git_darcs_fetch
"$httpurl"
70 bzrurl
="${url#bzr://}"
71 bang git_bzr_fetch
"$bzrurl"
74 [ "$url" = "$(git config --get remote.origin.url || :)" ] || bang config_set_raw remote.origin.url
"$url"
75 GIT_SSL_NO_VERIFY
=1 bang git remote update
76 bang git remote prune origin
80 bang git update-server-info
81 bang config_set lastrefresh
"$(date "$datefmt")"
83 # Look at which refs changed and trigger ref-change for these
84 show_progress
=1 bang git for-each-ref
--format '%(refname) %(objectname)' >.refs-after
85 sockpath
="$cfg_chroot/etc/taskd.socket"
86 if [ -S "$sockpath" ] && ! cmp -s .refs-before .refs-after
; then
87 join -j 1 .refs-before .refs-after |
88 while read ref old new
; do
89 [ "$old" != "$new" ] ||
continue
90 echo "ref-change %$proj% $proj $old $new $ref" | nc.openbsd
-w 1 -U "$sockpath"
92 join -j 1 -v 1 .refs-before .refs-after |
93 while read ref old
; do
94 echo "ref-change %$proj% $proj $old 0000000000000000000000000000000000000000 $ref" | nc.openbsd
-w 1 -U "$sockpath"
96 join -j 1 -v 2 .refs-before .refs-after |
97 while read ref new
; do
98 echo "ref-change %$proj% $proj 0000000000000000000000000000000000000000 $new $ref" | nc.openbsd
-w 1 -U "$sockpath"
102 rm -f .refs-before .refs-after
104 if [ -e .banged
]; then
105 [ -z "$mailaddrs" ] ||
107 echo "$proj update succeeded - failure recovery"
108 echo "this status message may be disabled on the project admin page"
109 } |
mail -s "[$cfg_name] $proj update succeeded" "$mailaddrs"
113 progress
"- [$proj] update (`date`)"