Skip to content

Beakerlib._merge_metadata does not do what it is supposed to do #4501

@LecrisUT

Description

@LecrisUT

def _merge_metadata(self, library_path: Path, local_library_path: Path) -> None:
"""
Merge all inherited metadata into one metadata file
"""
for f in local_library_path.glob(r'*\.fmf'):
f.unlink()
write(
path=local_library_path / 'main.fmf',
data=tmt.utils.get_full_metadata(library_path, self.name),
quiet=True,
)

This function is supposed to delete all .fmf files and then write a single main.fmf file with only the current metadata. Notice the bug in here?

Spoiler

It's the bogus \ escape:

>>> from pathlib import Path
... some_tree = Path("docs/releases")
... print("[Original]")
... for f in some_tree.glob(r"*\.fmf"):
...     print(f)
... print("[Expected]")
... for f in some_tree.glob("**/?*.fmf"):
...     print(f)
[Original]
[Expected]
docs/releases/main.fmf
docs/releases/1.62.1/4125.fmf
docs/releases/1.62.1/4231.fmf

Secondary bug though, if we fix it to actually delete all .fmf files, then we risk deleting also subtrees, so instead we need to get the exact fmf source files and delete only those. @HouMinXi I think this was a compounding issue for #4439.

Metadata

Metadata

Assignees

Labels

area | librariesIssues related to beakerlib libraries support

Type

Projects

Status

backlog

Status

triaged

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions