Skip to content

Commit 29e7546

Browse files
authored
Added api_base_path option for GitHub Enterprise compatibility (#983)
Added api_base_path option for GitHub Enterprise compatibility
2 parents 95e023e + a95081a commit 29e7546

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

binderhub/repoproviders.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,17 @@ class GitHubRepoProvider(RepoProvider):
496496
e.g. GitHub Enterprise.
497497
""")
498498

499+
api_base_path = Unicode('https://api.{hostname}',
500+
config=True,
501+
help="""The base path of the GitHub API
502+
503+
Only necessary if not github.com,
504+
e.g. GitHub Enterprise.
505+
506+
Can use {hostname} for substitution,
507+
e.g. 'https://{hostname}/api/v3'
508+
""")
509+
499510
client_id = Unicode(config=True,
500511
help="""GitHub client id for authentication with the GitHub API
501512
@@ -649,9 +660,9 @@ def get_resolved_ref(self):
649660
if hasattr(self, 'resolved_ref'):
650661
return self.resolved_ref
651662

652-
api_url = "https://api.{hostname}/repos/{user}/{repo}/commits/{ref}".format(
653-
user=self.user, repo=self.repo, ref=self.unresolved_ref,
654-
hostname=self.hostname,
663+
api_url = "{api_base_path}/repos/{user}/{repo}/commits/{ref}".format(
664+
api_base_path=self.api_base_path.format(hostname=self.hostname),
665+
user=self.user, repo=self.repo, ref=self.unresolved_ref
655666
)
656667
self.log.debug("Fetching %s", api_url)
657668
cached = self.cache.get(api_url)

0 commit comments

Comments
 (0)