gruntwork-io / git-xargs

git-xargs is a command-line tool (CLI) for making updates across multiple Github repositories with a single command.
https://blog.gruntwork.io/introducing-git-xargs-an-open-source-tool-to-update-multiple-github-repos-753f9f3675ec
Apache License 2.0
948 stars 61 forks source link

Add support for Github enterprise instances #5

Closed zackproser closed 1 year ago

zackproser commented 3 years ago

Related: https://github.com/gruntwork-io/fetch/pull/43

ejstreet commented 3 years ago

Would adding baseUrl support be enough to work with other git providers? (e.g. Gitlab)

zackproser commented 3 years ago

Hi @ejstreet,

Thanks for the great question. Git-xargs grew organically out of an internal tool at Gruntwork, where we exclusively use Github, so the tool currently pre-supposes Github as the version control system for opening PRs.

So, I think adding support for additional git providers would be a bit more involved. One initial thought about approaching this is that we could create an interface for a version control provider. For example, the interface would have a method like OpenPullRequest and then we could create a concrete implementation for Github, Gitlab, etc and provide additional CLI flags and fallback behavior for choosing which VCS provider to use at runtime.

We might also consider implementing a config file and syntax for it if we go down that route. That all said, it sounds like discussion might be better split into a new ticket specifically about adding support for other version control providers like Gitlab, Bitbucket, etc (whereas this ticket is about supporting Github enterprise instances.)

I have an internal backlog of git-xargs issues I still need to migrate to this repo, so I will open one there (or you could feel free to open a new ticket specifically for supporting other version control providers).

Thanks!

jpmontez commented 3 years ago

I ran into this issue as well. Until there's a robust solution, this worked for me in GitHub Enterprise.

diff --git a/auth/auth.go b/auth/auth.go
index 73ac8c0..b07d8ac 100644
--- a/auth/auth.go
+++ b/auth/auth.go
@@ -52,7 +52,8 @@ func ConfigureGithubClient() GithubClient {
    tc := oauth2.NewClient(context.Background(), ts)

    // Wrap the go-github client in a GithubClient struct, which is common between production and test code
-   client := NewClient(github.NewClient(tc))
+   _client, _ := github.NewEnterpriseClient("https://${INSERT_BASE_URL_HERE}/api/v3/", "${INSERT_BASE_URL_HERE}/api/v3/upload", tc)
+   client := NewClient(_client)

    return client
 }
nwsparks commented 2 years ago

Any chance of this being added? Would love to use this tool, but stuck on Enterprise.

CodeYogiCo commented 2 years ago

does it still no exit fot github enterprise?

zackproser commented 1 year ago

Closing as I'm no longer working at Gruntwork and this issue is stale. If someone would like to pick up this work, please open a new issue to discuss it with the team and propose a pull request.