From da4ac382bc5bcbd52057ed8c4a38d60ea7823cc6 Mon Sep 17 00:00:00 2001 From: Jay Gabriels Date: Sun, 17 Apr 2022 17:51:53 -0700 Subject: [PATCH] Update github scm to know when user is cloning own repos (#201) --- CHANGELOG.md | 11 ++++++++++- cmd/clone.go | 2 +- cmd/version.go | 2 +- scm/github.go | 10 +++++++++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e8a084..087a320 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) -## [1.7.13] - unreleased +## [1.7.14] - Unreleased ### Added ### Changed ### Deprecated @@ -11,6 +11,15 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) ### Fixed ### Security +## [1.7.13] - 4/17/22 +### Added +### Changed +### Deprecated +### Removed +### Fixed +- User cloning self on github now finds all public/private repos; thanks @iDoka +### Security + ## [1.7.12] - 5/19/22 ### Added - Dockerfile diff --git a/cmd/clone.go b/cmd/clone.go index 00bd180..7f2e97d 100644 --- a/cmd/clone.go +++ b/cmd/clone.go @@ -422,7 +422,7 @@ func CloneAllRepos(git git.Gitter, cloneTargets []scm.Repo) { os.Exit(1) } - colorlog.PrintInfo("Using ghorgignore, filtering repos down...\n") + colorlog.PrintInfo("\nUsing ghorgignore, filtering repos down...\n") filteredCloneTargets := []scm.Repo{} var flag bool diff --git a/cmd/version.go b/cmd/version.go index faed24f..6e34d15 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -11,6 +11,6 @@ var versionCmd = &cobra.Command{ Short: "Print the version number of Ghorg", Long: `All software has versions. This is Ghorg's`, Run: func(cmd *cobra.Command, args []string) { - fmt.Println("v1.7.12") + fmt.Println("v1.7.13") }, } diff --git a/scm/github.go b/scm/github.go index 50d3f2a..07912a4 100644 --- a/scm/github.go +++ b/scm/github.go @@ -53,7 +53,7 @@ func (c Github) GetOrgRepos(targetOrg string) ([]Repo, error) { } if opt.Page%12 == 0 && opt.Page != 0 { - colorlog.PrintSubtleInfo("Everything is okay, its just a lot of repos...") + colorlog.PrintSubtleInfo("\nEverything is okay, the org just has a lot of repos...") } opt.Page = resp.NextPage } @@ -63,6 +63,14 @@ func (c Github) GetOrgRepos(targetOrg string) ([]Repo, error) { // GetUserRepos gets user repos func (c Github) GetUserRepos(targetUser string) ([]Repo, error) { + + userToken, _, _ := c.Users.Get(context.Background(), "") + + if targetUser == userToken.GetLogin() { + colorlog.PrintSubtleInfo("\nCloning all your public/private repos. This process may take a bit longer than other clones, please be patient...") + targetUser = "" + } + if os.Getenv("GHORG_SCM_BASE_URL") != "" { c.BaseURL, _ = url.Parse(os.Getenv("GHORG_SCM_BASE_URL")) }