From 40796c04f4da8c850f2c416d56322b6b2a8b97d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Tue, 29 Aug 2017 14:42:39 +0200 Subject: [PATCH] createrepo: Only consider successful compose for deltas MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the compose failed, it may not have repos to compute deltas against, and even if it has them, they were never shipped so no one will have the older version of the package. We should instead go deeper in history and pick a successful compose. Relates: https://pagure.io/pungi/issue/715 Signed-off-by: Lubomír Sedlář --- pungi/phases/createrepo.py | 3 ++- pungi/util.py | 6 ++++-- tests/test_util.py | 6 ++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pungi/phases/createrepo.py b/pungi/phases/createrepo.py index 22985fba..1324f9ca 100644 --- a/pungi/phases/createrepo.py +++ b/pungi/phases/createrepo.py @@ -272,7 +272,8 @@ def _get_old_package_dirs(compose, repo_dir): compose.ci_base.release.short, compose.ci_base.release.version, compose.ci_base.base_product.short if compose.ci_base.release.is_layered else None, - compose.ci_base.base_product.version if compose.ci_base.release.is_layered else None + compose.ci_base.base_product.version if compose.ci_base.release.is_layered else None, + allowed_statuses=['FINISHED', 'FINISHED_INCOMPLETE'], ) if not old_compose_path: compose.log_info("No suitable old compose found in: %s" % compose.old_composes) diff --git a/pungi/util.py b/pungi/util.py index 7fbc2ffb..c8c9e306 100644 --- a/pungi/util.py +++ b/pungi/util.py @@ -396,7 +396,9 @@ def get_file_size(path): def find_old_compose(old_compose_dirs, release_short, release_version, - base_product_short=None, base_product_version=None): + base_product_short=None, base_product_version=None, + allowed_statuses=None): + allowed_statuses = allowed_statuses or ("FINISHED", "FINISHED_INCOMPLETE", "DOOMED") composes = [] def _sortable(compose_id): @@ -437,7 +439,7 @@ def find_old_compose(old_compose_dirs, release_short, release_version, try: with open(status_path, 'r') as f: - if f.read().strip() in ("FINISHED", "FINISHED_INCOMPLETE", "DOOMED"): + if f.read().strip() in allowed_statuses: composes.append((_sortable(i), os.path.abspath(path))) except: continue diff --git a/tests/test_util.py b/tests/test_util.py index aa1e6caa..81630505 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -233,6 +233,12 @@ class TestFindOldCompose(unittest.TestCase): old = util.find_old_compose(self.tmp_dir, 'Fedora', 'Rawhide') self.assertIsNone(old) + def test_only_considers_allowed_status(self): + touch(self.tmp_dir + '/Fedora-Rawhide-20160229.0/STATUS', 'FINISHED') + old = util.find_old_compose(self.tmp_dir, 'Fedora', 'Rawhide', + allowed_statuses=['DOOMED']) + self.assertIsNone(old) + def test_finds_latest(self): touch(self.tmp_dir + '/Fedora-Rawhide-20160228.0/STATUS', 'DOOMED') touch(self.tmp_dir + '/Fedora-Rawhide-20160229.0/STATUS', 'FINISHED')