Skip to content

Commit

Permalink
fix: missing parameter in merge message requirement check (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
gitcommitshow authored Jun 22, 2024
1 parent 40a138d commit 03e9f4c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ app.octokit.log.debug(`Authenticated as '${data.name}'`);
// Subscribe to the "pull_request.opened" webhook event
app.webhooks.on("pull_request.opened", async ({ octokit, payload }) => {
console.log(
`Received a pull request event for #${payload.pull_request.number}`,
`Received a pull request event for #${payload.pull_request.number} by ${payload.pull_request.user.type}: ${payload.pull_request.user.login}`,
);
try {
if (!isCLARequired(payload.pull_request)) {
Expand Down Expand Up @@ -101,7 +101,7 @@ app.webhooks.on("pull_request.closed", async ({ octokit, payload }) => {
if (!payload.pull_request.merged) return;
console.log(`This PR is merged`);
try {
if (!isMessageAfterMergeRequired()) {
if (!isMessageAfterMergeRequired(payload.pull_request)) {
return;
}
console.log(`Going to notify the PR author...`);
Expand Down Expand Up @@ -129,9 +129,7 @@ app.webhooks.on("pull_request.closed", async ({ octokit, payload }) => {
});

app.webhooks.on("issues.opened", async ({ octokit, payload }) => {
console.log(
`Received a new issue event for #${payload.issue.number} by ${pull_request.user.type}: ${pull_request.user.login}`,
);
console.log(`Received a new issue event for #${payload.issue.number}`);
try {
await octokit.rest.issues.createComment({
owner: payload.repository.owner.login,
Expand Down
2 changes: 1 addition & 1 deletion src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function isCLARequired(pullRequest) {
}

export function isMessageAfterMergeRequired(pullRequest) {
if (isABot(pullRequest.user)) {
if (isABot(pullRequest?.user)) {
console.log("This PR is from a bot. So no message after merge required.");
return false;
}
Expand Down

0 comments on commit 03e9f4c

Please sign in to comment.