Skip to content

Commit

Permalink
feat: support for skipping issues created before a given timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
denschub authored and dessant committed Nov 8, 2018
1 parent 5418408 commit ace8c2d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ The file can be empty, or it can override any of these default settings:
# Number of days of inactivity before a closed issue or pull request is locked
daysUntilLock: 365

# Skip issues and pull requests created before a given timestamp. Timestamp must
# follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable.
skipCreatedBefore: false

# Issues and pull requests with these labels will not be locked. Set to `[]` to disable
exemptLabels: []

Expand Down
4 changes: 4 additions & 0 deletions assets/app-description.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Create `.github/lock.yml` in the default branch to enable the app. The file can
# Number of days of inactivity before a closed issue or pull request is locked
daysUntilLock: 365

# Skip issues and pull requests created before a given timestamp. Timestamp must
# follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable.
skipCreatedBefore: false

# Issues and pull requests with these labels will not be locked. Set to `[]` to disable
exemptLabels: []

Expand Down
5 changes: 5 additions & 0 deletions src/lock.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ module.exports = class Lock {
const {owner, repo} = this.context.repo();
const daysUntilLock = this.getConfigValue(type, 'daysUntilLock');
const exemptLabels = this.getConfigValue(type, 'exemptLabels');
const skipCreatedBeforeTimestamp = this.getConfigValue(type, 'skipCreatedBefore');

const timestamp = this.getUpdatedTimestamp(daysUntilLock);

Expand All @@ -78,6 +79,10 @@ module.exports = class Lock {
query += ' is:pr';
}

if (skipCreatedBeforeTimestamp) {
query += ` created:>${skipCreatedBeforeTimestamp}`;
}

this.log.info({repo: {owner, repo}}, `Searching ${type}`);
return this.context.github.search.issues({
q: query,
Expand Down
8 changes: 8 additions & 0 deletions src/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ const fields = {
'Number of days of inactivity before a closed issue or pull request is locked'
),

skipCreatedBefore: Joi.alternatives()
.try(Joi.string(), Joi.boolean().only(false))
.description(
'Skip issues and pull requests created before a given timestamp. Timestamp' +
'must follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable.'
),

exemptLabels: Joi.array()
.single()
.items(Joi.string())
Expand All @@ -31,6 +38,7 @@ const fields = {

const schema = Joi.object().keys({
daysUntilLock: fields.daysUntilLock.default(365),
skipCreatedBefore: fields.skipCreatedBefore.default(false),
exemptLabels: fields.exemptLabels.default([]),
lockLabel: fields.lockLabel.default(false),
lockComment: fields.lockComment.default(
Expand Down

0 comments on commit ace8c2d

Please sign in to comment.