Skip to content

Commit ace8c2d

Browse files
denschubdessant
authored andcommitted
feat: support for skipping issues created before a given timestamp
1 parent 5418408 commit ace8c2d

4 files changed

Lines changed: 21 additions & 0 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ The file can be empty, or it can override any of these default settings:
3434
# Number of days of inactivity before a closed issue or pull request is locked
3535
daysUntilLock: 365
3636

37+
# Skip issues and pull requests created before a given timestamp. Timestamp must
38+
# follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable.
39+
skipCreatedBefore: false
40+
3741
# Issues and pull requests with these labels will not be locked. Set to `[]` to disable
3842
exemptLabels: []
3943

assets/app-description.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ Create `.github/lock.yml` in the default branch to enable the app. The file can
1818
# Number of days of inactivity before a closed issue or pull request is locked
1919
daysUntilLock: 365
2020

21+
# Skip issues and pull requests created before a given timestamp. Timestamp must
22+
# follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable.
23+
skipCreatedBefore: false
24+
2125
# Issues and pull requests with these labels will not be locked. Set to `[]` to disable
2226
exemptLabels: []
2327

src/lock.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ module.exports = class Lock {
6262
const {owner, repo} = this.context.repo();
6363
const daysUntilLock = this.getConfigValue(type, 'daysUntilLock');
6464
const exemptLabels = this.getConfigValue(type, 'exemptLabels');
65+
const skipCreatedBeforeTimestamp = this.getConfigValue(type, 'skipCreatedBefore');
6566

6667
const timestamp = this.getUpdatedTimestamp(daysUntilLock);
6768

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

82+
if (skipCreatedBeforeTimestamp) {
83+
query += ` created:>${skipCreatedBeforeTimestamp}`;
84+
}
85+
8186
this.log.info({repo: {owner, repo}}, `Searching ${type}`);
8287
return this.context.github.search.issues({
8388
q: query,

src/schema.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ const fields = {
77
'Number of days of inactivity before a closed issue or pull request is locked'
88
),
99

10+
skipCreatedBefore: Joi.alternatives()
11+
.try(Joi.string(), Joi.boolean().only(false))
12+
.description(
13+
'Skip issues and pull requests created before a given timestamp. Timestamp' +
14+
'must follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable.'
15+
),
16+
1017
exemptLabels: Joi.array()
1118
.single()
1219
.items(Joi.string())
@@ -31,6 +38,7 @@ const fields = {
3138

3239
const schema = Joi.object().keys({
3340
daysUntilLock: fields.daysUntilLock.default(365),
41+
skipCreatedBefore: fields.skipCreatedBefore.default(false),
3442
exemptLabels: fields.exemptLabels.default([]),
3543
lockLabel: fields.lockLabel.default(false),
3644
lockComment: fields.lockComment.default(

0 commit comments

Comments
 (0)