- expand custom assignment and add testcase to verify ability to construct custom categories involving states of PRs
This commit is contained in:
+7
-3
@@ -160,8 +160,11 @@ export function sortPullRequests(
|
||||
}
|
||||
|
||||
// helper function to add a special open label to prs not merged.
|
||||
function addOpenLabel(labels: Set<string>): Set<string> {
|
||||
labels.add('##rcba-open')
|
||||
function attachSpeciaLabels(
|
||||
status: 'open' | 'merged',
|
||||
labels: Set<string>
|
||||
): Set<string> {
|
||||
labels.add(`--rcba-${status}`)
|
||||
return labels
|
||||
}
|
||||
|
||||
@@ -178,7 +181,8 @@ const mapPullRequest = (
|
||||
mergeCommitSha: pr.merge_commit_sha || '',
|
||||
author: pr.user?.login || '',
|
||||
repoName: pr.base.repo.full_name,
|
||||
labels: addOpenLabel(
|
||||
labels: attachSpeciaLabels(
|
||||
status,
|
||||
new Set(
|
||||
pr.labels?.map(lbl => lbl.name?.toLocaleLowerCase('en') || '') || []
|
||||
)
|
||||
|
||||
+1
-1
@@ -323,7 +323,7 @@ function fillTemplate(pr: PullRequestInfo, template: string): string {
|
||||
transformed = transformed.replace(/\${{AUTHOR}}/g, pr.author)
|
||||
transformed = transformed.replace(
|
||||
/\${{LABELS}}/g,
|
||||
[...pr.labels]?.filter(l => !l.startsWith('##rcba-'))?.join(', ') || ''
|
||||
[...pr.labels]?.filter(l => !l.startsWith('--rcba-'))?.join(', ') || ''
|
||||
)
|
||||
transformed = transformed.replace(/\${{MILESTONE}}/g, pr.milestone || '')
|
||||
transformed = transformed.replace(/\${{BODY}}/g, pr.body)
|
||||
|
||||
Reference in New Issue
Block a user