Skip to content

Commit

Permalink
global: Add support for new SWHID qualifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
anlambert committed Jun 9, 2020
1 parent 6b4ce40 commit 2767f6e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
7 changes: 5 additions & 2 deletions idutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,11 @@
"""ASCL regular expression."""

swh_regexp = re.compile(
"swh:1:(cnt|dir|rel|rev|snp):[0-9a-f]{40}(;origin=\S+)?$"
)
"swh:1:(cnt|dir|rel|rev|snp):[0-9a-f]{40}"
"(;origin=\S+)?(;visit=swh:1:snp:[0-9a-f]{40})?"
"(;anchor=swh:1:(dir|rel|rev):[0-9a-f]{40})?"
"(;path=\S+)?(;lines=[0-9]+(-[0-9]+)?)?$"
)
"""Matches Software Heritage identifiers."""


Expand Down
16 changes: 16 additions & 0 deletions tests/test_idutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,22 @@
('http://archive.softwareheritage.org/'
'swh:1:dir:d198bc9d7a6bcf6db04f476d29314f157507d505'
';origin=https://github.com/user/repo')),
(('swh:1:cnt:78e48f800c950530e36d3712d9e2e89673f23562'
';origin=https://github.com/python/cpython'
';visit=swh:1:snp:cd510e99a42139ed36f15a5774301c113c3e494b'
';anchor=swh:1:rel:ae1f6af15f3e4110616801e235873e47fd7d1977'
';path=/Programs/python.c;lines=12-16'), ['swh', ],
('swh:1:cnt:78e48f800c950530e36d3712d9e2e89673f23562'
';origin=https://github.com/python/cpython'
';visit=swh:1:snp:cd510e99a42139ed36f15a5774301c113c3e494b'
';anchor=swh:1:rel:ae1f6af15f3e4110616801e235873e47fd7d1977'
';path=/Programs/python.c;lines=12-16'),
('http://archive.softwareheritage.org/'
'swh:1:cnt:78e48f800c950530e36d3712d9e2e89673f23562'
';origin=https://github.com/python/cpython'
';visit=swh:1:snp:cd510e99a42139ed36f15a5774301c113c3e494b'
';anchor=swh:1:rel:ae1f6af15f3e4110616801e235873e47fd7d1977'
';path=/Programs/python.c;lines=12-16')),
]


Expand Down

0 comments on commit 2767f6e

Please sign in to comment.