mirror of
https://github.com/gojp/goreportcard.git
synced 2026-01-28 22:39:05 +08:00
add -real flag to really run repo deletions
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
var real = flag.Bool("real", false, "run the deletions")
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
files, err := ioutil.ReadDir("_repos/src")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
@@ -22,8 +26,12 @@ func main() {
|
||||
for _, d := range dirs {
|
||||
if time.Now().Sub(d.ModTime()) > 30*24*time.Hour {
|
||||
path := "_repos/src/" + f.Name() + "/" + d.Name()
|
||||
log.Printf("Deleting %s...", path)
|
||||
os.RemoveAll(path)
|
||||
if *real {
|
||||
log.Printf("Deleting %s...", path)
|
||||
os.RemoveAll(path)
|
||||
} else {
|
||||
log.Printf("Would delete %s", path)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user