From 44c82506ddd5f6d33e5a9c653e6e4fc5c9042cf9 Mon Sep 17 00:00:00 2001 From: Sambhav Kothari Date: Tue, 6 Oct 2020 22:52:12 +0100 Subject: [PATCH] fix: Fix undefined error with blank validators --- docs/changelog.rst | 1 + docs/recipes.rst | 17 +++++++++++++++++ lib/actions/close.js | 2 +- lib/actions/comment.js | 2 +- lib/actions/labels.js | 2 +- 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 9293ee44..5341f37c 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,6 +1,7 @@ CHANGELOG ===================================== +| October 6, 2020 : fix: Fix undefined error with blank validators `#402 `_ | October 4, 2020 : fix Typo in header of title validator docs | October 2, 2020 : Don't throw merge error if required status are are the cause of the error `#389 `_ | September 24, 2020 : Add ability to delete or replace the labels on an issue `#380 `_ diff --git a/docs/recipes.rst b/docs/recipes.rst index 0faf3e12..42060225 100644 --- a/docs/recipes.rst +++ b/docs/recipes.rst @@ -126,3 +126,20 @@ Detect issues and pull requests that are n days old (stale) and notify authors a payload: body: This is old. Is it still relevant? + +Greet a new contributor +""""""""""""""""""""""" +Add a comment on a pull request when it is created + +:: + + version: 2 + mergeable: + - when: pull_request.opened + name: "Greet a contributor" + validate: [] + pass: + - do: comment + payload: + body: > + Thanks for creating a pull request! A maintainer will review your changes shortly. Please don't be discouraged if it takes a while. diff --git a/lib/actions/close.js b/lib/actions/close.js index e3c82e87..3093fe04 100644 --- a/lib/actions/close.js +++ b/lib/actions/close.js @@ -20,7 +20,7 @@ class Close extends Action { async beforeValidate () {} async afterValidate (context, settings, name, results) { - let scheduleResults = results && results.validationSuites && results.validationSuites[0].schedule + let scheduleResults = results && results.validationSuites && results.validationSuites.length && results.validationSuites[0].schedule let items = (scheduleResults) ? scheduleResults.issues.concat(scheduleResults.pulls) : [this.getPayload(context)] diff --git a/lib/actions/comment.js b/lib/actions/comment.js index a9c30e2a..762520c8 100644 --- a/lib/actions/comment.js +++ b/lib/actions/comment.js @@ -68,7 +68,7 @@ class Comment extends Action { async beforeValidate () {} async afterValidate (context, settings, name, results) { - let scheduleResults = results && results.validationSuites && results.validationSuites[0].schedule + let scheduleResults = results && results.validationSuites && results.validationSuites.length && results.validationSuites[0].schedule let commentables = (scheduleResults) ? scheduleResults.issues.concat(scheduleResults.pulls) : [this.getPayload(context)] diff --git a/lib/actions/labels.js b/lib/actions/labels.js index 7ce32b6f..9c4cb2cf 100644 --- a/lib/actions/labels.js +++ b/lib/actions/labels.js @@ -42,7 +42,7 @@ class Labels extends Action { async beforeValidate () {} async afterValidate (context, settings, name, results) { - let scheduleResults = results && results.validationSuites && results.validationSuites[0].schedule + let scheduleResults = results && results.validationSuites && results.validationSuites.length && results.validationSuites[0].schedule let items = (scheduleResults) ? scheduleResults.issues.concat(scheduleResults.pulls) : [this.getPayload(context)]