From 86bd64d9558463fec85efcf848ad1f8f03e9c267 Mon Sep 17 00:00:00 2001 From: Jay Gabriels Date: Fri, 9 Apr 2021 09:00:56 -0700 Subject: [PATCH] Update how github users clone their own repos (#127) --- CHANGELOG.md | 10 ++++++++++ cmd/clone.go | 14 +++++++++----- cmd/version.go | 2 +- sample-conf.yaml | 2 +- scm/github.go | 4 ---- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cea7df1b..f37b956f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ 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.6.0] - 4/9/21 +### Added +### Changed +- how github users clone their own repos thanks @dword-design +### Deprecated +### Removed +### Fixed +### Security + ## [1.5.2] - 4/5/21 ### Added - ghorg clone me to clone all of your own private repos from github diff --git a/cmd/clone.go b/cmd/clone.go index a39dec72..e976ec9f 100644 --- a/cmd/clone.go +++ b/cmd/clone.go @@ -82,11 +82,6 @@ func cloneFunc(cmd *cobra.Command, argz []string) { } - if len(argz) < 1 { - colorlog.PrintError("You must provide an org or user to clone") - os.Exit(1) - } - if cmd.Flags().Changed("path") { absolutePath := ensureTrailingSlash(cmd.Flag("path").Value.String()) os.Setenv("GHORG_ABSOLUTE_PATH_TO_CLONE_TO", absolutePath) @@ -156,6 +151,15 @@ func cloneFunc(cmd *cobra.Command, argz []string) { os.Setenv("GHORG_OUTPUT_DIR", d) } + if len(argz) < 1 { + if os.Getenv("GHORG_SCM_TYPE") == "github" && os.Getenv("GHORG_CLONE_TYPE") == "user" { + argz = append(argz, "") + } else { + colorlog.PrintError("You must provide an org or user to clone") + os.Exit(1) + } + } + configs.GetOrSetToken() if cmd.Flags().Changed("token") { diff --git a/cmd/version.go b/cmd/version.go index 52da627f..14596f62 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -15,6 +15,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("1.5.2") + fmt.Println("1.6.0") }, } diff --git a/sample-conf.yaml b/sample-conf.yaml index d97b450e..c0670ba7 100644 --- a/sample-conf.yaml +++ b/sample-conf.yaml @@ -77,7 +77,7 @@ GHORG_BRANCH: # Type of entity to clone (user or org) # default: org -# to clone all of your own repos from github use "ghorg clone me --clone-type=user" +# to clone all of your own repos from github don't specify any user eg. "ghorg clone --clone-type=user" # flag (--clone-type, -c) GHORG_CLONE_TYPE: diff --git a/scm/github.go b/scm/github.go index 2b42ae21..d7c8ded4 100644 --- a/scm/github.go +++ b/scm/github.go @@ -80,10 +80,6 @@ func (c Github) GetUserRepos(targetUser string) ([]Repo, error) { for { - if targetUser == "me" { - targetUser = "" - } - // List the repositories for a user. Passing the empty string will list repositories for the authenticated user. repos, resp, err := c.Repositories.List(context.Background(), targetUser, opt)