Skip to content

Commit f9ab495

Browse files
committed
Fix tests
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
1 parent cdfa818 commit f9ab495

File tree

6 files changed

+10783
-12176
lines changed

6 files changed

+10783
-12176
lines changed

src/fetchcode/package.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,9 @@ class UtilLinuxDirectoryListedSource(DirectoryListedSource):
472472
source_url = "https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/"
473473
is_nested = True
474474
# Source archive ex: util-linux-1.2.3.tar.gz
475-
source_archive_regex = re.compile(r"^(util-linux-)(?P<version>[\w.-]*)(.tar.gz)$")
475+
source_archive_regex = re.compile(
476+
r"^(util-linux-|util-linux-ng-)(?P<version>[\w.-]*)(.tar.gz)$"
477+
)
476478
ignored_files_and_dir = []
477479

478480

src/fetchcode/package_util.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,13 @@ def _get_github_packages(purl, version_regex, ignored_tag_regex, default_package
123123
else:
124124
version = tag
125125

126-
version = version.strip("Vv").strip().replace("_", ".")
126+
version = version.strip("Vv").strip()
127+
if "+" in version:
128+
first, last = version.split("+")
129+
first.replace("_", ".")
130+
version = f"{first}+{last}"
131+
else:
132+
version = version.replace("_", ".")
127133
if not version or not version[0].isdigit():
128134
continue
129135

src/fetchcode/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ class GitHubTokenError(Exception):
117117
class GraphQLError(Exception):
118118
pass
119119

120+
120121
def get_github_token():
121122
gh_token = os.environ.get("GH_TOKEN", None)
122123
if not gh_token:
@@ -152,9 +153,11 @@ def github_response(graphql_query):
152153

153154
return response
154155

156+
155157
def get_github_rest(url):
156158
headers = None
157-
if gh_token := get_github_token():
159+
gh_token = get_github_token()
160+
if gh_token:
158161
headers = {
159162
"Authorization": f"Bearer {gh_token}",
160163
}

0 commit comments

Comments
 (0)