blob: 21c78985b5a60f951710d675a483aa38591d1ab7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
#! /usr/bin/env bash
# Some commonly useful addtional options that can be specified via the
# command line:
#
# --dry-run
# --progress
#
owd=`pwd`
trap "{ cd $owd; exit 1; }" ERR
set -o errtrace # Trap in functions.
echo_git=
# Keep arguments intact for the future use with rsync.
#
for o in "$@"; do
case $o in
--dry-run)
echo_git=echo
;;
esac
done
# Publish test pkg repositories.
#
rsync -v -rlpt --copy-unsafe-links \
--prune-empty-dirs --delete-after --delete-excluded $* \
--include '*/' \
--include '*.tar.gz' \
--include 'packages' \
--include 'repositories' \
--include 'signature' \
--exclude '*' \
test/*/pkg/1/build2.org/ build2.org:/var/pkg/1/
# Publish test git repositories.
#
urls=('git.build2.org:/var/scm/testing/bpkg/unadv' \
'git.build2.org:/var/scm/testing/bpkg/advonly')
# Find git repository directories to publish.
#
for r in $(find test -type d -regex '.*/git/.*/[^/]+\.git'); do
br="${r/\/git\//\/git-bare\/}" # Bare repository directory.
# Make base repositories from the test ones.
#
rm -r -f $br
mkdir -p $(dirname $br)
git clone --bare $r $br
# Subdirectory that is relative to git-bare/.
#
d=$(echo $br | sed -n -e 's%.*/git-bare/\(.*\)%\1%p')
for u in "${urls[@]}"; do
url="$u/$d"
# Push local branches and tags to the remote repository, if it exists.
#
if git ls-remote "$url" 2>/dev/null >&2; then
# Point the bare repository origin to the remote repository.
#
git -C $br config remote.origin.url "$url"
# Delete all remote branches and tags.
#
while read commit ref; do
$echo_git git -C $br push origin ":$ref"
done < <(git -C $br ls-remote --refs origin)
# Push local branches.
#
while read branch; do
$echo_git git -C $br push --tags origin "$branch:$branch"
done < <(git -C $br for-each-ref --format='%(refname:short)' \
'refs/heads/')
fi
done
# Prepare the bare repository for serving via the HTTPS dumb protocol.
#
git -C $br update-server-info --force
done
# Publish git repositories that are served via the HTTPS dumb protocol.
#
rsync -v -rlpt --copy-unsafe-links --delete-after $* \
test/*/git-bare/ build2.org:/var/pkg/git/
|