Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed epoch parser failing for numeric values #3520

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/packagedcode/rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ def __new__(self, version, release=None, epoch=None):
note: the sort order of the named tuple is the sort order.
But for creation we put the rarely used epoch last with a default to None.
"""

epoch = str(epoch) if epoch else ""

if epoch and epoch.strip() and not epoch.isdigit():
raise ValueError('Invalid epoch: must be a number or empty.')
if not version:
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "apache-commons-io",
"epoch": "1",
"version": "2.4",
"release": "12.el7",
"arch": "noarch",
"os": "linux",
"summary": "Utilities to assist with developing IO functionality",
"description": null,
"distribution": null,
"vendor": "CentOS",
"license": "ASL 2.0",
"packager": "CentOS BuildSystem <http://bugs.centos.org>",
"group": "Unspecified",
"url": "http://commons.apache.org/io",
"source_rpm": "apache-commons-io-2.4-12.el7.src.rpm",
"dist_url": null,
"is_binary": true
}
4 changes: 4 additions & 0 deletions tests/packagedcode/test_rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,3 +391,7 @@ def test_rpm_tags_xsetup_0_28_b1_src_rpm(self):
def test_rpm_tags_zziplib_0_11_15_3sf_i586_rpm(self):
test_file = self.get_test_loc('rpm/header/zziplib-0.11.15-3sf.i586.rpm')
self.check_rpm_tags(test_file)

def test_rpm_tags_apache_commons_io_2_4_12_el7_noarch_rpm(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe test_get_rpm_tags_can_parse_numeric_values is a better name?

Copy link
Contributor Author

@OmkarPh OmkarPh Sep 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the tests above also check for the same function right
Should I update those too?

test_file = self.get_test_loc('rpm/header/apache-commons-io-2.4-12.el7.noarch.rpm')
OmkarPh marked this conversation as resolved.
Show resolved Hide resolved
self.check_rpm_tags(test_file)