Skip to content

Commit 570d982

Browse files
committed
feat(parse,git): Use rev for branch / tag / ref
1 parent 37584e2 commit 570d982

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

libvcs/parse/git.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
(:(?P<port>\d{1,5}))?
3838
(?P<separator>[:,/])?
3939
(?P<path>
40-
(\w[^:.]*) # cut the path at . to negate .git
40+
(\w[^:.@]*) # cut the path at . to negate .git, @ from pip
4141
)?
4242
"""
4343

@@ -110,6 +110,10 @@
110110
)
111111
"""
112112

113+
RE_PIP_REV = r"""
114+
(@(?P<rev>.*))
115+
"""
116+
113117

114118
PIP_DEFAULT_MATCHERS: list[Matcher] = [
115119
Matcher(
@@ -121,6 +125,7 @@
121125
://
122126
{RE_PATH}
123127
{RE_SUFFIX}?
128+
{RE_PIP_REV}?
124129
""",
125130
re.VERBOSE,
126131
),
@@ -132,7 +137,8 @@
132137
rf"""
133138
{RE_PIP_SCP_SCHEME}
134139
{SCP_REGEX}?
135-
{RE_SUFFIX}
140+
{RE_SUFFIX}?
141+
{RE_PIP_REV}?
136142
""",
137143
re.VERBOSE,
138144
),
@@ -142,9 +148,10 @@
142148
label="pip-file-url",
143149
description="pip-style git+file:// URL",
144150
pattern=re.compile(
145-
r"""
151+
rf"""
146152
(?P<scheme>git\+file)://
147-
(?P<path>.*)
153+
(?P<path>[^@]*)
154+
{RE_PIP_REV}?
148155
""",
149156
re.VERBOSE,
150157
),
@@ -229,10 +236,6 @@ class GitURL(URLProtocol, SkipDefaultFieldsReprMixin):
229236
----------
230237
matcher : str
231238
name of the :class:`~libvcs.parse.base.Matcher`
232-
233-
branch : str, optional
234-
Default URL parsers don't output these,
235-
can be added by extending or passing manually
236239
"""
237240

238241
url: str
@@ -245,12 +248,8 @@ class GitURL(URLProtocol, SkipDefaultFieldsReprMixin):
245248
# Decoration
246249
suffix: Optional[str] = None
247250

248-
#
249-
# commit-ish: tag, branch, ref, revision
250-
#
251-
ref: Optional[str] = None
252-
branch: Optional[str] = None
253-
tag: Optional[str] = None
251+
# commit-ish (rev): tag, branch, ref
252+
rev: Optional[str] = None
254253

255254
matcher: Optional[str] = None
256255
matchers = MatcherRegistry = MatcherRegistry(

0 commit comments

Comments
 (0)