Skip to content

Commit

Permalink
Fix github enterprise api url (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
roomedia authored Feb 28, 2024
1 parent 8f9608a commit 3ec875f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
7 changes: 6 additions & 1 deletion ghstack/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,13 @@ def read_config(
if config.has_option("ghstack", "github_username"):
github_username = config.get("ghstack", "github_username")
if github_username is None and github_oauth is not None:
request_url: str
if "{github_url}" == "github.com":
request_url = f"https://api.{github_url}/user"
else:
request_url = f"https://{github_url}/api/v3/user"
res = requests.get(
f"https://api.{github_url}/user",
request_url,
headers={
"Accept": "application/vnd.github+json",
"Authorization": f"Bearer {github_oauth}",
Expand Down
12 changes: 10 additions & 2 deletions ghstack/github_real.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,19 @@ class RealGitHubEndpoint(ghstack.github.GitHubEndpoint):
"""

# The URL of the GraphQL endpoint to connect to
graphql_endpoint: str = "https://api.{github_url}/graphql"
graphql_endpoint: str
if "{github_url}" == "github.com":
graphql_endpoint = "https://api.{github_url}/graphql"
else:
graphql_endpoint = "https://{github_url}/api/graphql"

# The base URL of the REST endpoint to connect to (all REST requests
# will be subpaths of this URL)
rest_endpoint: str = "https://api.{github_url}"
rest_endpoint: str
if "{github_url}" == "github.com":
rest_endpoint = "https://api.{github_url}"
else:
rest_endpoint = "https://{github_url}/api/v3"

# The base URL of regular WWW website, in case we need to manually
# interact with the real website
Expand Down

0 comments on commit 3ec875f

Please sign in to comment.