ci/github-script/reminders: don't remind on cherry-picks

Addresses https://github.com/NixOS/nixpkgs/pull/562912#issuecomment-6101844681
This commit is contained in:
Michael Daniels
2026-10-11 13:42:51 -04:00
parent e051ed5d72
commit 9e37f67efc
2 changed files with 39 additions and 5 deletions

View File

@@ -154,6 +154,10 @@ jobs:
sparse-checkout: |
ci/github-script
- name: Install dependencies
run: npm ci --package-lock-only=false --no-audit bottleneck
working-directory: trusted/ci/github-script
- uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
if: github.event_name != 'pull_request' && vars.NIXPKGS_CI_CLIENT_ID
id: app-token

View File

@@ -3,6 +3,7 @@ import path from 'node:path'
import type * as actionsCore from '@actions/core'
import type { context as actionsContext } from '@actions/github'
import type { GitHub } from '@actions/github/lib/utils'
import { cherryPickedFromSha, shaIsInDevelopmentBranch } from './commits.ts'
import { getCommitDetailsForPR } from './get-pr-commit-details.ts'
import { dismissReviews, postReview } from './reviews.ts'
import { classify } from './supportedBranches.ts'
@@ -63,12 +64,12 @@ export default async function postReminders({
return
}
const baseBranchType = classify(
const { type: baseBranchType, stable } = classify(
pr.base.ref.replace(/^refs\/heads\//, ''),
).type
const headBranchType = classify(
)
const { type: headBranchType } = classify(
pr.head.ref.replace(/^refs\/heads\//, ''),
).type
)
if (
baseBranchType.includes('development') &&
@@ -85,7 +86,36 @@ export default async function postReminders({
}
const details = await getCommitDetailsForPR({ core, pr, repoPath })
const changedPaths = details.flatMap(({ changedPaths }) => changedPaths)
let changedPaths: string[]
if (stable && details.length < 250) {
const prCommits = await github.paginate(github.rest.pulls.listCommits, {
...context.repo,
pull_number,
})
changedPaths = (
await Promise.all(
prCommits.map(async ({ files, commit }) => {
// Ignore cherry-picks from development branches to stable branches
const original_sha = cherryPickedFromSha(commit.message)
if (
!files ||
(original_sha &&
(await shaIsInDevelopmentBranch({
github,
context,
sha: original_sha,
})))
) {
return []
} else {
return files?.map(({ filename }) => filename)
}
}),
)
).flat(1)
} else {
changedPaths = details.flatMap(({ changedPaths }) => changedPaths)
}
for (const { key, paths } of reminders) {
if (matchesAny(changedPaths, paths)) {