|
|
|
|
@@ -1,4 +1,4 @@
|
|
|
|
|
module.exports = async function ({ github, context, core, dry }) {
|
|
|
|
|
module.exports = async ({ github, context, core, dry }) => {
|
|
|
|
|
const { execFileSync } = require('node:child_process')
|
|
|
|
|
const { readFile } = require('node:fs/promises')
|
|
|
|
|
const { join } = require('node:path')
|
|
|
|
|
@@ -24,7 +24,7 @@ module.exports = async function ({ github, context, core, dry }) {
|
|
|
|
|
|
|
|
|
|
async function extract({ sha, commit }) {
|
|
|
|
|
const noCherryPick = Array.from(
|
|
|
|
|
commit.message.matchAll(/^Not-cherry-picked-because: (.*)$/g)
|
|
|
|
|
commit.message.matchAll(/^Not-cherry-picked-because: (.*)$/g),
|
|
|
|
|
).at(0)
|
|
|
|
|
|
|
|
|
|
if (noCherryPick)
|
|
|
|
|
@@ -148,8 +148,7 @@ module.exports = async function ({ github, context, core, dry }) {
|
|
|
|
|
|
|
|
|
|
const fetch = extracted
|
|
|
|
|
.filter(({ severity }) => !severity)
|
|
|
|
|
.map(({ sha, original_sha }) => [ sha, original_sha ])
|
|
|
|
|
.flat()
|
|
|
|
|
.flatMap(({ sha, original_sha }) => [sha, original_sha])
|
|
|
|
|
|
|
|
|
|
if (fetch.length > 0) {
|
|
|
|
|
// Fetching all commits we need for diff at once is much faster than any other method.
|
|
|
|
|
@@ -163,7 +162,9 @@ module.exports = async function ({ github, context, core, dry }) {
|
|
|
|
|
])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const results = extracted.map(result => result.severity ? result : diff(result))
|
|
|
|
|
const results = extracted.map((result) =>
|
|
|
|
|
result.severity ? result : diff(result),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Log all results without truncation, with better highlighting and all whitespace changes to the job log.
|
|
|
|
|
results.forEach(({ sha, commit, severity, message, colored_diff }) => {
|
|
|
|
|
@@ -217,28 +218,58 @@ module.exports = async function ({ github, context, core, dry }) {
|
|
|
|
|
if (results.some(({ severity }) => severity == 'error'))
|
|
|
|
|
process.exitCode = 1
|
|
|
|
|
|
|
|
|
|
core.summary.addRaw('This report is automatically generated by the `PR / Check / cherry-pick` CI workflow.', true)
|
|
|
|
|
core.summary.addRaw(
|
|
|
|
|
'This report is automatically generated by the `PR / Check / cherry-pick` CI workflow.',
|
|
|
|
|
true,
|
|
|
|
|
)
|
|
|
|
|
core.summary.addEOL()
|
|
|
|
|
core.summary.addRaw("Some of the commits in this PR require the author's and reviewer's attention.", true)
|
|
|
|
|
core.summary.addRaw(
|
|
|
|
|
"Some of the commits in this PR require the author's and reviewer's attention.",
|
|
|
|
|
true,
|
|
|
|
|
)
|
|
|
|
|
core.summary.addEOL()
|
|
|
|
|
|
|
|
|
|
if (results.some(({ type }) => type === 'no-commit-hash')) {
|
|
|
|
|
core.summary.addRaw('Please follow the [backporting guidelines](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#how-to-backport-pull-requests) and cherry-pick with the `-x` flag.', true)
|
|
|
|
|
core.summary.addRaw('This requires changes to the unstable `master` and `staging` branches first, before backporting them.', true)
|
|
|
|
|
core.summary.addRaw(
|
|
|
|
|
'Please follow the [backporting guidelines](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#how-to-backport-pull-requests) and cherry-pick with the `-x` flag.',
|
|
|
|
|
true,
|
|
|
|
|
)
|
|
|
|
|
core.summary.addRaw(
|
|
|
|
|
'This requires changes to the unstable `master` and `staging` branches first, before backporting them.',
|
|
|
|
|
true,
|
|
|
|
|
)
|
|
|
|
|
core.summary.addEOL()
|
|
|
|
|
core.summary.addRaw('Occasionally, commits are not cherry-picked at all, for example when updating minor versions of packages which have already advanced to the next major on unstable.', true)
|
|
|
|
|
core.summary.addRaw('These commits can optionally be marked with a `Not-cherry-picked-because: <reason>` footer.', true)
|
|
|
|
|
core.summary.addRaw(
|
|
|
|
|
'Occasionally, commits are not cherry-picked at all, for example when updating minor versions of packages which have already advanced to the next major on unstable.',
|
|
|
|
|
true,
|
|
|
|
|
)
|
|
|
|
|
core.summary.addRaw(
|
|
|
|
|
'These commits can optionally be marked with a `Not-cherry-picked-because: <reason>` footer.',
|
|
|
|
|
true,
|
|
|
|
|
)
|
|
|
|
|
core.summary.addEOL()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (results.some(({ type }) => type === 'diff')) {
|
|
|
|
|
core.summary.addRaw('Sometimes it is not possible to cherry-pick exactly the same patch.', true)
|
|
|
|
|
core.summary.addRaw('This most frequently happens when resolving merge conflicts.', true)
|
|
|
|
|
core.summary.addRaw('The range-diff will help to review the resolution of conflicts.', true)
|
|
|
|
|
core.summary.addRaw(
|
|
|
|
|
'Sometimes it is not possible to cherry-pick exactly the same patch.',
|
|
|
|
|
true,
|
|
|
|
|
)
|
|
|
|
|
core.summary.addRaw(
|
|
|
|
|
'This most frequently happens when resolving merge conflicts.',
|
|
|
|
|
true,
|
|
|
|
|
)
|
|
|
|
|
core.summary.addRaw(
|
|
|
|
|
'The range-diff will help to review the resolution of conflicts.',
|
|
|
|
|
true,
|
|
|
|
|
)
|
|
|
|
|
core.summary.addEOL()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
core.summary.addRaw('If you need to merge this PR despite the warnings, please [dismiss](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/dismissing-a-pull-request-review) this review shortly before merging.', true)
|
|
|
|
|
core.summary.addRaw(
|
|
|
|
|
'If you need to merge this PR despite the warnings, please [dismiss](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/dismissing-a-pull-request-review) this review shortly before merging.',
|
|
|
|
|
true,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
results.forEach(({ severity, message, diff }) => {
|
|
|
|
|
if (severity == 'info') return
|
|
|
|
|
@@ -256,7 +287,7 @@ module.exports = async function ({ github, context, core, dry }) {
|
|
|
|
|
// Whether this is intended or just an implementation detail is unclear.
|
|
|
|
|
core.summary.addRaw('<blockquote>')
|
|
|
|
|
core.summary.addRaw(
|
|
|
|
|
`\n\n[!${({ important: 'IMPORTANT', warning: 'WARNING', error: 'CAUTION' })[severity]}]`,
|
|
|
|
|
`\n\n[!${{ important: 'IMPORTANT', warning: 'WARNING', error: 'CAUTION' }[severity]}]`,
|
|
|
|
|
true,
|
|
|
|
|
)
|
|
|
|
|
core.summary.addRaw(`${message}`, true)
|
|
|
|
|
|