diff --git a/eval.go b/eval.go index af637f01e..6276ef012 100644 --- a/eval.go +++ b/eval.go @@ -75,6 +75,8 @@ func (d *indexData) simplify(in query.Q) query.Q { return d.simplifyMultiRepo(q, func(repo *Repository) bool { return r.Set[repo.Name] }) + case query.RawConfig: + return d.simplifyMultiRepo(q, func(repo *Repository) bool { return uint8(r)&encodeRawConfig(repo.RawConfig) == uint8(r) }) case *query.RepoIDs: return d.simplifyMultiRepo(q, func(repo *Repository) bool { return r.Repos.Contains(repo.ID) diff --git a/eval_test.go b/eval_test.go index 32cefdea0..36e78ed9d 100644 --- a/eval_test.go +++ b/eval_test.go @@ -329,6 +329,22 @@ func TestSimplifyRepoRegexp(t *testing.T) { } } +func TestSimplifyRcRawConfig(t *testing.T) { + d := compoundReposShard(t, "foo", "bar") + var all = query.RcOnlyPrivate | query.RcNoForks | query.RcNoArchived + + got := d.simplify(all) + if d := cmp.Diff(&query.Const{Value: true}, got); d != "" { + t.Fatalf("-want, +got:\n%s", d) + } + + var none = query.RcOnlyPublic | query.RcNoForks | query.RcNoArchived + got = d.simplify(none) + if d := cmp.Diff(&query.Const{Value: false}, got); d != "" { + t.Fatalf("-want, +got:\n%s", d) + } +} + func TestSimplifyBranchesRepos(t *testing.T) { d := compoundReposShard(t, "foo", "bar")