Skip to content

Commit

Permalink
feat(cmd/zoekt-mirror-gitlab): add no_archived Option (#881)
Browse files Browse the repository at this point in the history
Add support to the GitLab mirror for excluding archived repos.
  • Loading branch information
MarcWort authored Jan 8, 2025
1 parent d484925 commit d0990e0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/zoekt-indexserver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ func executeMirror(cfg []ConfigEntry, repoDir string, pendingRepos chan<- string
if c.CredentialPath != "" {
cmd.Args = append(cmd.Args, "-token", c.CredentialPath)
}
if c.NoArchived {
cmd.Args = append(cmd.Args, "-no_archived")
}
} else if c.GerritApiURL != "" {
cmd = exec.Command("zoekt-mirror-gerrit",
"-dest", repoDir, "-delete")
Expand Down
6 changes: 6 additions & 0 deletions cmd/zoekt-mirror-gitlab/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ func main() {
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).")
noArchived := flag.Bool("no_archived", false, "mirror only projects that are not archived")

flag.Parse()

if *dest == "" {
Expand Down Expand Up @@ -100,6 +102,10 @@ func main() {
opt.LastActivityAfter = gitlab.Time(targetDate)
}

if *noArchived {
opt.Archived = gitlab.Bool(false)
}

var gitlabProjects []*gitlab.Project
for {
projects, _, err := client.Projects.ListProjects(opt)
Expand Down

0 comments on commit d0990e0

Please sign in to comment.