mirror of
https://github.com/gojp/goreportcard.git
synced 2026-01-28 22:39:05 +08:00
make cleanup repos tool inspect subdirs
This commit is contained in:
@@ -19,33 +19,42 @@ func main() {
|
||||
}
|
||||
|
||||
for _, f := range files {
|
||||
if f.Name() != "github.com" {
|
||||
continue
|
||||
}
|
||||
if f.IsDir() {
|
||||
dirs, err := ioutil.ReadDir("_repos/src/" + f.Name())
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
for _, d := range dirs {
|
||||
path := "_repos/src/" + f.Name() + "/" + d.Name()
|
||||
if time.Since(d.ModTime()) > 30*24*time.Hour {
|
||||
if *real {
|
||||
log.Printf("Deleting %s (repo is old)...", path)
|
||||
os.RemoveAll(path)
|
||||
continue
|
||||
} else {
|
||||
log.Printf("Would delete %s (repo is old)", path)
|
||||
}
|
||||
}
|
||||
|
||||
size, err := DirSize(path)
|
||||
repos, err := ioutil.ReadDir("_repos/src/" + f.Name() + "/" + d.Name())
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if size < 15*1000*1000 {
|
||||
if *real {
|
||||
log.Printf("Deleting %s (dir size < 15M)...", path)
|
||||
os.RemoveAll(path)
|
||||
} else {
|
||||
log.Printf("Would delete %s (dir size < 15M)", path)
|
||||
for _, repo := range repos {
|
||||
path := "_repos/src/" + f.Name() + "/" + d.Name() + "/" + repo.Name()
|
||||
if time.Since(d.ModTime()) > 30*24*time.Hour {
|
||||
if *real {
|
||||
log.Printf("Deleting %s (repo is old)...", path)
|
||||
os.RemoveAll(path)
|
||||
continue
|
||||
} else {
|
||||
log.Printf("Would delete %s (repo is old)", path)
|
||||
}
|
||||
}
|
||||
|
||||
size, err := DirSize(path)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if size < 15*1000*1000 {
|
||||
if *real {
|
||||
log.Printf("Deleting %s (dir size < 15M)...", path)
|
||||
os.RemoveAll(path)
|
||||
} else {
|
||||
log.Printf("Would delete %s (dir size < 15M)", path)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user