зеркало из https://github.com/golang/build.git
cmd/issuelock: support locking a specific issue
Change-Id: I87792b5cd2a34cfde4c42519f83f750350d778a2 Reviewed-on: https://go-review.googlesource.com/24611 Reviewed-by: Andrew Gerrand <adg@golang.org>
This commit is contained in:
Родитель
99b219b546
Коммит
face166226
|
@ -6,10 +6,13 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -17,7 +20,16 @@ import (
|
|||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
func usage() {
|
||||
fmt.Fprintf(os.Stderr, "Usage: issuelock [<issue>]\n")
|
||||
flag.PrintDefaults()
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Usage = usage
|
||||
flag.Parse()
|
||||
|
||||
tokenFile := filepath.Join(os.Getenv("HOME"), "keys", "github-gobot")
|
||||
slurp, err := ioutil.ReadFile(tokenFile)
|
||||
if err != nil {
|
||||
|
@ -31,6 +43,20 @@ func main() {
|
|||
tc := oauth2.NewClient(oauth2.NoContext, ts)
|
||||
client := github.NewClient(tc)
|
||||
|
||||
if flag.NArg() == 1 {
|
||||
issueNum, err := strconv.Atoi(flag.Arg(0))
|
||||
if err != nil {
|
||||
usage()
|
||||
}
|
||||
if err := freeze(client, issueNum); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
if flag.NArg() > 1 {
|
||||
usage()
|
||||
}
|
||||
|
||||
tooOld := time.Now().Add(-365 * 24 * time.Hour).Format("2006-01-02")
|
||||
log.Printf("Freezing closed issues before %v", tooOld)
|
||||
for {
|
||||
|
|
Загрузка…
Ссылка в новой задаче