mirror of
https://github.com/outbackdingo/ghorg.git
synced 2026-01-27 10:19:03 +00:00
Add support for cloning github enterprise repos (#169)
This commit is contained in:
@@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
||||
### Added
|
||||
- GHORG_DRY_RUN to do dry runs on clones
|
||||
- output for long running repo fetches
|
||||
- support for cloning github enterprise repos
|
||||
### Changed
|
||||
- go-github versions v32 -> v41
|
||||
### Deprecated
|
||||
|
||||
@@ -102,6 +102,7 @@ $ ghorg ls someorg
|
||||
|
||||
### github setup
|
||||
1. Create [Personal Access Token](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line) with all `repo` scopes. Update `GHORG_GITHUB_TOKEN` in your `ghorg/conf.yaml`, as a cli flag, or add to your [osx keychain](https://help.github.com/en/github/using-git/caching-your-github-password-in-git). If your org has Saml SSO in front you will need to give your token those permissions as well, see [this doc](https://docs.github.com/en/github/authenticating-to-github/authenticating-with-saml-single-sign-on/authorizing-a-personal-access-token-for-use-with-saml-single-sign-on).
|
||||
1. For cloning GitHub Enterprise repos you must set `--base-url` e.g. `ghorg clone <github_org> --base-url=https://internal.github.com`
|
||||
|
||||
### gitlab setup
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# GitHub Cloud
|
||||
|
||||
clone a **users** repos
|
||||
|
||||
```
|
||||
@@ -15,3 +17,23 @@ clone all repos from a **github org** that are **prefixed** with "frontend" **in
|
||||
```
|
||||
$ ghorg clone <github_org> --match-regex=^frontend --output-dir=design_only
|
||||
```
|
||||
|
||||
# GitHub Enterprise
|
||||
|
||||
clone a **users** repos
|
||||
|
||||
```
|
||||
$ ghorg clone <github_username> --clone-type=user --base-url=https://internal.github.com
|
||||
```
|
||||
|
||||
clone an **org**
|
||||
|
||||
```
|
||||
$ ghorg clone <github_org> --base-url=https://internal.github.com
|
||||
```
|
||||
|
||||
clone all repos from a **github org** that are **prefixed** with "frontend" **into a folder** called "design_only"
|
||||
|
||||
```
|
||||
$ ghorg clone <github_org> --match-regex=^frontend --output-dir=design_only --base-url=https://internal.github.com
|
||||
```
|
||||
|
||||
@@ -32,9 +32,6 @@ func (_ Github) GetType() string {
|
||||
|
||||
// GetOrgRepos gets org repos
|
||||
func (c Github) GetOrgRepos(targetOrg string) ([]Repo, error) {
|
||||
if os.Getenv("GHORG_SCM_BASE_URL") != "" {
|
||||
c.BaseURL, _ = url.Parse(os.Getenv("GHORG_SCM_BASE_URL"))
|
||||
}
|
||||
|
||||
opt := &github.RepositoryListByOrgOptions{
|
||||
Type: "all",
|
||||
@@ -120,7 +117,15 @@ func (_ Github) NewClient() (Client, error) {
|
||||
&oauth2.Token{AccessToken: os.Getenv("GHORG_GITHUB_TOKEN")},
|
||||
)
|
||||
tc := oauth2.NewClient(ctx, ts)
|
||||
c := github.NewClient(tc)
|
||||
|
||||
baseURL := os.Getenv("GHORG_SCM_BASE_URL")
|
||||
var c *github.Client
|
||||
|
||||
if baseURL != "" {
|
||||
c, _ = github.NewEnterpriseClient(baseURL, baseURL, tc)
|
||||
} else {
|
||||
c = github.NewClient(tc)
|
||||
}
|
||||
|
||||
client := Github{Client: c, perPage: 100}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user