Skip to content

Commit 661d543

Browse files
committed
Allow short commit hashes for Cargo crates
Seen e.g. for lsp-types in ruff: [[package]] name = "lsp-types" version = "0.95.1" source = "git+https://github.com/astral-sh/lsp-types.git?rev=3512a9f#3512a9f33eadc5402cfab1b8f7340824c8ca1439"
1 parent dcd7ddf commit 661d543

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

easybuild/easyblocks/generic/cargo.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,13 @@ def generate_crate_list(sourcedir):
562562
qs = parse_qs(parsed_url.query)
563563
rev_qs = qs.get('rev', [None])[0]
564564
if rev_qs is not None and rev_qs != rev:
565-
raise ValueError(f"Found different revision in query of URL {url}: {rev_qs} (expected: {rev})")
565+
# It is not an error if one is the short version of the other
566+
# E.g. https://github.com/astral/lsp-types.git?rev=3512a9f#3512a9f33eadc5402cfab1b8f7340824c8ca1439
567+
if (rev_qs and rev.startswith(rev_qs)) or rev_qs.startswith(rev):
568+
# The query value is the relevant one if both are present
569+
rev = rev_qs
570+
else:
571+
raise ValueError(f"Found different revision in query of URL {url}: {rev_qs} (expected: {rev})")
566572
crates.append((name, version, url, rev))
567573
return app_in_cratesio, crates, other_crates
568574

0 commit comments

Comments
 (0)