Skip to content
This repository has been archived by the owner on Aug 3, 2021. It is now read-only.

Commit

Permalink
feat: ignore threads with certain labels
Browse files Browse the repository at this point in the history
Closes #1.
  • Loading branch information
dessant committed Mar 29, 2018
1 parent 888e5a8 commit 8a29d89
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
3 changes: 3 additions & 0 deletions assets/app-description.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
12 changes: 9 additions & 3 deletions src/lock.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down

0 comments on commit 8a29d89

Please sign in to comment.