From d80d701fec78568cfb075646639b73583e5fcf62 Mon Sep 17 00:00:00 2001 From: po3rin Date: Mon, 21 Oct 2024 16:43:02 +0900 Subject: [PATCH] zoekt-mirror-gitlab: add last_activity_after flag (#845) --- cmd/zoekt-mirror-gitlab/main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmd/zoekt-mirror-gitlab/main.go b/cmd/zoekt-mirror-gitlab/main.go index f28f9ce29..b37c18cac 100644 --- a/cmd/zoekt-mirror-gitlab/main.go +++ b/cmd/zoekt-mirror-gitlab/main.go @@ -32,6 +32,7 @@ import ( "path/filepath" "strconv" "strings" + "time" "github.com/sourcegraph/zoekt/gitindex" gitlab "github.com/xanzy/go-gitlab" @@ -49,6 +50,7 @@ func main() { excludeUserRepos := flag.Bool("exclude_user", false, "exclude user repos") namePattern := flag.String("name", "", "only clone repos whose name matches the given regexp.") excludePattern := flag.String("exclude", "", "don't mirror repos whose names match this regexp.") + lastActivityAfter := flag.String("last_activity_after", "", "only mirror repos that have been active since this date (format: 2006-01-02).") flag.Parse() if *dest == "" { @@ -90,6 +92,14 @@ func main() { opt.Visibility = gitlab.Visibility(gitlab.PublicVisibility) } + if *lastActivityAfter != "" { + targetDate, err := time.Parse("2006-01-02", *lastActivityAfter) + if err != nil { + log.Fatal(err) + } + opt.LastActivityAfter = gitlab.Time(targetDate) + } + var gitlabProjects []*gitlab.Project for { projects, _, err := client.Projects.ListProjects(opt)