From c443b80a83a99aa9b6ac527153230713b2e1c3dc Mon Sep 17 00:00:00 2001 From: po3rin Date: Sat, 19 Oct 2024 04:11:02 +0900 Subject: [PATCH] add last_activity_after flag --- 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 ede481c01..8cb228d84 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" @@ -48,6 +49,7 @@ func main() { deleteRepos := flag.Bool("delete", false, "delete missing 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 == "" { @@ -89,6 +91,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)