Last active
December 15, 2015 13:47
-
-
Save mattn/158681fd382f787ab4a0 to your computer and use it in GitHub Desktop.
GOPATH 内の git リポジトリで全部 git gc するやつ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"os" | |
"os/exec" | |
"path/filepath" | |
"strings" | |
) | |
func main() { | |
b, err := exec.Command("ghq", "list").CombinedOutput() | |
if err != nil { | |
log.Fatal(err) | |
} | |
for _, line := range strings.Split(string(b), "\n") { | |
for _, p := range filepath.SplitList(os.Getenv("GOPATH")) { | |
repo := filepath.FromSlash(filepath.Join(p, "src", line)) | |
if _, err = os.Stat(filepath.Join(repo, ".git")); err != nil { | |
continue | |
} | |
log.Print(repo) | |
cmd := exec.Command("git", "gc") | |
cmd.Stdout = os.Stdout | |
cmd.Stderr = os.Stderr | |
cmd.Dir = repo | |
if err = cmd.Run(); err != nil { | |
log.Print(err) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment