Visitar URL original
Preliminary support for GitHub Enterprise by mislav · Pull Request #823 · cli/cli · GitHub
The Wayback Machine - https://web.archive.org/web/20200529203116/https://github.com/cli/cli/pull/823
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

Preliminary support for GitHub Enterprise #823

Draft
wants to merge 1 commit into
base: trunk
from
Draft

Preliminary support for GitHub Enterprise #823

wants to merge 1 commit into from

Conversation

@mislav
Copy link
Member

mislav commented Apr 23, 2020 •

This is a rough code spike to explore GitHub Enterprise compatibility. The experience in this branch isn't very user-friendly yet: you have to manually juggle your config files and you have to set the GITHUB_HOST environment variable to your GHE hostname while testing (i.e. the Enterprise hostname will not get automatically picked up from your existing git remotes). But, it works!

How to test:

  • backup your old config: cp ~/.config/gh/config.yml{,.bak}
  • clear the config file rm ~/.config/gh/config.yml
  • set export GITHUB_HOST=ghe.example.com to your GHE hostname
  • build gh with make
  • run a bin/gh command
  • restore your old config when done testing this branch mv ~/.config/gh/config.yml{.bak,}

Ref. #273

How to test:
- backup your old config: `cp ~/.config/gh/config.yml{,.bak}`
- clear the config `rm ~/.config/gh/config.yml`
- set `export GITHUB_HOST=ghe.example.com` to your GHE hostname
- run a `gh` command
- clear the config again when done testing `rm ~/.config/gh/config.yml`
@mislav mislav requested a review from tierninho Apr 23, 2020
@mislav mislav changed the title Preliminary Enterprise support Preliminary support for GitHub Enterprise Apr 23, 2020
@mislav mislav added this to In progress 🚧 in The GitHub CLI Apr 23, 2020
Copy link
Contributor

tierninho left a comment

Thanks for the setup instructions! I ran through the following commands and set the host to our internal GHE host and was authenticated properly ✅. The host is also present in the config file. ✅

run a gh command

I did place bin/ in front of each command and was able to access the repo on the GHE host ✅ and executive a few gh commands successfully.

Note, I was blocked on a few commands like this, which I believe is expected given the infancy of the things. Let me know if otherwise, or if I missed anything.

➜  cli git:(ghe-prototype) bin/gh pr list -R tierninho/Blah
graphql error: 'Field 'isDraft' doesn't exist on type 'PullRequest''
The GitHub CLI automation moved this from In progress 🚧 to Needs to be merged 🎉 Apr 23, 2020
@jgilchrist
Copy link

jgilchrist commented Apr 28, 2020 •

@mislav I cherry picked this onto master - authentication worked well, but running any commands gave me the following error:

no git remote found for a github.com repository

The following patch fixes this for me:

diff --git i/internal/ghrepo/repo.go w/internal/ghrepo/repo.go
index dc3115b..f7e745c 100644
--- i/internal/ghrepo/repo.go
+++ w/internal/ghrepo/repo.go
@@ -3,11 +3,18 @@ package ghrepo
 import (
    "fmt"
    "net/url"
+   "os"
    "strings"
 )

 // TODO these are sprinkled across command, context, config, and ghrepo
-const defaultHostname = "github.com"
+var defaultHostname = "github.com"
+
+func init() {
+   if gheHostname := os.Getenv("GITHUB_HOST"); gheHostname != "" {
+       defaultHostname = gheHostname
+   }
+}

 // Interface describes an object that represents a GitHub repository
 type Interface interface {
@tierninho
Copy link
Contributor

tierninho commented Apr 29, 2020 •

Tested on GitHub Enterprise Server 2.20.6. OSX.

A first sweep of testing the gh commands yielded mixed results:

What was tested:

PASS

  • gh completion -s [shell]
  • gh help
  • gh help [command]
  • gh issue create, -R
  • gh issue status
  • gh issue view [number], -w -R
  • gh issue list, -a -l -L -s -R

FAIL

  • gh pr list/status/create = FAIL as they result in: graphql error: 'Field 'isDraft' doesn't exist on type 'PullRequest''
  • gh pr create, -w = FAIL as it took me to GitHub.com. Note I used -R as well.
  • gh issue create, -w = FAIL as it took me to GitHub.com. Note I used -R as well.

What I couldn’t test for the time being

  • gh repo as it requires a username/pw and we currently login into GHE via Okta only so I don't know what the credentials are. It is a good sign it is asking for GHE credentials though.
  • gh config git_protocol, as I cannot test due to above

--

2.19 tests in progress...

@mislav mislav moved this from Needs to be merged 🎉 to In progress 🚧 in The GitHub CLI May 4, 2020
@tierninho
Copy link
Contributor

tierninho commented May 5, 2020 •

and here are the results on: GHE Version 2.19.12 a099171, OSX. More tests passed only because I had access to the login credentials after using ghe-boot to set up my own instance.

What was tested:

PASS

  • gh completion -s [shell]
  • gh help
  • gh help [command]
  • gh issue create, -R
  • gh issue status
  • gh issue view [number], -w -R
  • gh issue list, -a -A -l -L -s -R
  • gh repo create
  • gh repo view
  • gh repo clone
  • gh repo fork
  • gh config works, but had some minor issues with SSH that I need to resolve. SSH should be for both GHE and GH?

FAIL

  • gh pr list/status/create = FAIL as they result in: graphql error: 'Field 'isDraft' doesn't exist on type 'PullRequest''
  • gh pr create, -w = FAIL as it took me to GitHub.com. Note I used -R as well.
  • gh issue create, -w = FAIL as it took me to GitHub.com. Note I used -R as well.
  • gh repo view. -w = FAIL as it took me to GitHub.com. Note I used -R as well.
@mislav
Copy link
Member Author

mislav commented May 6, 2020

  • gh config works, but had some minor issues with SSH that I need to resolve. SSH should be for both GHE and GH?

If you use gh config set git_protocol ssh, that git protocol should be used for both GHE and github.com. If that's not the case, it's a bug and we should look into that!

  • gh pr create, -w = FAIL as it took me to GitHub.com. Note I used -R as well.

I think is something we could fix easily, perhaps by applying @jgilchrist's patch above.

@tierninho
Copy link
Contributor

tierninho commented May 6, 2020

If you use gh config set git_protocol ssh, that git protocol should be used for both GHE and github.com. If that's not the case, it's a bug and we should look into that!

Got it working ⚡ after resolving a password issue.

@mislav mislav changed the base branch from master to trunk May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
The GitHub CLI
  
In progress 🚧
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.