Skip to content

Commit 24fdf1d

Browse files
committed
Add more test and fix cgit regex pattern
Signed-off-by: ziad hany <ziadhany2016@gmail.com>
1 parent 7e87e09 commit 24fdf1d

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/packageurl/contrib/url2purl.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,9 @@ def build_cgit_purl(url):
763763
r"(?P<namespace>.+)/"
764764
r"(?P<name>[^/]+?)"
765765
r"(?:\.git)?"
766-
r"/commit/\?id="
766+
r"/commit/"
767+
r"(?:[^?]+)?"
768+
r"\?id="
767769
r"(?P<version>[0-9a-fA-F]{7,64})/?$"
768770
)
769771

tests/contrib/data/url2purl.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@
285285
"https://codeberg.org/alpinelinux/aports/commit/a40a9732c840e5a324fba78b0ff7980b497c3831": "pkg:generic/codeberg.org/alpinelinux/aports@a40a9732c840e5a324fba78b0ff7980b497c3831",
286286

287287
"https://git.kernel.org/pub/scm/utils/b4/b4.git/commit/?id=477734000555ffc24bf873952e40367deee26f17": "pkg:generic/git.kernel.org/pub/scm/utils/b4/b4@477734000555ffc24bf873952e40367deee26f17",
288+
"https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/net/core/sock.c?id=9d538fa60bad4f7b23193c89e843797a1cf71ef3": "pkg:generic/git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux@9d538fa60bad4f7b23193c89e843797a1cf71ef3",
288289
"https://cgit.git.savannah.gnu.org/cgit/uddf.git/commit/?id=98c41e131dc952aee43d4ec392b80ca4c426be8d": "pkg:generic/cgit.git.savannah.gnu.org/cgit/uddf@98c41e131dc952aee43d4ec392b80ca4c426be8d",
289290
"https://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git/commit/?id=7457fe9541b5162f285454947448d553a5d5a531": "pkg:generic/git.kernel.org/pub/scm/virt/kvm/mst/qemu@7457fe9541b5162f285454947448d553a5d5a531",
290291

0 commit comments

Comments
 (0)