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

Support GH enterprise #12863

Merged
merged 3 commits into from
Sep 21, 2020
Merged

Support GH enterprise #12863

merged 3 commits into from
Sep 21, 2020

Conversation

jolheiser
Copy link
Member

@jolheiser jolheiser commented Sep 15, 2020

I haven't had a chance to test with an instance of GH Enterprise, but I believe this should support it.

Unfortunately, the distinction made for the host is required because GH uses special URLs for their API

https://github.com/google/go-github/blob/dea2127aaa05fc2f42f9c137d87962f716e92414/github/github.go#L31-L32

However, from what I can tell, Enterprise should have sub-URLs 🤷‍♂️

https://github.com/google/go-github/blob/dea2127aaa05fc2f42f9c137d87962f716e92414/github/github.go#L301-L313

Giving it a sane base URL will cause the func to append the appropriate path

https://github.com/google/go-github/blob/dea2127aaa05fc2f42f9c137d87962f716e92414/github/github.go#L315-L339

Will fix #11815

Signed-off-by: jolheiser <john.olheiser@gmail.com>
@jolheiser jolheiser added the type/enhancement An improvement of existing functionality label Sep 15, 2020
@jolheiser jolheiser added this to the 1.13.0 milestone Sep 15, 2020
@GiteaBot GiteaBot added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Sep 15, 2020
Copy link
Member

@6543 6543 left a comment

Choose a reason for hiding this comment

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

had tested this change in the past, it didn't worked on my test GHE

@6543
Copy link
Member

6543 commented Sep 15, 2020

(cant test it now since I dont have this Test Instance anymore)

@@ -74,7 +75,7 @@ type GithubDownloaderV3 struct {
}

// NewGithubDownloaderV3 creates a github Downloader via github v3 API
func NewGithubDownloaderV3(ctx context.Context, userName, password, token, repoOwner, repoName string) *GithubDownloaderV3 {
func NewGithubDownloaderV3(ctx context.Context, baseURL, userName, password, token, repoOwner, repoName string) *GithubDownloaderV3 {
Copy link
Member

Choose a reason for hiding this comment

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

I think we could return with an error, so that we could know the error from NewEnterpriseClient

Copy link
Member Author

Choose a reason for hiding this comment

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

The only error that NewEnterpriseClient throws is when parsing the given URLs, which have already been parsed prior to this func being called.

Copy link
Member

Choose a reason for hiding this comment

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

So we assume NewEnterpriseClient will only return the parse error.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, and it never should because we've already asserted the URL is parsable prior to calling this.

I can handle the error if it would make us more comfortable for future maintaining, I just left it out since we shouldn't run in to it.

@codecov-commenter
Copy link

codecov-commenter commented Sep 17, 2020

Codecov Report

Merging #12863 into master will decrease coverage by 0.00%.
The diff coverage is 20.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #12863      +/-   ##
==========================================
- Coverage   43.07%   43.07%   -0.01%     
==========================================
  Files         658      658              
  Lines       72451    72454       +3     
==========================================
+ Hits        31211    31212       +1     
- Misses      36183    36185       +2     
  Partials     5057     5057              
Impacted Files Coverage Δ
modules/migrations/github.go 80.80% <20.00%> (-0.49%) ⬇️
modules/util/timer.go 42.85% <0.00%> (-42.86%) ⬇️
services/pull/check.go 44.61% <0.00%> (-3.08%) ⬇️
services/pull/pull.go 40.78% <0.00%> (ø)
modules/git/repo.go 46.70% <0.00%> (+0.50%) ⬆️
models/gpg_key.go 53.90% <0.00%> (+0.57%) ⬆️
modules/git/utils.go 77.04% <0.00%> (+3.27%) ⬆️
modules/indexer/stats/db.go 60.86% <0.00%> (+8.69%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2dbca92...037af0d. Read the comment docs.

@6543
Copy link
Member

6543 commented Sep 18, 2020

did someone test this patch sucessfully?

@coldcoff
Copy link

I can test as soon as I can download an executable with the code somewhere.

@zeripath told me #11815 (comment) that I can always get the lastest master to do that. And I did in #11815.

But this code in question here is not yet merged to master.

Is there some similar service building the PR branch executables, so that I can fetch an executable to test from there?

@6543
Copy link
Member

6543 commented Sep 20, 2020

@coldcoff if realy needed I can build the binary for you - witch OS & arch do you have?

@coldcoff
Copy link

coldcoff commented Sep 21, 2020

Played with it on the weekend (and yes: I was able to build this executable here for myself :-) )
This seems like a step in the right direction! Wonderful!

  • migration when "this is a mirror" is NOT ticked -> works, including releases, issues, pull requests. Seems complete.
    (I noted an aditional "approval" from my migration user, which is NOT there in the original PR, though. This is probably some different bug, unrelated to the subject here)

  • migration when "this is a mirror" IS ticked -> only working partially, it seems at least the pull requests are not migrated / mirrored then. This is required for my usecase :-(

Is the GitHub migration options expected to work on a mirror basis?

@jolheiser
Copy link
Member Author

Is the GitHub migration options expected to work on a mirror basis?

No, mirrors don't pull over any items except for code.
A mirror is periodically synced, so having PRs against one doesn't make much sense. (At least not with the current implementation)

Would you mind opening an issue with your use-case? Currently all mirror migrations work that way.

@coldcoff
Copy link

OK, without "this is a mirror" the migration from our GitHub Enterprise instance succeeded, see above!
Maybe grey the migration options out when "this is a mirror" is checked?

Will create a separate issue then for the other topic, thanks.

Copy link
Member

@6543 6543 left a comment

Choose a reason for hiding this comment

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

Worked as per @coldcoff

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Sep 21, 2020
@techknowlogick techknowlogick merged commit ec6a35a into go-gitea:master Sep 21, 2020
@lunny lunny added type/feature Completely new functionality. Can only be merged if feature freeze is not active. and removed type/enhancement An improvement of existing functionality labels Oct 14, 2020
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GitHub Migrations for Enterprise GitHub servers
8 participants