UNPKG

backport

Version:

A CLI tool that automates the process of backporting commits

27 lines 1.06 kB
export function getSourcePRLabelsToCopy({ commits, copySourcePRLabels, }) { if (copySourcePRLabels === true) { return commits.flatMap((commit) => { if (!commit.sourcePullRequest) { return []; } const backportLabels = new Set(commit.targetPullRequestStates.map((pr) => pr.label)); return commit.sourcePullRequest.labels.filter((label) => !backportLabels.has(label)); }); } const patterns = Array.isArray(copySourcePRLabels) ? copySourcePRLabels : typeof copySourcePRLabels === 'string' ? [copySourcePRLabels] : []; if (patterns.length === 0) { return []; } const regexes = patterns.map((pattern) => new RegExp(pattern)); return commits.flatMap((commit) => { if (!commit.sourcePullRequest) { return []; } return commit.sourcePullRequest.labels.filter((label) => regexes.some((regex) => regex.test(label))); }); } //# sourceMappingURL=get-source-pr-labels-to-copy.js.map