mirror of
https://github.com/outbackdingo/ghorg.git
synced 2026-01-27 10:19:03 +00:00
fetch all and reset hard if repo already exists
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
# ghorg
|
||||
|
||||
Github search is terrible. The idea here is quickly clone all org repos into a single directory and use something like ack for searching the org. Can also be used for setting up kuve <https://github.com/wrsinc/kuve>
|
||||
Github search is terrible. The idea with ghorg is to quickly clone all org repos into a single directory and use something like ack to search.
|
||||
|
||||
## Use
|
||||
|
||||
- $ ghorg nameoforg
|
||||
- $ ghorg org
|
||||
|
||||
```NOTE: When ran ghorg will overwrite any local changes. If you are using ghorg to create a directory to work out of, make sure you rename the directory before running a second time.```
|
||||
|
||||
## Setup
|
||||
|
||||
|
||||
21
cmd/clone.go
21
cmd/clone.go
@@ -97,16 +97,25 @@ func CloneAllReposByOrg() {
|
||||
return
|
||||
}
|
||||
|
||||
cmd2 := exec.Command("git", "pull", "origin", "master")
|
||||
cmd2.Dir = repoDir
|
||||
err2 := cmd2.Run()
|
||||
if err2 != nil {
|
||||
cmd = exec.Command("git", "fetch", "--all")
|
||||
cmd.Dir = repoDir
|
||||
err = cmd.Run()
|
||||
if err != nil {
|
||||
fmt.Println("Error trying to fetch all", repoDir)
|
||||
errc <- err
|
||||
return
|
||||
}
|
||||
|
||||
cmd = exec.Command("git", "reset", "--hard", "origin/master")
|
||||
cmd.Dir = repoDir
|
||||
err = cmd.Run()
|
||||
if err != nil {
|
||||
fmt.Println("Error trying to pull master from", repoDir)
|
||||
errc <- err2
|
||||
errc <- err
|
||||
return
|
||||
}
|
||||
} else {
|
||||
cmd := exec.Command("git", "clone", repoUrl, repoDir)
|
||||
cmd := exec.Command("git", "clone", "-b master", repoUrl, repoDir)
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
fmt.Println("Error trying to clone", repoUrl)
|
||||
|
||||
Reference in New Issue
Block a user