Skip to content

Commit 2e11591

Browse files
committed
docs,tests(parse,base): Cleanup and fixes
1 parent 2e3792a commit 2e11591

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

libvcs/parse/base.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,17 @@ def register(self, cls: Matcher) -> None:
5959
But what if you wanted to do ``github:org/repo``?
6060
6161
>>> GitURL.is_valid(url="github:org/repo")
62-
False
62+
True
63+
64+
That actually works, but look, it's caught in git's standard SCP regex:
65+
66+
>>> GitURL(url="github:org/repo")
67+
GitURL(url=github:org/repo,
68+
hostname=github,
69+
path=org/repo,
70+
matcher=core-git-scp)
71+
72+
We need something more specific. What do we do?
6373
6474
**Extending matching capability:**
6575
@@ -84,6 +94,17 @@ def register(self, cls: Matcher) -> None:
8494
>>> GitHubLocation.is_valid(url='gitlab:vcs-python/libvcs')
8595
False
8696
97+
`GitHubLocation` sees this as invalid since it only has one matcher,
98+
`GitHubPrefix`.
99+
100+
>>> GitURL.is_valid(url='gitlab:vcs-python/libvcs')
101+
True
102+
103+
Same story, getting caught in ``git(1)``'s own liberal scp-style URL:
104+
105+
>>> GitURL(url='gitlab:vcs-python/libvcs').matcher
106+
'core-git-scp'
107+
87108
>>> class GitLabPrefix(Matcher):
88109
... label = 'gl-prefix'
89110
... description ='Matches prefixes like gitlab:org/repo'
@@ -108,7 +129,14 @@ def register(self, cls: Matcher) -> None:
108129
Option 2 (global, everywhere): Add to the global :class:`GitURL`:
109130
110131
>>> GitURL.is_valid(url='gitlab:vcs-python/libvcs')
111-
False
132+
True
133+
134+
Are we home free, though? Remember our issue with vague matches.
135+
136+
>>> GitURL(url='gitlab:vcs-python/libvcs').matcher
137+
'core-git-scp'
138+
139+
Register:
112140
113141
>>> GitURL.matchers.register(GitLabPrefix)
114142

0 commit comments

Comments
 (0)