aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-11-12 14:03:36 -0500
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-11-12 14:03:36 -0500
commit07332cb507b944d786aefc1b2bada82b24e04db2 (patch)
tree9583d9ee743cf0c2789d81f78af98074f76b02c3
parent0462cafad016af6623b28d0a85b23727675e16fd (diff)
downloadgrokmirror-07332cb507b944d786aefc1b2bada82b24e04db2.tar.gz
Properly handle multiple baseline entries
This properly handles situations when we want more than one repository considered for baseline matching. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r--grokmirror/__init__.py2
-rwxr-xr-xgrokmirror/fsck.py39
2 files changed, 21 insertions, 20 deletions
diff --git a/grokmirror/__init__.py b/grokmirror/__init__.py
index ce2ef95..75b5d99 100644
--- a/grokmirror/__init__.py
+++ b/grokmirror/__init__.py
@@ -38,7 +38,7 @@ from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
-VERSION = '2.0.4'
+VERSION = '2.0.5-dev'
MANIFEST_LOCKH = None
REPO_LOCKH = dict()
GITBIN = '/usr/bin/git'
diff --git a/grokmirror/fsck.py b/grokmirror/fsck.py
index e800d55..52c1187 100755
--- a/grokmirror/fsck.py
+++ b/grokmirror/fsck.py
@@ -1051,7 +1051,8 @@ def fsck_mirror(config, force=False, repack_only=False, conn_only=False,
my_remotes = grokmirror.list_repo_remotes(obstrepo, withurl=True)
# Use the first child repo as our "reference" entry in manifest
refrepo = None
- set_baseline = False
+ # Use for the alternateRefsPrefixes value
+ baseline_refs = set()
set_islandcore = False
new_islandcore = False
valid_virtrefs = set()
@@ -1087,24 +1088,11 @@ def fsck_mirror(config, force=False, repack_only=False, conn_only=False,
continue
# Do we need to set any alternateRefsPrefixes?
- if not set_baseline:
- is_baseline = False
- for baseline in baselines:
- # Does this repo match a baseline
- if fnmatch.fnmatch(gitdir, baseline):
- is_baseline = True
- break
- if is_baseline:
- set_baseline = True
- refpref = 'refs/virtual/%s/heads/' % virtref
- # Go through all remotes and set their alternateRefsPrefixes
- for s_virtref, s_childpath in my_remotes:
- # is it already set to that?
- entries = grokmirror.get_config_from_git(s_childpath, r'core\.alternate*')
- if entries.get('alternaterefsprefixes') != refpref:
- s_gitdir = '/' + os.path.relpath(s_childpath, toplevel)
- logger.info(' reconfig: %s (baseline to %s)', s_gitdir, virtref)
- grokmirror.set_git_config(s_childpath, 'core.alternateRefsPrefixes', refpref)
+ for baseline in baselines:
+ # Does this repo match a baseline
+ if fnmatch.fnmatch(gitdir, baseline):
+ baseline_refs.add('refs/virtual/%s/heads/' % virtref)
+ break
# Do we need to set islandCore?
if not set_islandcore:
@@ -1132,6 +1120,19 @@ def fsck_mirror(config, force=False, repack_only=False, conn_only=False,
manifest[gitdir]['forkgroup'] = os.path.basename(obstrepo[:-4])
+ if len(baseline_refs):
+ # sort the list, so we have deterministic value
+ br = list(baseline_refs)
+ br.sort()
+ refpref = ' '.join(br)
+ # Go through all remotes and set their alternateRefsPrefixes
+ for s_virtref, s_childpath in my_remotes:
+ # is it already set to that?
+ entries = grokmirror.get_config_from_git(s_childpath, r'core\.alternate*')
+ if entries.get('alternaterefsprefixes') != refpref:
+ s_gitdir = '/' + os.path.relpath(s_childpath, toplevel)
+ logger.info(' reconfig: %s (baseline)', s_gitdir)
+ grokmirror.set_git_config(s_childpath, 'core.alternateRefsPrefixes', refpref)
repack_requested = False
if os.path.exists(os.path.join(obstrepo, 'grokmirror.repack')):
repack_requested = True