diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2026-01-12 22:47:10 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2026-01-13 14:18:14 +0000 |
| commit | 393201ac23707dff38037f4961f955db7e413b67 (patch) | |
| tree | ba9ad0823a72fcfb92dd90fa6e8a215c39076e4d /syz-cluster/pkg/triage/commit.go | |
| parent | 85894026b1b003844e8fda94056d80d88294b0be (diff) | |
syz-cluster: prioritize blob-based base commits
Consider Cc'd mailing lists when selecting the exact base commit.
Among the base commits determined based on blob sha value from the git
patch, first select the ones that match both the trees of the Cc'd
subsystems and their primary branches.
If it gives no exact match, select a base commit that comes from a tree
of a Cc'd subsystem. As fallback, take any subsystem tree.
This should prevent valid, but suprising patch series triage results.
Diffstat (limited to 'syz-cluster/pkg/triage/commit.go')
| -rw-r--r-- | syz-cluster/pkg/triage/commit.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/syz-cluster/pkg/triage/commit.go b/syz-cluster/pkg/triage/commit.go index 53229e32c..6d8644623 100644 --- a/syz-cluster/pkg/triage/commit.go +++ b/syz-cluster/pkg/triage/commit.go @@ -80,3 +80,40 @@ func (cs *CommitSelector) Select(series *api.Series, tree *api.Tree, lastBuild * } return SelectResult{Reason: reasonNotApplies}, nil } + +func FromBaseCommits(series *api.Series, baseCommits []*vcs.BaseCommit, trees []*api.Tree) (*api.Tree, string) { + // Technically, any one of baseCommits could be a good match. + // However, the developers have their own expectations regarding + // what tree and what branch are actually preferred there. + // So, among baseCommits, we still give preference to those that + // align with the mailing lists Cc'd by the patch series. + tree, commit := bestCommit(baseCommits, SelectTrees(series, trees)) + if tree != nil { + return tree, commit + } + return bestCommit(baseCommits, trees) +} + +func bestCommit(baseCommits []*vcs.BaseCommit, trees []*api.Tree) (*api.Tree, string) { + retTreeIdx, retSameBranch, retCommit := -1, false, "" + for _, commit := range baseCommits { + for _, commitBranch := range commit.Branches { + treeIdx, branch := FindTree(trees, commitBranch) + if treeIdx < 0 { + continue + } + sameBranch := branch == trees[treeIdx].Branch + // If, for the same tree, we also have matched the branch, even better. + if retTreeIdx < 0 || treeIdx < retTreeIdx || + treeIdx == retTreeIdx && !retSameBranch && sameBranch { + retTreeIdx = treeIdx + retSameBranch = sameBranch + retCommit = commit.Hash + } + } + } + if retTreeIdx < 0 { + return nil, "" + } + return trees[retTreeIdx], retCommit +} |
