From ec18d30b65fbe2da859648171fa3d77bccad8029 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Wed, 11 Sep 2019 14:31:55 +0200 Subject: gitolite-sync: create default remote if no remote was set up so far --- gitolite-sync.conf.in | 6 ++++++ gitolite-sync.in | 10 +++++++--- 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/*' -- cgit v1.2.3-70-g09d2