From ceba1068573cb722d9c749538473dfbed7ec73a4 Mon Sep 17 00:00:00 2001 From: Sagi Shnaidman Date: Wed, 27 Mar 2019 13:02:14 +0200 Subject: [PATCH] Keep delorean.repo filename consistent in branches While repo name can be different, we need to keep the filename the same across all branches. It's required for scripts that parses repo files and shouldn't be branch dependent. Change-Id: I6fac85a092ff07e688d0a3f9f851244b4dc2b73c --- tripleo_repos/main.py | 14 ++++++++------ tripleo_repos/tests/test_main.py | 6 ++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tripleo_repos/main.py b/tripleo_repos/main.py index c5c9734..e34d657 100755 --- a/tripleo_repos/main.py +++ b/tripleo_repos/main.py @@ -147,11 +147,13 @@ def _get_repo(path, args): r.raise_for_status() -def _write_repo(content, target): - m = TITLE_RE.search(content) - if not m: - raise NoRepoTitle('Could not find repo title in: \n%s' % content) - filename = m.group(1) + '.repo' +def _write_repo(content, target, name=None): + if not name: + m = TITLE_RE.search(content) + if not m: + raise NoRepoTitle('Could not find repo title in: \n%s' % content) + name = m.group(1) + filename = name + '.repo' filename = os.path.join(target, filename) with open(filename, 'w') as f: f.write(content) @@ -284,7 +286,7 @@ def _install_repos(args, base_path): content = _get_repo(base_path + 'current/delorean.repo', args) if args.branch != 'master': content = TITLE_RE.sub('[delorean-%s]' % args.branch, content) - _write_repo(content, args.output_path) + _write_repo(content, args.output_path, name='delorean') install_deps(args, base_path) elif repo == 'deps': install_deps(args, base_path) diff --git a/tripleo_repos/tests/test_main.py b/tripleo_repos/tests/test_main.py index 6ea0073..8ea7df4 100644 --- a/tripleo_repos/tests/test_main.py +++ b/tripleo_repos/tests/test_main.py @@ -161,7 +161,8 @@ class TestTripleORepos(testtools.TestCase): mock.call('roads/delorean-deps.repo', args), ], mock_get.mock_calls) - self.assertEqual([mock.call('[delorean]\nMr. Fusion', 'test'), + self.assertEqual([mock.call('[delorean]\nMr. Fusion', 'test', + name='delorean'), mock.call('[delorean]\nMr. Fusion', 'test'), ], mock_write.mock_calls) @@ -179,7 +180,8 @@ class TestTripleORepos(testtools.TestCase): mock.call('roads/delorean-deps.repo', args), ], mock_get.mock_calls) - self.assertEqual([mock.call('[delorean-mitaka]\nMr. Fusion', 'test'), + self.assertEqual([mock.call('[delorean-mitaka]\nMr. Fusion', 'test', + name='delorean'), mock.call('[delorean]\nMr. Fusion', 'test'), ], mock_write.mock_calls)