summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-09-11 14:31:55 +0200
committerErich Eckner <git@eckner.net>2019-09-11 14:31:55 +0200
commitec18d30b65fbe2da859648171fa3d77bccad8029 (patch)
tree07d70ee7a13fc400114f0ab2495f92e3ee6ef88c
parent585353d2ca9d9355cb4e7097f1c173a3a95f330d (diff)
downloadgitolite-sync-ec18d30b65fbe2da859648171fa3d77bccad8029.tar.xz
gitolite-sync: create default remote if no remote was set up so far
-rw-r--r--gitolite-sync.conf.in6
-rw-r--r--gitolite-sync.in10
2 files changed, 13 insertions, 3 deletions
diff --git a/gitolite-sync.conf.in b/gitolite-sync.conf.in
index 240ec0c..3ba06be 100644
--- a/gitolite-sync.conf.in
+++ b/gitolite-sync.conf.in
@@ -11,3 +11,9 @@ repository_dirs=(
| sed 's,$,/repositories,'
)
)
+
+# name and path of default remote
+default_remote_name='ecknernet'
+default_remote_path_substitution='
+ s#^'"${repository_dirs[0]}"'#gitolite@eckner.net:#
+'
diff --git a/gitolite-sync.in b/gitolite-sync.in
index 067b87a..9c7bdf0 100644
--- a/gitolite-sync.in
+++ b/gitolite-sync.in
@@ -51,9 +51,13 @@ for repository_dir in "${repository_dirs[@]}"; do
| sort -u
)
if [ -z "${remotes}" ]; then
- >&2 printf 'Repository "%s" has no backup remotes.\n' \
- "${path}"
- continue
+ >&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/*'