Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle URLs from GitHub Enterprise managed orgs #2098

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jameslairdsmith
Copy link

My organisation recently set itself up on a managed GitHub Enterprise organisation. Our new URL is of the form "https://my-cool-org.ghe.com". This PR makes the changes required for usethis to recognise this kind of URL as a GitHub one and parse it to find the appropriate API URL, which is of the form "https://api.my-cool-org.ghe.com".

My immediate use case was trying usethis::use_pkgdown_github_pages() and I can confirm that this function now works with the proposed changes.

Fixed checks to include URLs with "ghe" not just
github.com.

Fixes URL parser to provide API URLs of the form
assigned to GitHub Enterprise managed
organisations.
is_github_enterprise <- function(url) {
url <- get_baseurl(url)
url <- normalize_host(url)
grepl("ghe.com$", url)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have any concrete info on how universally this applies to GHE? Like, is this scheme for the hostname forced on you or is it a default or recommended? I've long wanted to better account for GHE and dragged my feet due to my perception that this could be anything.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, in #1897, the host is ghe-gsk-prod.metworx.com. So I am inclined to believe that full GHE support will need to make this configurable.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't stand-up the environment, so I can't be 100% certain, but my understanding is the following.

  1. Those using the Free, Pro and Team versions of GitHub will use "api.github.com" as normal.
  2. Those using GitHub Enterprise Cloud will use "api.SUBDOMAIN.ghe.com".
  3. Those using GitHub Enterprise Server will be self-hosting and so their API URL can be anything (as I assume is happening in the example of github_remote_list() not picking up GHE host #1897 above).

To confirm item (2) above, you can have a look at this page in the GitHub API documentation which says the following in the first section:

If you access GitHub at GHE.com, replace api.github.com with your enterprise's dedicated subdomain at api.SUBDOMAIN.ghe.com.

If that's true, then you are correct in that the changes in this PR don't amount to full GHE support, because they don't account for self-hosted GitHub Enterprise server. And I agree that the only way to properly account for it would be to make it configurable. But it does feel to me like "ghe.com" is standard enough that it would be nice to account for it automatically without users having to set their own environment variable. Allowing a configurable override would of course be a sensible next step.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the extra info! So I gather that you have GitHub Enterprise Cloud? It does seems like accomodating that would be considerably easier than full configurability. I'm about to be travelling, but I'll come back and review this PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I gather that you have GitHub Enterprise Cloud?

That's correct yes.

I'm about to be travelling, but I'll come back and review this PR.

Safe travels! And thanks for the prompt response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants