Skip to content
This repository has been archived by the owner on May 20, 2023. It is now read-only.

Commit

Permalink
Merge pull request #172 from christianbundy/exempt-assignees
Browse files Browse the repository at this point in the history
Add ability to ignore issues with an assignee
  • Loading branch information
JasonEtco authored Dec 17, 2018
2 parents cb88632 + 5d09a9e commit 5843b68
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ exemptProjects: false
# Set to true to ignore issues in a milestone (defaults to false)
exemptMilestones: false

# Set to true to ignore issues with an assignee (defaults to false)
exemptAssignees: false

# Label to use when marking as stale
staleLabel: wontfix

Expand Down
4 changes: 4 additions & 0 deletions lib/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const fields = {
exemptMilestones: Joi.boolean()
.description('Set to true to ignore issues in a milestone (defaults to false)'),

exemptAssignees: Joi.boolean()
.description('Set to true to ignore issues with an assignee (defaults to false)'),

staleLabel: Joi.string()
.description('Label to use when marking as stale'),

Expand All @@ -43,6 +46,7 @@ const schema = Joi.object().keys({
exemptLabels: fields.exemptLabels.default(['pinned', 'security']),
exemptProjects: fields.exemptProjects.default(false),
exemptMilestones: fields.exemptMilestones.default(false),
exemptAssignees: fields.exemptMilestones.default(false),
staleLabel: fields.staleLabel.default('wontfix'),
markComment: fields.markComment.default(
'This issue has been automatically marked as stale because ' +
Expand Down
2 changes: 2 additions & 0 deletions lib/stale.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ module.exports = class Stale {
const exemptLabels = this.getConfigValue(type, 'exemptLabels')
const exemptProjects = this.getConfigValue(type, 'exemptProjects')
const exemptMilestones = this.getConfigValue(type, 'exemptMilestones')
const exemptAssignees = this.getConfigValue(type, 'exemptAssignees')
const labels = [staleLabel].concat(exemptLabels)
const queryParts = labels.map(label => `-label:"${label}"`)
queryParts.push(Stale.getQueryTypeRestriction(type))

queryParts.push(exemptProjects ? 'no:project' : '')
queryParts.push(exemptMilestones ? 'no:milestone' : '')
queryParts.push(exemptAssignees ? 'no:assignee' : '')

const query = queryParts.join(' ')
const days = this.getConfigValue(type, 'days') || this.getConfigValue(type, 'daysUntilStale')
Expand Down
4 changes: 4 additions & 0 deletions test/schema.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const validConfigs = [
[{ exemptProjects: false }],
[{ exemptMilestones: true }],
[{ exemptMilestones: false }],
[{ exemptAssignees: true }],
[{ exemptAssignees: false }],
[{ staleLabel: 'stale' }],
[{ markComment: 'stale yo' }],
[{ markComment: false }],
Expand All @@ -33,6 +35,7 @@ const invalidConfigs = [
[{ daysUntilClose: true }, 'must be a number or false'],
[{ exemptProjects: 'nope' }, 'must be a boolean'],
[{ exemptMilestones: 'nope' }, 'must be a boolean'],
[{ exemptAssignees: 'nope' }, 'must be a boolean'],
[{ staleLabel: '' }, 'not allowed to be empty'],
[{ staleLabel: false }, 'must be a string'],
[{ staleLabel: ['a', 'b'] }, 'must be a string'],
Expand All @@ -58,6 +61,7 @@ describe('schema', () => {
exemptLabels: ['pinned', 'security'],
exemptProjects: false,
exemptMilestones: false,
exemptAssignees: false,
staleLabel: 'wontfix',
perform: true,
markComment: 'This issue has been automatically marked as stale because ' +
Expand Down

0 comments on commit 5843b68

Please sign in to comment.