Skip to content

Commit

Permalink
fix: support filtering threads by labels with spaces
Browse files Browse the repository at this point in the history
Closes #40.
  • Loading branch information
dessant committed Nov 22, 2023
1 parent d42e5f4 commit 0a63678
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,15 @@ jobs:
### Filtering issues, pull requests and discussions

This step will lock only issues, and exclude issues created before 2018,
or those with the `upstream` or `help-wanted` labels applied.
or those with the `help wanted` or `upstream` labels applied.

<!-- prettier-ignore -->
```yaml
steps:
- uses: dessant/lock-threads@v5
with:
exclude-issue-created-before: '2018-01-01T00:00:00Z'
exclude-any-issue-labels: 'upstream, help-wanted'
exclude-any-issue-labels: 'help wanted, upstream'
process-only: 'issues'
```

Expand Down Expand Up @@ -393,20 +393,19 @@ labels applied.
include-any-issue-labels: 'incomplete, invalid'
include-all-pr-labels: 'qa: done, published'
process-only: 'issues, prs'

```

This step will lock discussions that have not had any activity
in the past 180 days.
in the past 180 days, and have the `qa: verified` label applied.

<!-- prettier-ignore -->
```yaml
steps:
- uses: dessant/lock-threads@v5
with:
discussion-inactive-days: '180'
include-any-discussion-labels: 'qa: verified'
process-only: 'discussions'

```

### Commenting and labeling
Expand Down
8 changes: 6 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,16 @@ class App {
.map(label => `label:"${label}"`)
.join(' ')}`;
} else if (includeAnyLabels) {
query += ` label:${includeAnyLabels.join(',')}`;
query += ` label:${includeAnyLabels
.map(label => `"${label}"`)
.join(',')}`;
}

const excludeAnyLabels = this.config[`exclude-any-${threadType}-labels`];
if (excludeAnyLabels) {
query += ` -label:${excludeAnyLabels.join(',')}`;
query += ` -label:${excludeAnyLabels
.map(label => `"${label}"`)
.join(',')}`;
}

const excludeCreatedQuery = this.getFilterByDateQuery({
Expand Down
5 changes: 4 additions & 1 deletion src/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ const extendedJoi = Joi.extend(joi => {
if (value) {
value = value
.split(',')
.map(item => item.trim())
.map(item =>
// remove quotes around list item
item.replace(/^\s*["'](.+)["']\s*$/, '$1').trim()
)
.filter(Boolean);
}

Expand Down

0 comments on commit 0a63678

Please sign in to comment.