Do not skip symlinks when searching for old compose.

ODCS creates symlinks to real directories containing the composes.
The directory structure is similar to following one:

- `./nightly/Fedora-Rawhide-20200304.n.0` -> `../odcs-3`
- `./nightly/Fedora-Rawhide-20200305.n.0` -> `../odcs-4`
- `./nightly/latest-Fedora-Rawhide` -> `../odcs-5`

The current Pungi code to search for old composes skips symlinks
and therefore old ODCS composes are not found.

This commit removes this check and therefore symlinks are allowed
when searching for old compose.

I think this check existed to prevent using `latest-*` symlink as
source for the compose. But this is not possible, because the
code checks that the old compose directory name has certain pattern
constructed from release_short, release_version, ... The `latest-*`
symlink definitely does not match this pattern.

I also executed test compose and it worked as expected.

Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
This commit is contained in:
Jan Kaluza 2020-03-05 09:32:03 +01:00 committed by lsedlar
parent 887c68d05d
commit fc3b5063ca
2 changed files with 7 additions and 6 deletions

View File

@ -532,9 +532,6 @@ def find_old_compose(
if not os.path.isdir(path):
continue
if os.path.islink(path):
continue
status_path = os.path.join(path, "STATUS")
if not os.path.isfile(status_path):
continue

View File

@ -465,10 +465,14 @@ class TestFindOldCompose(unittest.TestCase):
old = util.find_old_compose(self.tmp_dir + "/file", "Fedora", "Rawhide", "")
self.assertIsNone(old)
def test_skips_symlink(self):
os.symlink(self.tmp_dir, self.tmp_dir + "/Fedora-Rawhide-20160229.0")
def test_do_not_skip_symlink(self):
touch(self.tmp_dir + "/Fedora-Rawhide-20160228.n.10/STATUS", "FINISHED")
os.symlink(
self.tmp_dir + "/Fedora-Rawhide-20160228.n.10",
self.tmp_dir + "/Fedora-Rawhide-20160229.n.0",
)
old = util.find_old_compose(self.tmp_dir, "Fedora", "Rawhide", "")
self.assertIsNone(old)
self.assertEqual(old, self.tmp_dir + "/Fedora-Rawhide-20160229.n.0")
def test_finds_layered_product(self):
touch(self.tmp_dir + "/Fedora-Rawhide-Base-1-20160229.0/STATUS", "FINISHED")