@@ -99,6 +99,10 @@ class RepoProvider(LoggingConfigurable):
9999 config = True ,
100100 )
101101
102+ # Not a traitlet because the class property is serialised in
103+ # config.ConfigHandler.generate_config()
104+ regex_detect = None
105+
102106 unresolved_ref = Unicode ()
103107
104108 git_credentials = Unicode (
@@ -192,6 +196,15 @@ def is_valid_sha1(sha1):
192196class FakeProvider (RepoProvider ):
193197 """Fake provider for local testing of the UI"""
194198
199+ name = Unicode ("Fake" )
200+
201+ display_name = "Fake GitHub"
202+
203+ regex_detect = [
204+ r"^https://github\.com/(?<repo>[^/]+/[^/]+)(/blob/(?<ref>[^/]+)(/(?<filepath>.+))?)?$" ,
205+ r"^https://github\.com/(?<repo>[^/]+/[^/]+)(/tree/(?<ref>[^/]+)(/(?<urlpath>.+))?)?$" ,
206+ ]
207+
195208 labels = {
196209 "text" : "Fake Provider" ,
197210 "tag_text" : "Fake Ref" ,
@@ -627,6 +640,13 @@ def _default_git_credentials(self):
627640 return rf"username=binderhub\npassword={ self .private_token } "
628641 return ""
629642
643+ # Gitlab repos can be nested under projects
644+ _regex_detect_base = r"^https://gitlab\.com/(?<repo>[^/]+/[^/]+(/[^/-][^/]+)*)"
645+ regex_detect = [
646+ _regex_detect_base + r"(/-/blob/(?<ref>[^/]+)(/(?<filepath>.+))?)?$" ,
647+ _regex_detect_base + r"(/-/tree/(?<ref>[^/]+)(/(?<urlpath>.+))?)?$" ,
648+ ]
649+
630650 labels = {
631651 "text" : "GitLab.com repository or URL" ,
632652 "tag_text" : "Git ref (branch, tag, or commit)" ,
@@ -780,6 +800,11 @@ def _default_git_credentials(self):
780800 return rf"username={ self .access_token } \npassword=x-oauth-basic"
781801 return ""
782802
803+ regex_detect = [
804+ r"^https://github\.com/(?<repo>[^/]+/[^/]+)(/blob/(?<ref>[^/]+)(/(?<filepath>.+))?)?$" ,
805+ r"^https://github\.com/(?<repo>[^/]+/[^/]+)(/tree/(?<ref>[^/]+)(/(?<urlpath>.+))?)?$" ,
806+ ]
807+
783808 labels = {
784809 "text" : "GitHub repository name or URL" ,
785810 "tag_text" : "Git ref (branch, tag, or commit)" ,
@@ -973,6 +998,10 @@ class GistRepoProvider(GitHubRepoProvider):
973998 help = "Flag for allowing usages of secret Gists. The default behavior is to disallow secret gists." ,
974999 )
9751000
1001+ regex_detect = [
1002+ r"^https://gist\.github\.com/(?<repo>[^/]+/[^/]+)(/(?<ref>[^/]+))?$"
1003+ ]
1004+
9761005 labels = {
9771006 "text" : "Gist ID (username/gistId) or URL" ,
9781007 "tag_text" : "Git commit SHA" ,
0 commit comments