fetch all and reset hard if repo already exists

This commit is contained in:
Jay Gabriels
2018-05-19 10:06:54 -07:00
parent 0a1c6f7c20
commit 17ade710f2
2 changed files with 19 additions and 8 deletions

View File

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

View File

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