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

Add support for GH_HOST and GH_REPO environment variables #125

Closed
rastersize opened this issue Oct 28, 2024 · 4 comments · Fixed by #126
Closed

Add support for GH_HOST and GH_REPO environment variables #125

rastersize opened this issue Oct 28, 2024 · 4 comments · Fixed by #126

Comments

@rastersize
Copy link

rastersize commented Oct 28, 2024

Description
gh supports setting the GitHub host and repo slug that should be used via the GH_HOST and GH_REPO environment variables. It would be great if gh-poi could add support for these.

Additional context
I interact with a GitHub Enterprise installation where the Git remote use a proxy, instead of the GitHub Enterprise domain. This makes gh fail as it expects it to also be the GitHub host. To overcome this we can set the GH_HOST and GH_REPO environment variables. Which works great with gh itself.

Unfortunately gh-poi fails as it doesn’t seem to read those environment values.

Given a remote.origin.url of https://git.enterprise.com/foo/bar where GitHub Enterprise is hosted ad github.enterprise.com:

$ GH_HOST="github.enterprise.com" GH_REPO="foo/bar" gh pr list
[Shows a list of PRs]

$ GH_HOST="github.enterprise.com" GH_REPO="foo/bar" gh poi
✕ Fetching pull requests...
failed to run external command: gh, args: [repo view git.enterprise.com/foo/bar --json owner,name,parent,defaultBranchRef]
 exit status 1

Thank you!

@seachicken
Copy link
Owner

Thanks for the good point! gh-poi's policy is to get as close as possible to the gh specifications, so it would be good to support it.
This code determines the host, so it looks like it will need to be overwritten with GH_HOST variable.
However, gh-poi will not work correctly unless the local git information in the current directory where it is executed and the remote GitHub information are the same, so overwriting with GH_REPO may be problematic in some cases.

@seachicken seachicken linked a pull request Nov 3, 2024 that will close this issue
@seachicken
Copy link
Owner

I've tried to override the hostname with the GH_HOST environment variable. Does this work in your environment?
Please try it if you like:

gh ext remove poi
gh ext install seachicken/gh-poi --pin v0.11.0-pre0

@rastersize
Copy link
Author

@seachicken It works, thank you so much!

@seachicken
Copy link
Owner

Thanks for checking! I've just released it.

You can remove the version pinning and install the latest version:

gh ext remove poi
gh ext install seachicken/gh-poi

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 a pull request may close this issue.

2 participants