@@ -59,7 +59,17 @@ def register(self, cls: Matcher) -> None:
59
59
But what if you wanted to do ``github:org/repo``?
60
60
61
61
>>> 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?
63
73
64
74
**Extending matching capability:**
65
75
@@ -84,6 +94,17 @@ def register(self, cls: Matcher) -> None:
84
94
>>> GitHubLocation.is_valid(url='gitlab:vcs-python/libvcs')
85
95
False
86
96
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
+
87
108
>>> class GitLabPrefix(Matcher):
88
109
... label = 'gl-prefix'
89
110
... description ='Matches prefixes like gitlab:org/repo'
@@ -108,7 +129,14 @@ def register(self, cls: Matcher) -> None:
108
129
Option 2 (global, everywhere): Add to the global :class:`GitURL`:
109
130
110
131
>>> 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:
112
140
113
141
>>> GitURL.matchers.register(GitLabPrefix)
114
142
0 commit comments