Skip to content

Commit

Permalink
Update how github users clone their own repos (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrie30 authored Apr 9, 2021
1 parent 21d7448 commit 86bd64d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 9 additions & 5 deletions cmd/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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") {
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
},
}
2 changes: 1 addition & 1 deletion sample-conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
4 changes: 0 additions & 4 deletions scm/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 86bd64d

Please sign in to comment.