Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ const { masterBranch } = __nccwpck_require__(51629);

function toPr(context) {
let { base, body, user, html_url, title, number, head, id} = context.payload.pull_request
let repoFullName = (base && base.repo && base.repo.full_name) ||
(head && head.repo && head.repo.full_name) || "";

return {
description: body,
authorHandle: user.login,
Expand All @@ -207,7 +210,8 @@ function toPr(context) {
from: head.ref,
to: base.ref,
id: id,
typeOfChange: head.ref.split('/')[0]
typeOfChange: head.ref.split('/')[0],
repoFullName: repoFullName
}
}

Expand Down Expand Up @@ -415,6 +419,7 @@ async function test() {
// await onPrClose({ payload: { pull_request: closedPr } })
}


/***/ }),

/***/ 87351:
Expand Down Expand Up @@ -107969,6 +107974,10 @@ function entry(label, value) {
return slack.markdown(`*${label}:* ${value}`)
}

function repoPrefix(pr) {
return pr && pr.repoFullName ? `[${pr.repoFullName}] ` : ""
}

async function notifyNewPR(pr) {
if (isAuthoredByBot(pr.authorHandle)) {
return;
Expand All @@ -107987,8 +107996,9 @@ async function notifyNewPR(pr) {
async function notifyMergedPR(pr, mergedBy) {
let textMessage = `${mergedBy} has merged a PR ${pr.title}(${pr.url})`
if (isAuthoredByBot(mergedBy)) {
let completedMessage = `${repoPrefix(pr)}${pr.title} - completed`
await slack.sendMessage(channelName(pr), textMessage, [
slack.markdown(pr.title + " - completed")
slack.markdown(completedMessage)
]);
return
}
Expand Down Expand Up @@ -108049,6 +108059,7 @@ async function autoSyncFailed(channelName) {
}
module.exports = {notifyNewPR, notifyMergedPR, notifyClosedPR, notifyPrHasConflicts, notifyPrMergeFailed, autoSyncFailed}


/***/ }),

/***/ 22877:
Expand Down
8 changes: 6 additions & 2 deletions handlers/pr.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const { masterBranch } = require("../constants");

function toPr(context) {
let { base, body, user, html_url, title, number, head, id} = context.payload.pull_request
let repoFullName = (base && base.repo && base.repo.full_name) ||
(head && head.repo && head.repo.full_name) || "";

return {
description: body,
authorHandle: user.login,
Expand All @@ -15,7 +18,8 @@ function toPr(context) {
from: head.ref,
to: base.ref,
id: id,
typeOfChange: head.ref.split('/')[0]
typeOfChange: head.ref.split('/')[0],
repoFullName: repoFullName
}
}

Expand Down Expand Up @@ -221,4 +225,4 @@ async function test() {

// var closedPr = JSON.parse(fs.readFileSync('./../ops/dev/fakes/pr/close.json', 'utf8'));
// await onPrClose({ payload: { pull_request: closedPr } })
}
}
9 changes: 7 additions & 2 deletions notifications/slack.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ function entry(label, value) {
return slack.markdown(`*${label}:* ${value}`)
}

function repoPrefix(pr) {
return pr && pr.repoFullName ? `[${pr.repoFullName}] ` : ""
}

async function notifyNewPR(pr) {
if (isAuthoredByBot(pr.authorHandle)) {
return;
Expand All @@ -55,8 +59,9 @@ async function notifyNewPR(pr) {
async function notifyMergedPR(pr, mergedBy) {
let textMessage = `${mergedBy} has merged a PR ${pr.title}(${pr.url})`
if (isAuthoredByBot(mergedBy)) {
let completedMessage = `${repoPrefix(pr)}${pr.title} - completed`
await slack.sendMessage(channelName(pr), textMessage, [
slack.markdown(pr.title + " - completed")
slack.markdown(completedMessage)
]);
return
}
Expand Down Expand Up @@ -115,4 +120,4 @@ async function autoSyncFailed(channelName) {
slack.header(":need_action: AUTO SYNC FAILED :need_action:")
])
}
module.exports = {notifyNewPR, notifyMergedPR, notifyClosedPR, notifyPrHasConflicts, notifyPrMergeFailed, autoSyncFailed}
module.exports = {notifyNewPR, notifyMergedPR, notifyClosedPR, notifyPrHasConflicts, notifyPrMergeFailed, autoSyncFailed}