From 8a29d89aa81da815a0a471f9d85f24400bd03305 Mon Sep 17 00:00:00 2001 From: dessant Date: Thu, 29 Mar 2018 14:16:50 +0300 Subject: [PATCH] feat: ignore threads with certain labels Closes #1. --- README.md | 3 +++ assets/app-description.md | 3 +++ src/lock.js | 12 +++++++++--- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 50e132c..931e865 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,9 @@ lockComment: > This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread. +# Issues or pull requests with these labels will not be locked +# exemptLabels: +# - no-locking # Limit to only `issues` or `pulls` # only: issues ``` diff --git a/assets/app-description.md b/assets/app-description.md index 67d58f1..bd21e64 100644 --- a/assets/app-description.md +++ b/assets/app-description.md @@ -22,6 +22,9 @@ lockComment: > This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread. +# Issues or pull requests with these labels will not be locked +# exemptLabels: +# - no-locking # Limit to only `issues` or `pulls` # only: issues ``` diff --git a/src/lock.js b/src/lock.js index c0d94c6..6271e21 100644 --- a/src/lock.js +++ b/src/lock.js @@ -40,16 +40,22 @@ module.exports = class Lock { search() { const {owner, repo} = this.context.repo(); - const {daysUntilLock, only} = this.config; + const {exemptLabels, daysUntilLock, only} = this.config; const timestamp = this.since(daysUntilLock) .toISOString() .replace(/\.\d{3}\w$/, ''); let query = `repo:${owner}/${repo} is:closed updated:<${timestamp}`; + if (exemptLabels && exemptLabels.length) { + const queryPart = exemptLabels + .map(label => `-label:"${label}"`) + .join(' '); + query += ` ${queryPart}`; + } if (only === 'issues') { - query += ` is:issue`; + query += ' is:issue'; } else if (only === 'pulls') { - query += ` is:pr`; + query += ' is:pr'; } this.logger.info(`[${owner}/${repo}] Searching`);