Skip to content

Commit

Permalink
Added api_base_path option for GitHub Enterprise compatibility. #issu…
Browse files Browse the repository at this point in the history
…e-972
  • Loading branch information
ivan-gomes committed Oct 23, 2019
1 parent a168d06 commit a95081a
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions binderhub/repoproviders.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,17 @@ class GitHubRepoProvider(RepoProvider):
e.g. GitHub Enterprise.
""")

api_base_path = Unicode('https://api.{hostname}',
config=True,
help="""The base path of the GitHub API
Only necessary if not github.com,
e.g. GitHub Enterprise.
Can use {hostname} for substitution,
e.g. 'https://{hostname}/api/v3'
""")

client_id = Unicode(config=True,
help="""GitHub client id for authentication with the GitHub API
Expand Down Expand Up @@ -580,9 +591,9 @@ def get_resolved_ref(self):
if hasattr(self, 'resolved_ref'):
return self.resolved_ref

api_url = "https://api.{hostname}/repos/{user}/{repo}/commits/{ref}".format(
user=self.user, repo=self.repo, ref=self.unresolved_ref,
hostname=self.hostname,
api_url = "{api_base_path}/repos/{user}/{repo}/commits/{ref}".format(
api_base_path=self.api_base_path.format(hostname=self.hostname),
user=self.user, repo=self.repo, ref=self.unresolved_ref
)
self.log.debug("Fetching %s", api_url)
cached = self.cache.get(api_url)
Expand Down

0 comments on commit a95081a

Please sign in to comment.