Skip to content

Commit 86bd64d

Browse files
authoredApr 9, 2021
Update how github users clone their own repos (#127)
1 parent 21d7448 commit 86bd64d

File tree

5 files changed

+21
-11
lines changed

5 files changed

+21
-11
lines changed
 

‎CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5+
6+
## [1.6.0] - 4/9/21
7+
### Added
8+
### Changed
9+
- how github users clone their own repos thanks @dword-design
10+
### Deprecated
11+
### Removed
12+
### Fixed
13+
### Security
14+
515
## [1.5.2] - 4/5/21
616
### Added
717
- ghorg clone me to clone all of your own private repos from github

‎cmd/clone.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,6 @@ func cloneFunc(cmd *cobra.Command, argz []string) {
8282

8383
}
8484

85-
if len(argz) < 1 {
86-
colorlog.PrintError("You must provide an org or user to clone")
87-
os.Exit(1)
88-
}
89-
9085
if cmd.Flags().Changed("path") {
9186
absolutePath := ensureTrailingSlash(cmd.Flag("path").Value.String())
9287
os.Setenv("GHORG_ABSOLUTE_PATH_TO_CLONE_TO", absolutePath)
@@ -156,6 +151,15 @@ func cloneFunc(cmd *cobra.Command, argz []string) {
156151
os.Setenv("GHORG_OUTPUT_DIR", d)
157152
}
158153

154+
if len(argz) < 1 {
155+
if os.Getenv("GHORG_SCM_TYPE") == "github" && os.Getenv("GHORG_CLONE_TYPE") == "user" {
156+
argz = append(argz, "")
157+
} else {
158+
colorlog.PrintError("You must provide an org or user to clone")
159+
os.Exit(1)
160+
}
161+
}
162+
159163
configs.GetOrSetToken()
160164

161165
if cmd.Flags().Changed("token") {

‎cmd/version.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ var versionCmd = &cobra.Command{
1515
Short: "Print the version number of Ghorg",
1616
Long: `All software has versions. This is Ghorg's`,
1717
Run: func(cmd *cobra.Command, args []string) {
18-
fmt.Println("1.5.2")
18+
fmt.Println("1.6.0")
1919
},
2020
}

‎sample-conf.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ GHORG_BRANCH:
7777

7878
# Type of entity to clone (user or org)
7979
# default: org
80-
# to clone all of your own repos from github use "ghorg clone me --clone-type=user"
80+
# to clone all of your own repos from github don't specify any user eg. "ghorg clone --clone-type=user"
8181
# flag (--clone-type, -c)
8282
GHORG_CLONE_TYPE:
8383

‎scm/github.go

-4
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,6 @@ func (c Github) GetUserRepos(targetUser string) ([]Repo, error) {
8080

8181
for {
8282

83-
if targetUser == "me" {
84-
targetUser = ""
85-
}
86-
8783
// List the repositories for a user. Passing the empty string will list repositories for the authenticated user.
8884
repos, resp, err := c.Repositories.List(context.Background(), targetUser, opt)
8985

0 commit comments

Comments
 (0)
Please sign in to comment.