Skip to content

Commit

Permalink
Fix build.get_repo() to return only directory that contains 'repodata…
Browse files Browse the repository at this point in the history
…/repomd.xml'
  • Loading branch information
dmach committed Apr 27, 2023
1 parent 6d54931 commit 2cdf052
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions osc/build.py
Expand Up @@ -456,30 +456,21 @@ def get_built_files(pacdir, buildtype):


def get_repo(path):
"""Walks up path looking for any repodata directories.
"""
Walks up path looking for any repodata directories.
:param path: path to a directory
:return: path to repository directory containing repodata directory
:return: path to repository directory containing repodata directory with repomd.xml file
:rtype: str
"""
oldDirectory = None
currentDirectory = os.path.abspath(path)
repositoryDirectory = None

# while there are still parent directories
while currentDirectory != oldDirectory:
children = os.listdir(currentDirectory)

if "repodata" in children:
repositoryDirectory = currentDirectory
break

# ascend
oldDirectory = currentDirectory
currentDirectory = os.path.abspath(os.path.join(oldDirectory,
os.pardir))
for root, dirs, files in os.walk(path):
if not "repodata" in dirs:
continue
if "repomd.xml" in os.listdir(os.path.join(root, "repodata")):
return root
return None

Check warning on line 472 in osc/build.py

View check run for this annotation

Codecov / codecov/patch

osc/build.py#L467-L472

Added lines #L467 - L472 were not covered by tests

return repositoryDirectory


def get_prefer_pkgs(dirs, wanted_arch, type, cpio):
Expand Down

0 comments on commit 2cdf052

Please sign in to comment.