fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

query: parse support for `fork:` and `public:` (#550)

Add support for parsing queries for zoekt.fork and zoekt.public.

author
Ian Kerins
committer
GitHub
date (Mar 16, 2023, 8:59 AM +0100) commit 52664b7d parent 06c1bce6
+36 -7
+1
cmd/zoekt-mirror-gerrit/main.go
··· 167 167 "zoekt.gerrit-project": k, 168 168 "zoekt.gerrit-host": rootURL.String(), 169 169 "zoekt.archived": marshalBool(v.State == "READ_ONLY"), 170 + "zoekt.public": marshalBool(v.State != "HIDDEN"), 170 171 } 171 172 172 173 for _, wl := range v.WebLinks {
+3 -6
cmd/zoekt-mirror-github/main.go
··· 296 296 return err 297 297 } 298 298 299 - archived := false 300 - if r.Archived != nil { 301 - archived = *r.Archived 302 - } 303 - 304 299 config := map[string]string{ 305 300 "zoekt.web-url-type": "github", 306 301 "zoekt.web-url": *r.HTMLURL, ··· 311 306 "zoekt.github-subscribers": itoa(r.SubscribersCount), 312 307 "zoekt.github-forks": itoa(r.ForksCount), 313 308 314 - "zoekt.archived": marshalBool(archived), 309 + "zoekt.archived": marshalBool(r.Archived != nil && *r.Archived), 310 + "zoekt.fork": marshalBool(r.Fork != nil && *r.Fork), 311 + "zoekt.public": marshalBool(r.Private == nil || !*r.Private), 315 312 } 316 313 dest, err := gitindex.CloneRepo(destDir, *r.FullName, *r.CloneURL, config) 317 314 if err != nil {
+2
cmd/zoekt-mirror-gitlab/main.go
··· 177 177 "zoekt.gitlab-forks": strconv.Itoa(p.ForksCount), 178 178 179 179 "zoekt.archived": marshalBool(p.Archived), 180 + "zoekt.fork": marshalBool(p.ForkedFromProject != nil), 181 + "zoekt.public": marshalBool(p.Public), 180 182 } 181 183 182 184 cloneURL := p.HTTPURLToRepo
+24 -1
query/parse.go
··· 134 134 default: 135 135 return nil, 0, fmt.Errorf("query: unknown archived argument %q, want {yes,no}", text) 136 136 } 137 + case tokFork: 138 + switch text { 139 + case "yes": 140 + expr = RawConfig(RcOnlyForks) 141 + case "no": 142 + expr = RawConfig(RcNoForks) 143 + default: 144 + return nil, 0, fmt.Errorf("query: unknown fork argument %q, want {yes,no}", text) 145 + } 146 + case tokPublic: 147 + switch text { 148 + case "yes": 149 + expr = RawConfig(RcOnlyPublic) 150 + case "no": 151 + expr = RawConfig(RcOnlyPrivate) 152 + default: 153 + return nil, 0, fmt.Errorf("query: unknown public argument %q, want {yes,no}", text) 154 + } 137 155 case tokBranch: 138 156 expr = &Branch{Pattern: text} 139 157 case tokText, tokRegex: ··· 148 166 return nil, 0, err 149 167 } 150 168 expr = q 151 - 152 169 case tokContent: 153 170 q, err := RegexpQuery(text, true, false) 154 171 if err != nil { ··· 374 391 tokSym = 13 375 392 tokType = 14 376 393 tokArchived = 15 394 + tokPublic = 16 395 + tokFork = 17 377 396 ) 378 397 379 398 var tokNames = map[int]string{ ··· 382 401 tokCase: "Case", 383 402 tokError: "Error", 384 403 tokFile: "File", 404 + tokFork: "Fork", 385 405 tokNegate: "Negate", 386 406 tokOr: "Or", 387 407 tokParenClose: "ParenClose", 388 408 tokParenOpen: "ParenOpen", 409 + tokPublic: "Public", 389 410 tokRegex: "Regex", 390 411 tokRepo: "Repo", 391 412 tokText: "Text", ··· 403 424 "content:": tokContent, 404 425 "f:": tokFile, 405 426 "file:": tokFile, 427 + "fork:": tokFork, 428 + "public:": tokPublic, 406 429 "r:": tokRepo, 407 430 "regex:": tokRegex, 408 431 "repo:": tokRepo,
+4
query/parse_test.go
··· 67 67 {"((x|y) )", &Regexp{Regexp: mustParseRE("[xy]")}}, 68 68 {"archived:yes", RawConfig(RcOnlyArchived)}, 69 69 {"archived:no", RawConfig(RcNoArchived)}, 70 + {"fork:yes", RawConfig(RcOnlyForks)}, 71 + {"fork:no", RawConfig(RcNoForks)}, 72 + {"public:yes", RawConfig(RcOnlyPublic)}, 73 + {"public:no", RawConfig(RcOnlyPrivate)}, 70 74 {"file:helpers\\.go byte", NewAnd( 71 75 &Substring{Pattern: "helpers.go", FileName: true}, 72 76 &Substring{Pattern: "byte"})},
+2
web/templates.go
··· 172 172 <dt><a href="search?q=sym:data">sym:data</a></span></dt><dd>search for symbol definitions containing "data"</dd> 173 173 <dt><a href="search?q=phone+r:droid">phone r:droid</a></dt><dd>search for "phone" in repositories whose name contains "droid"</dd> 174 174 <dt><a href="search?q=phone+archived:no">phone archived:no</a></dt><dd>search for "phone" in repositories that are not archived</dd> 175 + <dt><a href="search?q=phone+fork:no">phone fork:no</a></dt><dd>search for "phone" in repositories that are not forks</dd> 176 + <dt><a href="search?q=phone+public:no">phone public:no</a></dt><dd>search for "phone" in repositories that are not public</dd> 175 177 <dt><a href="search?q=phone+b:master">phone b:master</a></dt><dd>for Git repos, find "phone" in files in branches whose name contains "master".</dd> 176 178 <dt><a href="search?q=phone+b:HEAD">phone b:HEAD</a></dt><dd>for Git repos, find "phone" in the default ('HEAD') branch.</dd> 177 179 </dl>