Add bounty size info on Slack message for promoted bounty issues
This commit is contained in:
parent
fef64a854b
commit
c740507775
|
@ -118,6 +118,7 @@ Examples of settings that can be configured:
|
||||||
- `bounty-project-board/awaiting-approval-column-name`: Name of the column in the bounty project board to group issues that are awaiting for bounty approval
|
- `bounty-project-board/awaiting-approval-column-name`: Name of the column in the bounty project board to group issues that are awaiting for bounty approval
|
||||||
- `bounty-project-board/awaiting-approval-label-name`: Name of the label used in issues to declare that an issue is awaiting approval to become a bounty
|
- `bounty-project-board/awaiting-approval-label-name`: Name of the label used in issues to declare that an issue is awaiting approval to become a bounty
|
||||||
- `bounty-project-board/bounty-label-name`: Name of the label used in issues to declare that an issue is a bounty
|
- `bounty-project-board/bounty-label-name`: Name of the label used in issues to declare that an issue is a bounty
|
||||||
|
- `bounty-project-board/bounty-size-label-name-regex`: Regular expression that matches the bounty size label and returns a group containing the size itself
|
||||||
- `bounty-project-board/post-approved-bounties-to-slack-room`: Name of the Slack room where to cross-post approved bounties
|
- `bounty-project-board/post-approved-bounties-to-slack-room`: Name of the Slack room where to cross-post approved bounties
|
||||||
|
|
||||||
- Automated tests settings:
|
- Automated tests settings:
|
||||||
|
|
|
@ -66,6 +66,7 @@ async function assignIssueToBountyAwaitingForApproval (context, robot, assign) {
|
||||||
|
|
||||||
const bountyLabelName = projectBoardConfig['bounty-label-name']
|
const bountyLabelName = projectBoardConfig['bounty-label-name']
|
||||||
const isOfficialBounty = !!payload.issue.labels.find(l => l.name === bountyLabelName)
|
const isOfficialBounty = !!payload.issue.labels.find(l => l.name === bountyLabelName)
|
||||||
|
const bountySize = getBountySize(payload.issue.labels, projectBoardConfig)
|
||||||
|
|
||||||
if (process.env.DRY_RUN) {
|
if (process.env.DRY_RUN) {
|
||||||
if (assign) {
|
if (assign) {
|
||||||
|
@ -101,7 +102,7 @@ async function assignIssueToBountyAwaitingForApproval (context, robot, assign) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const slackMessage = getSlackMessage(projectBoardConfig.name, approvalColumnName, payload, assign, isOfficialBounty)
|
const slackMessage = getSlackMessage(projectBoardConfig.name, approvalColumnName, payload, assign, isOfficialBounty, bountySize)
|
||||||
if (slackMessage && !process.env.DRY_RUN_BOUNTY_APPROVAL) {
|
if (slackMessage && !process.env.DRY_RUN_BOUNTY_APPROVAL) {
|
||||||
// Send message to Slack
|
// Send message to Slack
|
||||||
slackHelper.sendMessage(robot, config.slack.notification.room, slackMessage)
|
slackHelper.sendMessage(robot, config.slack.notification.room, slackMessage)
|
||||||
|
@ -116,14 +117,33 @@ async function assignIssueToBountyAwaitingForApproval (context, robot, assign) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSlackMessage (projectBoardName, approvalColumnName, payload, assign, isOfficialBounty) {
|
function getSlackMessage (projectBoardName, approvalColumnName, payload, assign, isOfficialBounty, bountySize) {
|
||||||
if (assign) {
|
if (assign) {
|
||||||
return `Assigned issue to ${approvalColumnName} in ${projectBoardName} project\n${payload.issue.html_url}`
|
return `Assigned issue to ${approvalColumnName} in ${projectBoardName} project\n${payload.issue.html_url}`
|
||||||
} else {
|
|
||||||
if (isOfficialBounty) {
|
|
||||||
return `${payload.issue.html_url} has been approved as an official bounty!`
|
|
||||||
} else {
|
|
||||||
return `Unassigned issue from ${approvalColumnName} in ${projectBoardName} project\n${payload.issue.html_url}`
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isOfficialBounty) {
|
||||||
|
return `Unassigned issue from ${approvalColumnName} in ${projectBoardName} project\n${payload.issue.html_url}`
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bountySize) {
|
||||||
|
return `${payload.issue.html_url} has been approved as an official bounty (size: ${bountySize})!`
|
||||||
|
}
|
||||||
|
return `${payload.issue.html_url} has been approved as an official bounty!`
|
||||||
|
}
|
||||||
|
|
||||||
|
function getBountySize (labels, projectBoardConfig) {
|
||||||
|
const regexString = projectBoardConfig['bounty-size-label-name-regex']
|
||||||
|
if (!regexString) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
const bountySizeLabelRegex = new RegExp(regexString)
|
||||||
|
|
||||||
|
const match = labels.map(l => bountySizeLabelRegex.exec(l.name)).find(m => m != null)
|
||||||
|
if (match) {
|
||||||
|
return match[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue