rust2rpm: return single metadata
When generating the spec file, takes care of asserting that there is a single metadata. If not, write a warning.
This commit is contained in:
parent
1883197d9c
commit
31a778c4f2
1 changed files with 6 additions and 0 deletions
|
@ -261,6 +261,9 @@ def make_diff_metadata(crate, version, patch=False, store=False):
|
||||||
toml, crate, version, doc_files, license_files = local_toml(crate, version)
|
toml, crate, version, doc_files, license_files = local_toml(crate, version)
|
||||||
diff = make_patch(toml, enabled=patch, tmpfile=True)
|
diff = make_patch(toml, enabled=patch, tmpfile=True)
|
||||||
metadata = Metadata.from_file(toml)
|
metadata = Metadata.from_file(toml)
|
||||||
|
if len(metadata) > 1:
|
||||||
|
print(f"Warning: multiple metadata for {toml}")
|
||||||
|
metadata = metadata[0]
|
||||||
return metadata.name, diff, metadata, doc_files, license_files
|
return metadata.name, diff, metadata, doc_files, license_files
|
||||||
else:
|
else:
|
||||||
cratef, crate, version = download(crate, version)
|
cratef, crate, version = download(crate, version)
|
||||||
|
@ -268,6 +271,9 @@ def make_diff_metadata(crate, version, patch=False, store=False):
|
||||||
with files_from_crate(cratef, crate, version) as (toml, doc_files, license_files):
|
with files_from_crate(cratef, crate, version) as (toml, doc_files, license_files):
|
||||||
diff = make_patch(toml, enabled=patch)
|
diff = make_patch(toml, enabled=patch)
|
||||||
metadata = Metadata.from_file(toml)
|
metadata = Metadata.from_file(toml)
|
||||||
|
if len(metadata) > 1:
|
||||||
|
print(f"Warning: multiple metadata for {toml}")
|
||||||
|
metadata = metadata[0]
|
||||||
if store:
|
if store:
|
||||||
shutil.copy2(cratef, os.path.join(os.getcwd(), f"{metadata.name}-{version}.crate"))
|
shutil.copy2(cratef, os.path.join(os.getcwd(), f"{metadata.name}-{version}.crate"))
|
||||||
return crate, diff, metadata, doc_files, license_files
|
return crate, diff, metadata, doc_files, license_files
|
||||||
|
|
Loading…
Reference in a new issue