Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eval: simplify query.RawConfig #833

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
Loading