Skip to content

Commit

Permalink
feat: GitLab: exclude user repos (#830)
Browse files Browse the repository at this point in the history
  • Loading branch information
aetimmes authored Sep 18, 2024
1 parent a8d7c8b commit 8457735
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 7 additions & 3 deletions cmd/zoekt-indexserver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ type ConfigEntry struct {
Active bool
NoArchived bool
GerritFetchMetaConfig bool
GerritRepoNameFormat string
GerritRepoNameFormat string
ExcludeUserRepos bool
}

func randomize(entries []ConfigEntry) []ConfigEntry {
Expand Down Expand Up @@ -243,6 +244,9 @@ func executeMirror(cfg []ConfigEntry, repoDir string, pendingRepos chan<- string
if c.OnlyPublic {
cmd.Args = append(cmd.Args, "-public")
}
if c.ExcludeUserRepos {
cmd.Args = append(cmd.Args, "-exclude_user")
}
if c.CredentialPath != "" {
cmd.Args = append(cmd.Args, "-token", c.CredentialPath)
}
Expand All @@ -261,9 +265,9 @@ func executeMirror(cfg []ConfigEntry, repoDir string, pendingRepos chan<- string
if c.Active {
cmd.Args = append(cmd.Args, "-active")
}
if c.GerritFetchMetaConfig {
if c.GerritFetchMetaConfig {
cmd.Args = append(cmd.Args, "-fetch-meta-config")
}
}
if c.GerritRepoNameFormat != "" {
cmd.Args = append(cmd.Args, "-repo-name-format", c.GerritRepoNameFormat)
}
Expand Down
5 changes: 4 additions & 1 deletion cmd/zoekt-mirror-gitlab/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func main() {
isMember := flag.Bool("membership", false, "only mirror repos this user is a member of ")
isPublic := flag.Bool("public", false, "only mirror public repos")
deleteRepos := flag.Bool("delete", false, "delete missing repos")
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.")
flag.Parse()
Expand Down Expand Up @@ -103,6 +104,9 @@ func main() {
if project.DefaultBranch == "" {
continue
}
if *excludeUserRepos && project.Namespace.Kind == "user" {
continue
}

gitlabProjects = append(gitlabProjects, project)
}
Expand All @@ -128,7 +132,6 @@ func main() {
}
gitlabProjects = trimmed
}

fetchProjects(destDir, apiToken, gitlabProjects)

if *deleteRepos {
Expand Down

0 comments on commit 8457735

Please sign in to comment.