Update how github users clone their own repos (#127)

This commit is contained in:
Jay Gabriels 2021-04-09 09:00:56 -07:00 committed by GitHub
parent 21d74481cd
commit 86bd64d955
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 11 deletions

View File

@ -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

View File

@ -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") {

View File

@ -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")
},
}

View File

@ -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:

View File

@ -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)