Skip to content

Preliminary support for GitHub Enterprise - #823

Closed
mislav wants to merge 1 commit into
trunkfrom
ghe-prototype
Closed

Preliminary support for GitHub Enterprise#823
mislav wants to merge 1 commit into
trunkfrom
ghe-prototype

Conversation

@mislav

@mislav mislav commented Apr 23, 2020

Copy link
Copy Markdown
Contributor

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 April 23, 2020 17:02
@mislav mislav changed the title Preliminary Enterprise support Preliminary support for GitHub Enterprise Apr 23, 2020

@tierninho tierninho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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''

@jgilchrist

jgilchrist commented Apr 28, 2020

Copy link
Copy Markdown

@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

tierninho commented Apr 29, 2020

Copy link
Copy Markdown
Contributor

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...

@tierninho

tierninho commented May 5, 2020

Copy link
Copy Markdown
Contributor

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

mislav commented May 6, 2020

Copy link
Copy Markdown
Contributor Author
  • 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
Copy Markdown
Contributor

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 11:41
@mislav mislav mentioned this pull request Jun 4, 2020
2 tasks
@mislav

mislav commented Jul 23, 2020

Copy link
Copy Markdown
Contributor Author

#1415

@mislav mislav closed this Jul 23, 2020
@mislav
mislav deleted the ghe-prototype branch July 23, 2020 20:51
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.

5 participants