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
60 if [ "$svnurl" != "$(git config --get svn-remote.svn.url || :)" ]; then
61 bang config_set_raw svn-remote.svn.url
"$svnurl"
62 bang git config
-f svn
/.metadata svn-remote.svn.reposRoot
"$svnurl"
64 # remove any stale *.lock files greater than 1 hour old in case
65 # git-svn was killed on the last update because it took too long
66 find svn
-type f
-name '*.lock' -mmin +60 -print0 |
xargs -0 rm -f
67 GIT_DIR
=. bang git svn fetch
--quiet
68 # git svn does not preserve group permissions in the svn subdirectory
69 chmod -R ug
+rw
,o
+r svn
72 httpurl
="${url/darcs:\/\//http://}"
73 bang git_darcs_fetch
"$httpurl"
76 bzrurl
="${url#bzr://}"
77 bang git_bzr_fetch
"$bzrurl"
80 [ "$url" = "$(git config --get remote.origin.url || :)" ] || bang config_set_raw remote.origin.url
"$url"
81 GIT_SSL_NO_VERIFY
=1 bang git remote update
82 bang git remote prune origin
86 # The objects subdirectories permissions must be updated now.
87 # In the case of a dump http clone, the permissions will not be correct
88 # (missing group write) despite the core.sharedrepository=1 setting!
89 # The objects themselves seem to have the correct permissions.
90 # This problem appears to have been fixed in the most recent git versions.
92 [ "$cfg_permission_control" != "Hooks" ] || perms
=go
+w
93 chmod $perms $
(find objects
-maxdepth 1 -type d
) 2>/dev
/null ||
:
95 bang git update-server-info
96 bang config_set lastrefresh
"$(date "$datefmt")"
98 # Look at which refs changed and trigger ref-change for these
99 show_progress
=1 bang git for-each-ref
--format '%(refname) %(objectname)' |
sort -k1b,1 >.refs-after
100 sockpath
="$cfg_chroot/etc/taskd.socket"
101 if [ -S "$sockpath" ] && ! cmp -s .refs-before .refs-after
; then
102 join -j 1 .refs-before .refs-after |
103 while read ref old new
; do
104 [ "$old" != "$new" ] ||
continue
105 echo "ref-change %$proj% $proj $old $new $ref" | nc.openbsd
-w 1 -U "$sockpath"
107 join -j 1 -v 1 .refs-before .refs-after |
108 while read ref old
; do
109 echo "ref-change %$proj% $proj $old 0000000000000000000000000000000000000000 $ref" | nc.openbsd
-w 1 -U "$sockpath"
111 join -j 1 -v 2 .refs-before .refs-after |
112 while read ref new
; do
113 echo "ref-change %$proj% $proj 0000000000000000000000000000000000000000 $new $ref" | nc.openbsd
-w 1 -U "$sockpath"
115 git config gitweb.lastchange
"$(date '+%a, %d %b %Y %T %z')"
118 rm -f .refs-before .refs-after
120 if [ -e .banged
]; then
121 [ -z "$mailaddrs" ] ||
123 echo "$proj update succeeded - failure recovery"
124 echo "this status message may be disabled on the project admin page"
125 } |
mail -s "[$cfg_name] $proj update succeeded" "$mailaddrs"
129 progress
"- [$proj] update (`date`)"