Skip to content

Commit

Permalink
Upgrade matcher library
Browse files Browse the repository at this point in the history
Fixes issue where a label was always added when configured with an empty list, e.g.:

```yaml
dont-add: []
```
  • Loading branch information
TimonVS committed Nov 15, 2022
1 parent 7f16a21 commit adbeb0d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 18 deletions.
1 change: 1 addition & 0 deletions __tests__/fixtures/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ fix: fix/*
chore: chore/*
release: ['release/*', 'hotfix/*', '!release/skip-*']
skip-release: release/skip-*
dont-add: []
45 changes: 34 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@actions/core": "^1.10.0",
"@actions/github": "^5.1.1",
"matcher": "^2.0.0"
"matcher": "^4.0.0"
},
"devDependencies": {
"@types/jest": "^29.2.2",
Expand Down
4 changes: 1 addition & 3 deletions src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as github from '@actions/github';
import { Context } from '@actions/github/lib/context';
import matcher from 'matcher';
import getConfig, { Config } from './utils/config';
import { arrayify } from './utils/arrayify';

const defaultConfig = {
feature: ['feature/*', 'feat/*'],
Expand Down Expand Up @@ -48,8 +47,7 @@ function getLabelsToAdd(config: Config, branchName: string): string[] {
const labelsToAdd: string[] = [];

for (const label in config) {
const patterns = arrayify(config[label]);
const matches = matcher([branchName], patterns);
const matches = matcher(branchName, config[label]);

if (matches.length > 0) {
labelsToAdd.push(label);
Expand Down
3 changes: 0 additions & 3 deletions src/utils/arrayify.ts

This file was deleted.

0 comments on commit adbeb0d

Please sign in to comment.