cmd: add option to only mirror public gitlab repositories
Change-Id: I5e8ff96d1569397f3b8407aa4a9211da48994411
diff --git a/cmd/zoekt-indexserver/config.go b/cmd/zoekt-indexserver/config.go
index 057cf4c..00eff2f 100644
--- a/cmd/zoekt-indexserver/config.go
+++ b/cmd/zoekt-indexserver/config.go
@@ -42,6 +42,7 @@
Name string
Exclude string
GitLabURL string
+ OnlyPublic bool
}
func randomize(entries []ConfigEntry) []ConfigEntry {
@@ -212,6 +213,9 @@
if c.Exclude != "" {
cmd.Args = append(cmd.Args, "-exclude", c.Exclude)
}
+ if c.OnlyPublic {
+ cmd.Args = append(cmd.Args, "-public")
+ }
}
stdout, _ := loggedRun(cmd)
diff --git a/cmd/zoekt-mirror-gitlab/main.go b/cmd/zoekt-mirror-gitlab/main.go
index d602b69..8e156de 100644
--- a/cmd/zoekt-mirror-gitlab/main.go
+++ b/cmd/zoekt-mirror-gitlab/main.go
@@ -46,6 +46,7 @@
filepath.Join(os.Getenv("HOME"), ".gitlab-token"),
"file holding API token.")
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")
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.")
@@ -83,6 +84,9 @@
},
Membership: isMember,
}
+ if *isPublic {
+ opt.Visibility = gitlab.Visibility(gitlab.PublicVisibility)
+ }
var gitlabProjects []*gitlab.Project
for {