File tree Expand file tree Collapse file tree 4 files changed +19
-6
lines changed Expand file tree Collapse file tree 4 files changed +19
-6
lines changed 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@'"""
Original file line number Diff line number Diff line change 2323from libvcs ._internal .dataclasses import SkipDefaultFieldsReprMixin
2424
2525from .base import Rule , RuleMap , URLProtocol
26+ from .constants import RE_USER
2627
2728# Credit, pip (license: MIT):
2829# https://github.com/pypa/pip/blob/22.1.2/src/pip/_internal/vcs/git.py#L39-L52
2930# We modified it to have groupings
3031SCP_REGEX = r"""
31- # Optional user, e.g. 'git@'
32- ((?P<user>\w+)@)?
3332 # Server, e.g. 'github.com'.
3433 (?P<hostname>([^/:]+))
3534 (?P<separator>:)
4039 """
4140
4241RE_PATH = r"""
43- ((?P<user>\w+)@)?
4442 (?P<hostname>([^/:]+))
4543 (:(?P<port>\d{1,5}))?
4644 (?P<separator>[:,/])?
6967 rf"""
7068 ^{ RE_SCHEME }
7169 ://
70+ { RE_USER }
7271 { RE_PATH }
7372 { RE_SUFFIX } ?
7473 """ ,
8382 pattern = re .compile (
8483 rf"""
8584 ^(?P<scheme>ssh)?
85+ { RE_USER }
8686 { SCP_REGEX }
8787 { RE_SUFFIX } ?
8888 """ ,
125125 (@(?P<rev>.*))
126126"""
127127
128-
129128PIP_DEFAULT_RULES : list [Rule ] = [
130129 Rule (
131130 label = "pip-url" ,
134133 rf"""
135134 { RE_PIP_SCHEME }
136135 ://
136+ { RE_USER }
137137 { RE_PATH }
138138 { RE_SUFFIX } ?
139139 { RE_PIP_REV } ?
148148 pattern = re .compile (
149149 rf"""
150150 { RE_PIP_SCP_SCHEME }
151+ { RE_USER }
151152 { SCP_REGEX } ?
152153 { RE_SUFFIX } ?
153154 { RE_PIP_REV } ?
Original file line number Diff line number Diff line change 2525from libvcs .url .git import RE_PIP_REV , RE_SUFFIX , SCP_REGEX
2626
2727from .base import Rule , RuleMap , URLProtocol
28+ from .constants import 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)?
70+ { RE_USER }
6971 { SCP_REGEX }
7072 { RE_SUFFIX } ?
7173 """ ,
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 2626from libvcs .url .git import RE_PIP_REV , SCP_REGEX
2727
2828from .base import Rule , RuleMap , URLProtocol
29+ from .constants import RE_USER
2930
3031RE_PATH = r"""
31- ((?P<user>[^/:@]+)@)?
3232 (?P<hostname>([^/:@]+))
3333 (:(?P<port>\d{1,5}))?
3434 (?P<separator>[:,/])?
5656 rf"""
5757 ^{ RE_SCHEME }
5858 ://
59+ { RE_USER }
5960 { RE_PATH }
6061 { RE_PIP_REV } ?
6162 """ ,
6869 pattern = re .compile (
6970 rf"""
7071 ^(?P<scheme>ssh)?
72+ { RE_USER }
7173 { SCP_REGEX }
7274 { RE_PIP_REV } ?
7375 """ ,
101103 rf"""
102104 ^{ RE_PIP_SCHEME }
103105 ://
106+ { RE_USER }
104107 { RE_PATH }
105108 { RE_PIP_REV } ?
106109 """ ,
You can’t perform that action at this time.
0 commit comments