blob: d22151ceecea34eff66c63276e62a9cebf208d1d (
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
|
#!/bin/bash
if [ $# -eq 1 ]; then
if [ "$1" == "--help" ]; then
>&2 echo \
'Usage: gitolite-sync [options]
Synchronize the configured git repositories.
Options:
#HELPTEXT# #'
exit
elif [ "$1" == "--version" ]; then
echo '#VERSION#'
exit
fi
fi
if [ $# -ne 0 ]; then
>&2 echo 'too many arguments'
exit 1
fi
. "#ETCDIR#/gitolite-sync.conf"
if [ ${#repository_dirs[@]} -eq 0 ]; then
>&2 echo 'no repository_dirs defined'
exit 1
fi
for repository_dir in "${repository_dirs[@]}"; do
if [ -z "${repository_dir}" ] || [ ! -d "${repository_dir}" ]; then
>&2 printf 'cannot find "%s"\n' \
"${repository_dir}"
exit 1
fi
done
for repository_dir in "${repository_dirs[@]}"; do
find "${repository_dir}" \
-type d \
-name '*.git' \
-printf '%p\n' \
-prune \
| while read -r path; do
>&2 printf 'synchronizing "%s" ...\n' \
"${path}"
remotes=$(
git -C "${path}" remote -v \
| grep "${remote_regex}" \
| awk '{print $1}' \
| sort -u
)
if [ -z "${remotes}" ] \
&& ! git -C "${path}" remote get-url "${default_remote_name}" >/dev/null 2>&1; then
>&2 printf 'adding default remote "%s", because no remote was found so far\n' \
"${default_remote_name}"
git -C "${path}" remote add "${default_remote_name}" "$(
printf '%s\n' "${path}" \
| sed "${default_remote_path_substitution}"
)"
remotes="${default_remote_name}"
fi
for remote in ${remotes}; do
git -C "${path}" fetch "${remote}" 'refs/heads/*:refs/heads/*' 'refs/tags/*:refs/tags/*'
git -C "${path}" push "${remote}" 'refs/heads/*:refs/heads/*' 'refs/tags/*:refs/tags/*'
done
done
done
|