createrepo: Only consider successful compose for deltas
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ář <lsedlar@redhat.com>
This commit is contained in:
parent
e21a27bdc9
commit
40796c04f4
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user