aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-08-25 15:22:00 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-08-25 15:22:00 -0400
commit76bfb62263d67a6c0718fff9a596f0715eca306f (patch)
treee3d742ef8be947b900608bcef7a3bc6e0918ee23
parent5e241a7fb5a12a2f952e87bfd2ec55e55151d201 (diff)
downloadgrokmirror-76bfb62263d67a6c0718fff9a596f0715eca306f.tar.gz
Add pull.nopurge setting
There are valid cases where we have repos not replicated with grokmirror that we nevertheless don't want to get purged. Add pull.nopurge setting to make that configurable. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r--grokmirror.conf5
-rwxr-xr-xgrokmirror/pull.py10
2 files changed, 14 insertions, 1 deletions
diff --git a/grokmirror.conf b/grokmirror.conf
index afb21b9..1d012d7 100644
--- a/grokmirror.conf
+++ b/grokmirror.conf
@@ -131,6 +131,11 @@ post_update_hook =
# See also: purgeprotect.
purge = yes
#
+# There may be repositories that aren't replicated with grokmirror that
+# you don't want to be purged. You can list them below using bash-style
+# globbing. Separate multiple entries using newline+whitespace.
+#nopurge = /gitolite-admin.git
+#
# This prevents catastrophic mirror purges when our upstream gives us a
# manifest that is dramatically smaller than ours. The default is to
# refuse the purge if the remote manifest has over 5% fewer repositories
diff --git a/grokmirror/pull.py b/grokmirror/pull.py
index 6e10a4f..b132a66 100755
--- a/grokmirror/pull.py
+++ b/grokmirror/pull.py
@@ -624,6 +624,7 @@ def fill_todo_from_manifest(config, active_actions, nomtime=False, forcepurge=Fa
if not os.access(r_mani_cmd, os.X_OK):
logger.critical('Remote manifest command is not executable: %s', r_mani_cmd)
sys.exit(1)
+ logger.info(' manifest: executing %s', r_mani_cmd)
cmdargs = [r_mani_cmd]
(ecode, output, error) = grokmirror.run_shell_command(cmdargs)
if ecode == 0:
@@ -875,6 +876,7 @@ def fill_todo_from_manifest(config, active_actions, nomtime=False, forcepurge=Fa
actions.append((gitdir, 'init'))
if config['pull'].getboolean('purge', False):
+ nopurge = config['pull'].get('nopurge', '').split('\n')
to_purge = set()
found_repos = 0
for founddir in grokmirror.find_all_gitdirs(toplevel, exclude_objstore=True):
@@ -882,7 +884,13 @@ def fill_todo_from_manifest(config, active_actions, nomtime=False, forcepurge=Fa
found_repos += 1
if gitdir not in r_culled and gitdir not in all_symlinks:
- to_purge.add(gitdir)
+ exclude = False
+ for entry in nopurge:
+ if fnmatch.fnmatch(gitdir, entry):
+ exclude = True
+ break
+ if not exclude:
+ to_purge.add(gitdir)
if len(to_purge):
# Purge-protection engage