File tree Expand file tree Collapse file tree 7 files changed +72
-29
lines changed Expand file tree Collapse file tree 7 files changed +72
-29
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,16 @@ $ pip install --user --upgrade --pre libvcs
1515
1616<!-- Maintainers, insert changes / features for the next release here -->
1717
18+ ### Breaking changes
19+
20+ #### urls: Variable changes (#463 )
21+
22+ - ` RE_PIP_REV ` moved from ` libvcs.url.git ` to ` libvcs.url.constants ` .
23+ - Regex pattern for user (e.g. ` git@ ` ) decoupled to ` RE_USER ` .
24+ - ` RE_PATH ` and ` SCP_REGEX ` (now ` RE_SCP ` ) no longer include user regex pattern
25+ - Existing patterns now use ` RE_USER ` explicitly.
26+ - ` REGEX_SCP ` renamed to ` RE_SCP ` for consistency.
27+
1828### Documentation
1929
2030- Automatically linkify links that were previously only text.
@@ -26,6 +36,7 @@ $ pip install --user --upgrade --pre libvcs
2636- poetry: 1.8.1 -> 1.8.2
2737
2838 See also: https://github.com/python-poetry/poetry/blob/1.8.2/CHANGELOG.md
39+
2940- Code quality: Use f-strings in more places (#460 )
3041
3142 via [ ruff 0.4.2] ( https://github.com/astral-sh/ruff/blob/v0.4.2/CHANGELOG.md ) .
Original file line number Diff line number Diff line change 1+ ---
2+ myst :
3+ html_meta :
4+ " property=og:locale " : " en_US"
5+ ---
6+ (url-parser-constants)=
7+
8+ # Constants - ` libvcs.url.constants `
9+
10+ ``` {eval-rst}
11+ .. automodule:: libvcs.url.constants
12+ :members:
13+ :undoc-members:
14+ ```
Original file line number Diff line number Diff line change 269269hg
270270base
271271registry
272+ constants
272273```
Original file line number Diff line number Diff line change 1+ """Constants shared across ``libvcs.url``."""
2+
3+ RE_USER = r"""
4+ ((?P<user>[^/:@]+)@)?
5+ """
6+ """Optional user, e.g. 'git@'"""
7+
8+ # Credit, pip (license: MIT):
9+ # https://github.com/pypa/pip/blob/22.1.2/src/pip/_internal/vcs/git.py#L39-L52
10+ # We modified it to have groupings
11+ RE_SCP = r"""
12+ # Server, e.g. 'github.com'.
13+ (?P<hostname>([^/:]+))
14+ (?P<separator>:)
15+ # The server-side path. e.g. 'user/project.git'. Must start with an
16+ # alphanumeric character so as not to be confusable with a Windows paths
17+ # like 'C:/foo/bar' or 'C:\foo\bar'.
18+ (?P<path>(\w[^:.]+))
19+ """
20+ """Regular expression for scp-style of git URLs."""
21+
22+ #
23+ # Third-party URLs, e.g. npm, pip, etc.
24+ #
25+ RE_PIP_REV = r"""
26+ (@(?P<rev>.*))
27+ """
28+ """Pip-style revision for branch or revision."""
Original file line number Diff line number Diff line change 2323from libvcs ._internal .dataclasses import SkipDefaultFieldsReprMixin
2424
2525from .base import Rule , RuleMap , URLProtocol
26-
27- # Credit, pip (license: MIT):
28- # https://github.com/pypa/pip/blob/22.1.2/src/pip/_internal/vcs/git.py#L39-L52
29- # We modified it to have groupings
30- SCP_REGEX = r"""
31- # Optional user, e.g. 'git@'
32- ((?P<user>\w+)@)?
33- # Server, e.g. 'github.com'.
34- (?P<hostname>([^/:]+))
35- (?P<separator>:)
36- # The server-side path. e.g. 'user/project.git'. Must start with an
37- # alphanumeric character so as not to be confusable with a Windows paths
38- # like 'C:/foo/bar' or 'C:\foo\bar'.
39- (?P<path>(\w[^:.]+))
40- """
26+ from .constants import RE_PIP_REV , RE_SCP , RE_USER
4127
4228RE_PATH = r"""
43- ((?P<user>\w+)@)?
4429 (?P<hostname>([^/:]+))
4530 (:(?P<port>\d{1,5}))?
4631 (?P<separator>[:,/])?
6954 rf"""
7055 ^{ RE_SCHEME }
7156 ://
57+ { RE_USER }
7258 { RE_PATH }
7359 { RE_SUFFIX } ?
7460 """ ,
8369 pattern = re .compile (
8470 rf"""
8571 ^(?P<scheme>ssh)?
86- { SCP_REGEX }
72+ { RE_USER }
73+ { RE_SCP }
8774 { RE_SUFFIX } ?
8875 """ ,
8976 re .VERBOSE ,
121108 )
122109"""
123110
124- RE_PIP_REV = r"""
125- (@(?P<rev>.*))
126- """
127-
128-
129111PIP_DEFAULT_RULES : list [Rule ] = [
130112 Rule (
131113 label = "pip-url" ,
134116 rf"""
135117 { RE_PIP_SCHEME }
136118 ://
119+ { RE_USER }
137120 { RE_PATH }
138121 { RE_SUFFIX } ?
139122 { RE_PIP_REV } ?
148131 pattern = re .compile (
149132 rf"""
150133 { RE_PIP_SCP_SCHEME }
151- { SCP_REGEX } ?
134+ { RE_USER }
135+ { RE_SCP } ?
152136 { RE_SUFFIX } ?
153137 { RE_PIP_REV } ?
154138 """ ,
Original file line number Diff line number Diff line change 2222from typing import Optional
2323
2424from libvcs ._internal .dataclasses import SkipDefaultFieldsReprMixin
25- from libvcs .url .git import RE_PIP_REV , RE_SUFFIX , SCP_REGEX
25+ from libvcs .url .git import RE_SUFFIX
2626
2727from .base import Rule , RuleMap , URLProtocol
28+ from .constants import RE_PIP_REV , RE_SCP , RE_USER
2829
2930RE_PATH = r"""
30- ((?P<user>\w+)@)?
3131 (?P<hostname>([^/:]+))
3232 (:(?P<port>\d{1,5}))?
3333 (?P<separator>[:,/])?
5353 rf"""
5454 ^{ RE_SCHEME }
5555 ://
56+ { RE_USER }
5657 { RE_PATH }
5758 { RE_SUFFIX } ?
5859 { RE_PIP_REV } ?
6667 pattern = re .compile (
6768 rf"""
6869 ^(?P<scheme>ssh)?
69- { SCP_REGEX }
70+ { RE_USER }
71+ { RE_SCP }
7072 { RE_SUFFIX } ?
7173 """ ,
7274 re .VERBOSE ,
100102 rf"""
101103 ^{ RE_PIP_SCHEME }
102104 ://
105+ { RE_USER }
103106 { RE_PATH }
104107 { RE_SUFFIX } ?
105108 { RE_PIP_REV } ?
Original file line number Diff line number Diff line change 2323from typing import Optional
2424
2525from libvcs ._internal .dataclasses import SkipDefaultFieldsReprMixin
26- from libvcs .url .git import RE_PIP_REV , SCP_REGEX
2726
2827from .base import Rule , RuleMap , URLProtocol
28+ from .constants import RE_PIP_REV , RE_SCP , RE_USER
2929
3030RE_PATH = r"""
31- ((?P<user>[^/:@]+)@)?
3231 (?P<hostname>([^/:@]+))
3332 (:(?P<port>\d{1,5}))?
3433 (?P<separator>[:,/])?
5655 rf"""
5756 ^{ RE_SCHEME }
5857 ://
58+ { RE_USER }
5959 { RE_PATH }
6060 { RE_PIP_REV } ?
6161 """ ,
6868 pattern = re .compile (
6969 rf"""
7070 ^(?P<scheme>ssh)?
71- { SCP_REGEX }
71+ { RE_USER }
72+ { RE_SCP }
7273 { RE_PIP_REV } ?
7374 """ ,
7475 re .VERBOSE ,
101102 rf"""
102103 ^{ RE_PIP_SCHEME }
103104 ://
105+ { RE_USER }
104106 { RE_PATH }
105107 { RE_PIP_REV } ?
106108 """ ,
You can’t perform that action at this time.
0 commit comments