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

Configure Feed

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

query: simplify empty BranchesRepos and RepoIDs (#855)

We recently had an incident where this was accidently unset and lead to
lots of work done by zoekt which just got thrown away.

Test Plan: added unit test

+25
+11
query/query.go
··· 651 651 if s.Pattern == "" { 652 652 return &Const{true} 653 653 } 654 + case *BranchesRepos: 655 + for _, br := range s.List { 656 + if !br.Repos.IsEmpty() { 657 + return q 658 + } 659 + } 660 + return &Const{false} 661 + case *RepoIDs: 662 + if s.Repos.IsEmpty() { 663 + return &Const{false} 664 + } 654 665 case *RepoSet: 655 666 if len(s.Set) == 0 { 656 667 return &Const{false}
+14
query/query_test.go
··· 76 76 &Substring{Pattern: "byte"}, 77 77 &Not{&Substring{Pattern: "byte"}}), 78 78 }, 79 + { 80 + in: NewAnd( 81 + NewSingleBranchesRepos("HEAD"), // Empty list matches nothing 82 + &Not{&Type{Type: TypeRepo, Child: &Substring{Pattern: "hi"}}}), 83 + want: &Const{false}, 84 + }, 85 + { 86 + in: NewAnd( 87 + NewSingleBranchesRepos("HEAD", 1), 88 + &Not{&Type{Type: TypeRepo, Child: &Substring{Pattern: "hi"}}}), 89 + want: NewAnd( 90 + NewSingleBranchesRepos("HEAD", 1), 91 + &Not{&Type{Type: TypeRepo, Child: &Substring{Pattern: "hi"}}}), 92 + }, 79 93 } 80 94 81 95 for _, c := range cases {