chore: enable Issue management automation
This commit is contained in:
16
.github/issue-management/policy.mjs
vendored
16
.github/issue-management/policy.mjs
vendored
@@ -180,6 +180,20 @@ export function parseReferences({ body, repository }) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retain only references that resolve to Issues rather than pull requests.
|
||||
* @param {{all: number[], resolving: number[], related: number[]}} references Parsed references.
|
||||
* @param {Map<number, unknown>} issues Resolved same-repository Issues.
|
||||
* @returns {{all: number[], resolving: number[], related: number[]}} Issue-only references.
|
||||
*/
|
||||
export function retainIssueReferences(references, issues) {
|
||||
return {
|
||||
all: references.all.filter((number) => issues.has(number)),
|
||||
resolving: references.resolving.filter((number) => issues.has(number)),
|
||||
related: references.related.filter((number) => issues.has(number)),
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate one Issue with its Project status.
|
||||
* @param {{title: string, body: string, assignees: string[], labels: string[], type: string|null, priority: string|null, status: string|null, state: string, stateReason: string|null}} issue Issue snapshot.
|
||||
@@ -472,7 +486,7 @@ async function pullRequestSnapshot(number) {
|
||||
reviewRequestCount: reviewRequests.users.length + reviewRequests.teams.length,
|
||||
reviewCount: reviews.length,
|
||||
labels: pull.labels.map((label) => label.name),
|
||||
references,
|
||||
references: retainIssueReferences(references, issues),
|
||||
issues,
|
||||
}
|
||||
}
|
||||
|
||||
19
.github/issue-management/policy.test.mjs
vendored
19
.github/issue-management/policy.test.mjs
vendored
@@ -4,6 +4,7 @@ import test from 'node:test'
|
||||
import {
|
||||
countVisibleUnits,
|
||||
parseReferences,
|
||||
retainIssueReferences,
|
||||
requiresPullRequestPolicy,
|
||||
validateBody,
|
||||
validateIssue,
|
||||
@@ -117,6 +118,24 @@ test('separates resolving and informational references', () => {
|
||||
)
|
||||
})
|
||||
|
||||
test('does not treat pull request references as Issue associations', () => {
|
||||
const references = {
|
||||
all: [123, 1180, 1181],
|
||||
resolving: [123, 1180],
|
||||
related: [1181],
|
||||
}
|
||||
const issues = new Map([
|
||||
[1180, {}],
|
||||
[1181, {}],
|
||||
])
|
||||
|
||||
assert.deepEqual(retainIssueReferences(references, issues), {
|
||||
all: [1180, 1181],
|
||||
resolving: [1180],
|
||||
related: [1181],
|
||||
})
|
||||
})
|
||||
|
||||
test('allows informational references without cross-object constraints', () => {
|
||||
const errors = validatePullRequest({
|
||||
isDraft: false,
|
||||
|
||||
Reference in New Issue
Block a user