Skip to content

Commit a95081a

Browse files
committed
Added api_base_path option for GitHub Enterprise compatibility. #issue-972
1 parent a168d06 commit a95081a

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
@@ -434,6 +434,17 @@ class GitHubRepoProvider(RepoProvider):
434434
e.g. GitHub Enterprise.
435435
""")
436436

437+
api_base_path = Unicode('https://api.{hostname}',
438+
config=True,
439+
help="""The base path of the GitHub API
440+
441+
Only necessary if not github.com,
442+
e.g. GitHub Enterprise.
443+
444+
Can use {hostname} for substitution,
445+
e.g. 'https://{hostname}/api/v3'
446+
""")
447+
437448
client_id = Unicode(config=True,
438449
help="""GitHub client id for authentication with the GitHub API
439450
@@ -580,9 +591,9 @@ def get_resolved_ref(self):
580591
if hasattr(self, 'resolved_ref'):
581592
return self.resolved_ref
582593

583-
api_url = "https://api.{hostname}/repos/{user}/{repo}/commits/{ref}".format(
584-
user=self.user, repo=self.repo, ref=self.unresolved_ref,
585-
hostname=self.hostname,
594+
api_url = "{api_base_path}/repos/{user}/{repo}/commits/{ref}".format(
595+
api_base_path=self.api_base_path.format(hostname=self.hostname),
596+
user=self.user, repo=self.repo, ref=self.unresolved_ref
586597
)
587598
self.log.debug("Fetching %s", api_url)
588599
cached = self.cache.get(api_url)

0 commit comments

Comments
 (0)