Skip to content

Commit

Permalink
Do nothing with closed PRs
Browse files Browse the repository at this point in the history
`pull_request.merged` implies `pull_request.state != "open"` but the
latter will also be true for closed but unmerged pull requests.

Fixes #38.
  • Loading branch information
foolip authored Oct 21, 2019
1 parent 724e1bb commit 9cba8cf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ app.post('/github-hook', function (req, res, next) {
var u = (issue.user && issue.user.login) || null;
var content = issue.body || "";
if (!isComment && action == "edited") {
if (body.pull_request.merged) return; // we know .pullrequest is available because it's not a comment.
// We know .pull_request is available because it's not a comment.
if (body.pull_request.state != "open") return;
logArgs("#" + n, "pull request edited");
metadata(n, u, content).then(function(metadata) {
return removeReviewableBanner(n, metadata);
Expand All @@ -113,7 +114,7 @@ app.post('/github-hook', function (req, res, next) {
waitFor(5 * 1000).then(function() { // Avoid race condition
return getPullRequest(n, body);
}).then(function(pull_request) {
if (pull_request.merged) return;
if (pull_request.state != "open") return;
return metadata(n, u, content).then(function(metadata) {
logArgs(metadata);
return labelModel.post(n, metadata.labels).then(
Expand Down

0 comments on commit 9cba8cf

Please sign in to comment.