mirror of
https://github.com/gabrie30/ghorg.git
synced 2026-05-05 20:06:09 +02:00
update clone to fetch if checkout is unsuccessful (#145)
* update clone to fetch if checkout is unsuccessful when repo exists locally
This commit is contained in:
parent
805b9266e7
commit
43f7c06eeb
@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
||||
### Added
|
||||
- integration tests on windows, ubuntu, and mac for github
|
||||
- GHORG_MATCH_REGEX to filter cloning repos by regex; thanks @petomalina
|
||||
- fetch all if checkout fails when repo exists locally then retry
|
||||
### Changed
|
||||
- initial clone will try to checkout a branch if specified; thanks @dword-design
|
||||
- default clone directory to $HOME/ghorg
|
||||
|
||||
17
cmd/clone.go
17
cmd/clone.go
@ -363,10 +363,21 @@ func CloneAllRepos() {
|
||||
cmd := exec.Command("git", "checkout", branch)
|
||||
cmd.Dir = repoDir
|
||||
err := cmd.Run()
|
||||
|
||||
if err != nil {
|
||||
e := fmt.Sprintf("Could not checkout out %s, branch may not exist, no changes made Repo: %s Error: %v", branch, repo.URL, err)
|
||||
cloneInfos = append(cloneInfos, e)
|
||||
return
|
||||
cmd = exec.Command("git", "fetch", "--all")
|
||||
cmd.Dir = repoDir
|
||||
err = cmd.Run()
|
||||
|
||||
cmd = exec.Command("git", "checkout", branch)
|
||||
cmd.Dir = repoDir
|
||||
err = cmd.Run()
|
||||
|
||||
if err != nil {
|
||||
e := fmt.Sprintf("Could not checkout out %s, branch may not exist, no changes made Repo: %s Error: %v", branch, repo.URL, err)
|
||||
cloneInfos = append(cloneInfos, e)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
cmd = exec.Command("git", "clean", "-f", "-d")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user