mirror of
https://github.com/actions/labeler.git
synced 2025-12-12 12:37:48 +00:00
Compare commits
38 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9fcb2c2f55 | ||
|
|
0d06c50435 | ||
|
|
1d399c3ab6 | ||
|
|
82a4f6fc25 | ||
|
|
d40596e5db | ||
|
|
3cbc54c641 | ||
|
|
639ba81ab1 | ||
|
|
71d2484daa | ||
|
|
59d3310a72 | ||
|
|
a78a6c7eb7 | ||
|
|
54d434dac5 | ||
|
|
d07f38b87f | ||
|
|
e3b3815c8d | ||
|
|
673c7e22a7 | ||
|
|
44414dbc7d | ||
|
|
a27020c135 | ||
|
|
97762039fe | ||
|
|
60f44e7cf1 | ||
|
|
092c979868 | ||
|
|
cecbd94bd4 | ||
|
|
7fef7e3d17 | ||
|
|
012b89238e | ||
|
|
a7cc8a62ef | ||
|
|
b28379f6ed | ||
|
|
b898cc8e29 | ||
|
|
4a96e771de | ||
|
|
305cfeb74c | ||
|
|
866eff55a5 | ||
|
|
b78dba3eb5 | ||
|
|
20251547f9 | ||
|
|
d89797c51d | ||
|
|
f3632d3e9f | ||
|
|
e05b7c1927 | ||
|
|
8b8677b4ce | ||
|
|
920e9b6169 | ||
|
|
409a5a2095 | ||
|
|
6a0b7265cb | ||
|
|
b0d9292064 |
34
README.md
34
README.md
@@ -10,7 +10,7 @@ Automatically label new pull requests based on the paths of files being changed.
|
||||
|
||||
Create a `.github/labeler.yml` file with a list of labels and [minimatch](https://github.com/isaacs/minimatch) globs to match to apply the label.
|
||||
|
||||
The key is the name of the label in your repository that you want to add (eg: "merge conflict", "needs-updating") and the value is the path (glob) of the changed files (eg: `src/**/*`, `tests/*.spec.js`) or a match object.
|
||||
The key is the name of the label in your repository that you want to add (eg: "merge conflict", "needs-updating") and the value is the path (glob) of the changed files (eg: `src/**`, `tests/*.spec.js`) or a match object.
|
||||
|
||||
#### Match Object
|
||||
|
||||
@@ -40,12 +40,17 @@ label1:
|
||||
|
||||
From a boolean logic perspective, top-level match objects are `OR`-ed together and individual match rules within an object are `AND`-ed. Combined with `!` negation, you can write complex matching rules.
|
||||
|
||||
> ⚠️ This action uses [minimatch](https://www.npmjs.com/package/minimatch) to apply glob patterns.
|
||||
> For historical reasons, paths starting with dot (e.g. `.github`) are not matched by default.
|
||||
> You need to set `dot: true` to change this behavior.
|
||||
> See [Inputs](#inputs) table below for details.
|
||||
|
||||
#### Basic Examples
|
||||
|
||||
```yml
|
||||
# Add 'label1' to any changes within 'example' folder or any subfolders
|
||||
label1:
|
||||
- example/**/*
|
||||
- example/**
|
||||
|
||||
# Add 'label2' to any file changes within 'example2' folder
|
||||
label2: example2/*
|
||||
@@ -65,8 +70,7 @@ repo:
|
||||
|
||||
# Add '@domain/core' label to any change within the 'core' package
|
||||
'@domain/core':
|
||||
- package/core/*
|
||||
- package/core/**/*
|
||||
- package/core/**
|
||||
|
||||
# Add 'test' label to any change to *.spec.js files within the source dir
|
||||
test:
|
||||
@@ -74,7 +78,7 @@ test:
|
||||
|
||||
# Add 'source' label to any change to src files within the source dir EXCEPT for the docs sub-folder
|
||||
source:
|
||||
- any: ['src/**/*', '!src/docs/*']
|
||||
- any: ['src/**', '!src/docs/*']
|
||||
|
||||
# Add 'frontend` label to any change to *.js files as long as the `main.js` hasn't changed
|
||||
frontend:
|
||||
@@ -109,8 +113,24 @@ Various inputs are defined in [`action.yml`](action.yml) to let you configure th
|
||||
| - | - | - |
|
||||
| `repo-token` | Token to use to authorize label changes. Typically the GITHUB_TOKEN secret, with `contents:read` and `pull-requests:write` access | `github.token` |
|
||||
| `configuration-path` | The path to the label configuration file | `.github/labeler.yml` |
|
||||
| `sync-labels` | Whether or not to remove labels when matching files are reverted or no longer changed by the PR | `false`|
|
||||
| `sync-labels` | Whether or not to remove labels when matching files are reverted or no longer changed by the PR | `false` |
|
||||
| `dot` | Whether or not to auto-include paths starting with dot (e.g. `.github`) | `false` |
|
||||
|
||||
# Contributions
|
||||
When `dot` is disabled and you want to include _all_ files in a folder:
|
||||
|
||||
```yml
|
||||
label1:
|
||||
- path/to/folder/**/*
|
||||
- path/to/folder/**/.*
|
||||
```
|
||||
|
||||
If `dot` is enabled:
|
||||
|
||||
```yml
|
||||
label1:
|
||||
- path/to/folder/**
|
||||
```
|
||||
|
||||
## Contributions
|
||||
|
||||
Contributions are welcome! See the [Contributor's Guide](CONTRIBUTING.md).
|
||||
|
||||
@@ -15,15 +15,29 @@ const matchConfig = [{any: ['*.txt']}];
|
||||
describe('checkGlobs', () => {
|
||||
it('returns true when our pattern does match changed files', () => {
|
||||
const changedFiles = ['foo.txt', 'bar.txt'];
|
||||
const result = checkGlobs(changedFiles, matchConfig);
|
||||
const result = checkGlobs(changedFiles, matchConfig, false);
|
||||
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
|
||||
it('returns false when our pattern does not match changed files', () => {
|
||||
const changedFiles = ['foo.docx'];
|
||||
const result = checkGlobs(changedFiles, matchConfig);
|
||||
const result = checkGlobs(changedFiles, matchConfig, false);
|
||||
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
|
||||
it('returns false for a file starting with dot if `dot` option is false', () => {
|
||||
const changedFiles = ['.foo.txt'];
|
||||
const result = checkGlobs(changedFiles, matchConfig, false);
|
||||
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
|
||||
it('returns true for a file starting with dot if `dot` option is true', () => {
|
||||
const changedFiles = ['.foo.txt'];
|
||||
const result = checkGlobs(changedFiles, matchConfig, true);
|
||||
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -18,10 +18,27 @@ const yamlFixtures = {
|
||||
'only_pdfs.yml': fs.readFileSync('__tests__/fixtures/only_pdfs.yml')
|
||||
};
|
||||
|
||||
const configureInput = (
|
||||
mockInput: Partial<{
|
||||
'repo-token': string;
|
||||
'configuration-path': string;
|
||||
'sync-labels': boolean;
|
||||
dot: boolean;
|
||||
}>
|
||||
) => {
|
||||
jest
|
||||
.spyOn(core, 'getInput')
|
||||
.mockImplementation((name: string, ...opts) => mockInput[name]);
|
||||
jest
|
||||
.spyOn(core, 'getBooleanInput')
|
||||
.mockImplementation((name: string, ...opts) => mockInput[name]);
|
||||
};
|
||||
|
||||
afterAll(() => jest.restoreAllMocks());
|
||||
|
||||
describe('run', () => {
|
||||
it('adds labels to PRs that match our glob patterns', async () => {
|
||||
it('(with dot: false) adds labels to PRs that match our glob patterns', async () => {
|
||||
configureInput({});
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
mockGitHubResponseChangedFiles('foo.pdf');
|
||||
|
||||
@@ -37,7 +54,36 @@ describe('run', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('does not add labels to PRs that do not match our glob patterns', async () => {
|
||||
it('(with dot: true) adds labels to PRs that match our glob patterns', async () => {
|
||||
configureInput({dot: true});
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
mockGitHubResponseChangedFiles('.foo.pdf');
|
||||
|
||||
await run();
|
||||
|
||||
expect(removeLabelMock).toHaveBeenCalledTimes(0);
|
||||
expect(addLabelsMock).toHaveBeenCalledTimes(1);
|
||||
expect(addLabelsMock).toHaveBeenCalledWith({
|
||||
owner: 'monalisa',
|
||||
repo: 'helloworld',
|
||||
issue_number: 123,
|
||||
labels: ['touched-a-pdf-file']
|
||||
});
|
||||
});
|
||||
|
||||
it('(with dot: false) does not add labels to PRs that do not match our glob patterns', async () => {
|
||||
configureInput({});
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
mockGitHubResponseChangedFiles('.foo.pdf');
|
||||
|
||||
await run();
|
||||
|
||||
expect(removeLabelMock).toHaveBeenCalledTimes(0);
|
||||
expect(addLabelsMock).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
it('(with dot: true) does not add labels to PRs that do not match our glob patterns', async () => {
|
||||
configureInput({dot: true});
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
mockGitHubResponseChangedFiles('foo.txt');
|
||||
|
||||
@@ -48,15 +94,11 @@ describe('run', () => {
|
||||
});
|
||||
|
||||
it('(with sync-labels: true) it deletes preexisting PR labels that no longer match the glob pattern', async () => {
|
||||
const mockInput = {
|
||||
configureInput({
|
||||
'repo-token': 'foo',
|
||||
'configuration-path': 'bar',
|
||||
'sync-labels': true
|
||||
};
|
||||
|
||||
jest
|
||||
.spyOn(core, 'getInput')
|
||||
.mockImplementation((name: string, ...opts) => mockInput[name]);
|
||||
});
|
||||
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
mockGitHubResponseChangedFiles('foo.txt');
|
||||
@@ -79,15 +121,11 @@ describe('run', () => {
|
||||
});
|
||||
|
||||
it('(with sync-labels: false) it issues no delete calls even when there are preexisting PR labels that no longer match the glob pattern', async () => {
|
||||
const mockInput = {
|
||||
configureInput({
|
||||
'repo-token': 'foo',
|
||||
'configuration-path': 'bar',
|
||||
'sync-labels': false
|
||||
};
|
||||
|
||||
jest
|
||||
.spyOn(core, 'getInput')
|
||||
.mockImplementation((name: string, ...opts) => mockInput[name]);
|
||||
});
|
||||
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
mockGitHubResponseChangedFiles('foo.txt');
|
||||
|
||||
@@ -14,6 +14,10 @@ inputs:
|
||||
description: 'Whether or not to remove labels when matching files are reverted'
|
||||
default: false
|
||||
required: false
|
||||
dot:
|
||||
description: 'Whether or not to auto-include paths starting with dot (e.g. `.github`)'
|
||||
default: false
|
||||
required: false
|
||||
|
||||
runs:
|
||||
using: 'node16'
|
||||
|
||||
23
dist/index.js
vendored
23
dist/index.js
vendored
@@ -49,7 +49,8 @@ function run() {
|
||||
try {
|
||||
const token = core.getInput('repo-token');
|
||||
const configPath = core.getInput('configuration-path', { required: true });
|
||||
const syncLabels = !!core.getInput('sync-labels', { required: false });
|
||||
const syncLabels = !!core.getInput('sync-labels');
|
||||
const dot = core.getBooleanInput('dot');
|
||||
const prNumber = getPrNumber();
|
||||
if (!prNumber) {
|
||||
core.info('Could not get pull request number from context, exiting');
|
||||
@@ -68,7 +69,7 @@ function run() {
|
||||
const labelsToRemove = [];
|
||||
for (const [label, globs] of labelGlobs.entries()) {
|
||||
core.debug(`processing ${label}`);
|
||||
if (checkGlobs(changedFiles, globs)) {
|
||||
if (checkGlobs(changedFiles, globs, dot)) {
|
||||
labels.push(label);
|
||||
}
|
||||
else if (pullRequest.labels.find(l => l.name === label)) {
|
||||
@@ -158,11 +159,11 @@ function toMatchConfig(config) {
|
||||
function printPattern(matcher) {
|
||||
return (matcher.negate ? '!' : '') + matcher.pattern;
|
||||
}
|
||||
function checkGlobs(changedFiles, globs) {
|
||||
function checkGlobs(changedFiles, globs, dot) {
|
||||
for (const glob of globs) {
|
||||
core.debug(` checking pattern ${JSON.stringify(glob)}`);
|
||||
const matchConfig = toMatchConfig(glob);
|
||||
if (checkMatch(changedFiles, matchConfig)) {
|
||||
if (checkMatch(changedFiles, matchConfig, dot)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -182,8 +183,8 @@ function isMatch(changedFile, matchers) {
|
||||
return true;
|
||||
}
|
||||
// equivalent to "Array.some()" but expanded for debugging and clarity
|
||||
function checkAny(changedFiles, globs) {
|
||||
const matchers = globs.map(g => new minimatch_1.Minimatch(g));
|
||||
function checkAny(changedFiles, globs, dot) {
|
||||
const matchers = globs.map(g => new minimatch_1.Minimatch(g, { dot }));
|
||||
core.debug(` checking "any" patterns`);
|
||||
for (const changedFile of changedFiles) {
|
||||
if (isMatch(changedFile, matchers)) {
|
||||
@@ -195,8 +196,8 @@ function checkAny(changedFiles, globs) {
|
||||
return false;
|
||||
}
|
||||
// equivalent to "Array.every()" but expanded for debugging and clarity
|
||||
function checkAll(changedFiles, globs) {
|
||||
const matchers = globs.map(g => new minimatch_1.Minimatch(g));
|
||||
function checkAll(changedFiles, globs, dot) {
|
||||
const matchers = globs.map(g => new minimatch_1.Minimatch(g, { dot }));
|
||||
core.debug(` checking "all" patterns`);
|
||||
for (const changedFile of changedFiles) {
|
||||
if (!isMatch(changedFile, matchers)) {
|
||||
@@ -207,14 +208,14 @@ function checkAll(changedFiles, globs) {
|
||||
core.debug(` "all" patterns matched all files`);
|
||||
return true;
|
||||
}
|
||||
function checkMatch(changedFiles, matchConfig) {
|
||||
function checkMatch(changedFiles, matchConfig, dot) {
|
||||
if (matchConfig.all !== undefined) {
|
||||
if (!checkAll(changedFiles, matchConfig.all)) {
|
||||
if (!checkAll(changedFiles, matchConfig.all, dot)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (matchConfig.any !== undefined) {
|
||||
if (!checkAny(changedFiles, matchConfig.any)) {
|
||||
if (!checkAny(changedFiles, matchConfig.any, dot)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
164
package-lock.json
generated
164
package-lock.json
generated
@@ -19,8 +19,8 @@
|
||||
"@types/js-yaml": "^4.0.5",
|
||||
"@types/minimatch": "^5.1.2",
|
||||
"@types/node": "^16.11.7",
|
||||
"@typescript-eslint/eslint-plugin": "^5.59.7",
|
||||
"@typescript-eslint/parser": "^5.59.7",
|
||||
"@typescript-eslint/eslint-plugin": "^5.59.8",
|
||||
"@typescript-eslint/parser": "^5.59.8",
|
||||
"@vercel/ncc": "^0.36.1",
|
||||
"eslint": "^8.41.0",
|
||||
"eslint-config-prettier": "^8.8.0",
|
||||
@@ -1423,15 +1423,15 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||
"version": "5.59.7",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.7.tgz",
|
||||
"integrity": "sha512-BL+jYxUFIbuYwy+4fF86k5vdT9lT0CNJ6HtwrIvGh0PhH8s0yy5rjaKH2fDCrz5ITHy07WCzVGNvAmjJh4IJFA==",
|
||||
"version": "5.59.8",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.8.tgz",
|
||||
"integrity": "sha512-JDMOmhXteJ4WVKOiHXGCoB96ADWg9q7efPWHRViT/f09bA8XOMLAVHHju3l0MkZnG1izaWXYmgvQcUjTRcpShQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@eslint-community/regexpp": "^4.4.0",
|
||||
"@typescript-eslint/scope-manager": "5.59.7",
|
||||
"@typescript-eslint/type-utils": "5.59.7",
|
||||
"@typescript-eslint/utils": "5.59.7",
|
||||
"@typescript-eslint/scope-manager": "5.59.8",
|
||||
"@typescript-eslint/type-utils": "5.59.8",
|
||||
"@typescript-eslint/utils": "5.59.8",
|
||||
"debug": "^4.3.4",
|
||||
"grapheme-splitter": "^1.0.4",
|
||||
"ignore": "^5.2.0",
|
||||
@@ -1490,14 +1490,14 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@typescript-eslint/parser": {
|
||||
"version": "5.59.7",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.59.7.tgz",
|
||||
"integrity": "sha512-VhpsIEuq/8i5SF+mPg9jSdIwgMBBp0z9XqjiEay+81PYLJuroN+ET1hM5IhkiYMJd9MkTz8iJLt7aaGAgzWUbQ==",
|
||||
"version": "5.59.8",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.59.8.tgz",
|
||||
"integrity": "sha512-AnR19RjJcpjoeGojmwZtCwBX/RidqDZtzcbG3xHrmz0aHHoOcbWnpDllenRDmDvsV0RQ6+tbb09/kyc+UT9Orw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/scope-manager": "5.59.7",
|
||||
"@typescript-eslint/types": "5.59.7",
|
||||
"@typescript-eslint/typescript-estree": "5.59.7",
|
||||
"@typescript-eslint/scope-manager": "5.59.8",
|
||||
"@typescript-eslint/types": "5.59.8",
|
||||
"@typescript-eslint/typescript-estree": "5.59.8",
|
||||
"debug": "^4.3.4"
|
||||
},
|
||||
"engines": {
|
||||
@@ -1517,13 +1517,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/scope-manager": {
|
||||
"version": "5.59.7",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.59.7.tgz",
|
||||
"integrity": "sha512-FL6hkYWK9zBGdxT2wWEd2W8ocXMu3K94i3gvMrjXpx+koFYdYV7KprKfirpgY34vTGzEPPuKoERpP8kD5h7vZQ==",
|
||||
"version": "5.59.8",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.59.8.tgz",
|
||||
"integrity": "sha512-/w08ndCYI8gxGf+9zKf1vtx/16y8MHrZs5/tnjHhMLNSixuNcJavSX4wAiPf4aS5x41Es9YPCn44MIe4cxIlig==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "5.59.7",
|
||||
"@typescript-eslint/visitor-keys": "5.59.7"
|
||||
"@typescript-eslint/types": "5.59.8",
|
||||
"@typescript-eslint/visitor-keys": "5.59.8"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
@@ -1534,13 +1534,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/type-utils": {
|
||||
"version": "5.59.7",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.59.7.tgz",
|
||||
"integrity": "sha512-ozuz/GILuYG7osdY5O5yg0QxXUAEoI4Go3Do5xeu+ERH9PorHBPSdvD3Tjp2NN2bNLh1NJQSsQu2TPu/Ly+HaQ==",
|
||||
"version": "5.59.8",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.59.8.tgz",
|
||||
"integrity": "sha512-+5M518uEIHFBy3FnyqZUF3BMP+AXnYn4oyH8RF012+e7/msMY98FhGL5SrN29NQ9xDgvqCgYnsOiKp1VjZ/fpA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/typescript-estree": "5.59.7",
|
||||
"@typescript-eslint/utils": "5.59.7",
|
||||
"@typescript-eslint/typescript-estree": "5.59.8",
|
||||
"@typescript-eslint/utils": "5.59.8",
|
||||
"debug": "^4.3.4",
|
||||
"tsutils": "^3.21.0"
|
||||
},
|
||||
@@ -1561,9 +1561,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/types": {
|
||||
"version": "5.59.7",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.59.7.tgz",
|
||||
"integrity": "sha512-UnVS2MRRg6p7xOSATscWkKjlf/NDKuqo5TdbWck6rIRZbmKpVNTLALzNvcjIfHBE7736kZOFc/4Z3VcZwuOM/A==",
|
||||
"version": "5.59.8",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.59.8.tgz",
|
||||
"integrity": "sha512-+uWuOhBTj/L6awoWIg0BlWy0u9TyFpCHrAuQ5bNfxDaZ1Ppb3mx6tUigc74LHcbHpOHuOTOJrBoAnhdHdaea1w==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
@@ -1574,13 +1574,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/typescript-estree": {
|
||||
"version": "5.59.7",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.7.tgz",
|
||||
"integrity": "sha512-4A1NtZ1I3wMN2UGDkU9HMBL+TIQfbrh4uS0WDMMpf3xMRursDbqEf1ahh6vAAe3mObt8k3ZATnezwG4pdtWuUQ==",
|
||||
"version": "5.59.8",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.8.tgz",
|
||||
"integrity": "sha512-Jy/lPSDJGNow14vYu6IrW790p7HIf/SOV1Bb6lZ7NUkLc2iB2Z9elESmsaUtLw8kVqogSbtLH9tut5GCX1RLDg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "5.59.7",
|
||||
"@typescript-eslint/visitor-keys": "5.59.7",
|
||||
"@typescript-eslint/types": "5.59.8",
|
||||
"@typescript-eslint/visitor-keys": "5.59.8",
|
||||
"debug": "^4.3.4",
|
||||
"globby": "^11.1.0",
|
||||
"is-glob": "^4.0.3",
|
||||
@@ -1634,17 +1634,17 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@typescript-eslint/utils": {
|
||||
"version": "5.59.7",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.59.7.tgz",
|
||||
"integrity": "sha512-yCX9WpdQKaLufz5luG4aJbOpdXf/fjwGMcLFXZVPUz3QqLirG5QcwwnIHNf8cjLjxK4qtzTO8udUtMQSAToQnQ==",
|
||||
"version": "5.59.8",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.59.8.tgz",
|
||||
"integrity": "sha512-Tr65630KysnNn9f9G7ROF3w1b5/7f6QVCJ+WK9nhIocWmx9F+TmCAcglF26Vm7z8KCTwoKcNEBZrhlklla3CKg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.2.0",
|
||||
"@types/json-schema": "^7.0.9",
|
||||
"@types/semver": "^7.3.12",
|
||||
"@typescript-eslint/scope-manager": "5.59.7",
|
||||
"@typescript-eslint/types": "5.59.7",
|
||||
"@typescript-eslint/typescript-estree": "5.59.7",
|
||||
"@typescript-eslint/scope-manager": "5.59.8",
|
||||
"@typescript-eslint/types": "5.59.8",
|
||||
"@typescript-eslint/typescript-estree": "5.59.8",
|
||||
"eslint-scope": "^5.1.1",
|
||||
"semver": "^7.3.7"
|
||||
},
|
||||
@@ -1693,12 +1693,12 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@typescript-eslint/visitor-keys": {
|
||||
"version": "5.59.7",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.7.tgz",
|
||||
"integrity": "sha512-tyN+X2jvMslUszIiYbF0ZleP+RqQsFVpGrKI6e0Eet1w8WmhsAtmzaqm8oM8WJQ1ysLwhnsK/4hYHJjOgJVfQQ==",
|
||||
"version": "5.59.8",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.8.tgz",
|
||||
"integrity": "sha512-pJhi2ms0x0xgloT7xYabil3SGGlojNNKjK/q6dB3Ey0uJLMjK2UDGJvHieiyJVW/7C3KI+Z4Q3pEHkm4ejA+xQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "5.59.7",
|
||||
"@typescript-eslint/types": "5.59.8",
|
||||
"eslint-visitor-keys": "^3.3.0"
|
||||
},
|
||||
"engines": {
|
||||
@@ -6996,15 +6996,15 @@
|
||||
"dev": true
|
||||
},
|
||||
"@typescript-eslint/eslint-plugin": {
|
||||
"version": "5.59.7",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.7.tgz",
|
||||
"integrity": "sha512-BL+jYxUFIbuYwy+4fF86k5vdT9lT0CNJ6HtwrIvGh0PhH8s0yy5rjaKH2fDCrz5ITHy07WCzVGNvAmjJh4IJFA==",
|
||||
"version": "5.59.8",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.8.tgz",
|
||||
"integrity": "sha512-JDMOmhXteJ4WVKOiHXGCoB96ADWg9q7efPWHRViT/f09bA8XOMLAVHHju3l0MkZnG1izaWXYmgvQcUjTRcpShQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@eslint-community/regexpp": "^4.4.0",
|
||||
"@typescript-eslint/scope-manager": "5.59.7",
|
||||
"@typescript-eslint/type-utils": "5.59.7",
|
||||
"@typescript-eslint/utils": "5.59.7",
|
||||
"@typescript-eslint/scope-manager": "5.59.8",
|
||||
"@typescript-eslint/type-utils": "5.59.8",
|
||||
"@typescript-eslint/utils": "5.59.8",
|
||||
"debug": "^4.3.4",
|
||||
"grapheme-splitter": "^1.0.4",
|
||||
"ignore": "^5.2.0",
|
||||
@@ -7040,53 +7040,53 @@
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/parser": {
|
||||
"version": "5.59.7",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.59.7.tgz",
|
||||
"integrity": "sha512-VhpsIEuq/8i5SF+mPg9jSdIwgMBBp0z9XqjiEay+81PYLJuroN+ET1hM5IhkiYMJd9MkTz8iJLt7aaGAgzWUbQ==",
|
||||
"version": "5.59.8",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.59.8.tgz",
|
||||
"integrity": "sha512-AnR19RjJcpjoeGojmwZtCwBX/RidqDZtzcbG3xHrmz0aHHoOcbWnpDllenRDmDvsV0RQ6+tbb09/kyc+UT9Orw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/scope-manager": "5.59.7",
|
||||
"@typescript-eslint/types": "5.59.7",
|
||||
"@typescript-eslint/typescript-estree": "5.59.7",
|
||||
"@typescript-eslint/scope-manager": "5.59.8",
|
||||
"@typescript-eslint/types": "5.59.8",
|
||||
"@typescript-eslint/typescript-estree": "5.59.8",
|
||||
"debug": "^4.3.4"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/scope-manager": {
|
||||
"version": "5.59.7",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.59.7.tgz",
|
||||
"integrity": "sha512-FL6hkYWK9zBGdxT2wWEd2W8ocXMu3K94i3gvMrjXpx+koFYdYV7KprKfirpgY34vTGzEPPuKoERpP8kD5h7vZQ==",
|
||||
"version": "5.59.8",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.59.8.tgz",
|
||||
"integrity": "sha512-/w08ndCYI8gxGf+9zKf1vtx/16y8MHrZs5/tnjHhMLNSixuNcJavSX4wAiPf4aS5x41Es9YPCn44MIe4cxIlig==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/types": "5.59.7",
|
||||
"@typescript-eslint/visitor-keys": "5.59.7"
|
||||
"@typescript-eslint/types": "5.59.8",
|
||||
"@typescript-eslint/visitor-keys": "5.59.8"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/type-utils": {
|
||||
"version": "5.59.7",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.59.7.tgz",
|
||||
"integrity": "sha512-ozuz/GILuYG7osdY5O5yg0QxXUAEoI4Go3Do5xeu+ERH9PorHBPSdvD3Tjp2NN2bNLh1NJQSsQu2TPu/Ly+HaQ==",
|
||||
"version": "5.59.8",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.59.8.tgz",
|
||||
"integrity": "sha512-+5M518uEIHFBy3FnyqZUF3BMP+AXnYn4oyH8RF012+e7/msMY98FhGL5SrN29NQ9xDgvqCgYnsOiKp1VjZ/fpA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/typescript-estree": "5.59.7",
|
||||
"@typescript-eslint/utils": "5.59.7",
|
||||
"@typescript-eslint/typescript-estree": "5.59.8",
|
||||
"@typescript-eslint/utils": "5.59.8",
|
||||
"debug": "^4.3.4",
|
||||
"tsutils": "^3.21.0"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/types": {
|
||||
"version": "5.59.7",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.59.7.tgz",
|
||||
"integrity": "sha512-UnVS2MRRg6p7xOSATscWkKjlf/NDKuqo5TdbWck6rIRZbmKpVNTLALzNvcjIfHBE7736kZOFc/4Z3VcZwuOM/A==",
|
||||
"version": "5.59.8",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.59.8.tgz",
|
||||
"integrity": "sha512-+uWuOhBTj/L6awoWIg0BlWy0u9TyFpCHrAuQ5bNfxDaZ1Ppb3mx6tUigc74LHcbHpOHuOTOJrBoAnhdHdaea1w==",
|
||||
"dev": true
|
||||
},
|
||||
"@typescript-eslint/typescript-estree": {
|
||||
"version": "5.59.7",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.7.tgz",
|
||||
"integrity": "sha512-4A1NtZ1I3wMN2UGDkU9HMBL+TIQfbrh4uS0WDMMpf3xMRursDbqEf1ahh6vAAe3mObt8k3ZATnezwG4pdtWuUQ==",
|
||||
"version": "5.59.8",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.8.tgz",
|
||||
"integrity": "sha512-Jy/lPSDJGNow14vYu6IrW790p7HIf/SOV1Bb6lZ7NUkLc2iB2Z9elESmsaUtLw8kVqogSbtLH9tut5GCX1RLDg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/types": "5.59.7",
|
||||
"@typescript-eslint/visitor-keys": "5.59.7",
|
||||
"@typescript-eslint/types": "5.59.8",
|
||||
"@typescript-eslint/visitor-keys": "5.59.8",
|
||||
"debug": "^4.3.4",
|
||||
"globby": "^11.1.0",
|
||||
"is-glob": "^4.0.3",
|
||||
@@ -7121,17 +7121,17 @@
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/utils": {
|
||||
"version": "5.59.7",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.59.7.tgz",
|
||||
"integrity": "sha512-yCX9WpdQKaLufz5luG4aJbOpdXf/fjwGMcLFXZVPUz3QqLirG5QcwwnIHNf8cjLjxK4qtzTO8udUtMQSAToQnQ==",
|
||||
"version": "5.59.8",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.59.8.tgz",
|
||||
"integrity": "sha512-Tr65630KysnNn9f9G7ROF3w1b5/7f6QVCJ+WK9nhIocWmx9F+TmCAcglF26Vm7z8KCTwoKcNEBZrhlklla3CKg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@eslint-community/eslint-utils": "^4.2.0",
|
||||
"@types/json-schema": "^7.0.9",
|
||||
"@types/semver": "^7.3.12",
|
||||
"@typescript-eslint/scope-manager": "5.59.7",
|
||||
"@typescript-eslint/types": "5.59.7",
|
||||
"@typescript-eslint/typescript-estree": "5.59.7",
|
||||
"@typescript-eslint/scope-manager": "5.59.8",
|
||||
"@typescript-eslint/types": "5.59.8",
|
||||
"@typescript-eslint/typescript-estree": "5.59.8",
|
||||
"eslint-scope": "^5.1.1",
|
||||
"semver": "^7.3.7"
|
||||
},
|
||||
@@ -7163,12 +7163,12 @@
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/visitor-keys": {
|
||||
"version": "5.59.7",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.7.tgz",
|
||||
"integrity": "sha512-tyN+X2jvMslUszIiYbF0ZleP+RqQsFVpGrKI6e0Eet1w8WmhsAtmzaqm8oM8WJQ1ysLwhnsK/4hYHJjOgJVfQQ==",
|
||||
"version": "5.59.8",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.8.tgz",
|
||||
"integrity": "sha512-pJhi2ms0x0xgloT7xYabil3SGGlojNNKjK/q6dB3Ey0uJLMjK2UDGJvHieiyJVW/7C3KI+Z4Q3pEHkm4ejA+xQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/types": "5.59.7",
|
||||
"@typescript-eslint/types": "5.59.8",
|
||||
"eslint-visitor-keys": "^3.3.0"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -34,8 +34,8 @@
|
||||
"@types/js-yaml": "^4.0.5",
|
||||
"@types/minimatch": "^5.1.2",
|
||||
"@types/node": "^16.11.7",
|
||||
"@typescript-eslint/eslint-plugin": "^5.59.7",
|
||||
"@typescript-eslint/parser": "^5.59.7",
|
||||
"@typescript-eslint/eslint-plugin": "^5.59.8",
|
||||
"@typescript-eslint/parser": "^5.59.8",
|
||||
"@vercel/ncc": "^0.36.1",
|
||||
"eslint": "^8.41.0",
|
||||
"eslint-config-prettier": "^8.8.0",
|
||||
|
||||
@@ -15,7 +15,8 @@ export async function run() {
|
||||
try {
|
||||
const token = core.getInput('repo-token');
|
||||
const configPath = core.getInput('configuration-path', {required: true});
|
||||
const syncLabels = !!core.getInput('sync-labels', {required: false});
|
||||
const syncLabels = !!core.getInput('sync-labels');
|
||||
const dot = core.getBooleanInput('dot');
|
||||
|
||||
const prNumber = getPrNumber();
|
||||
if (!prNumber) {
|
||||
@@ -42,7 +43,7 @@ export async function run() {
|
||||
const labelsToRemove: string[] = [];
|
||||
for (const [label, globs] of labelGlobs.entries()) {
|
||||
core.debug(`processing ${label}`);
|
||||
if (checkGlobs(changedFiles, globs)) {
|
||||
if (checkGlobs(changedFiles, globs, dot)) {
|
||||
labels.push(label);
|
||||
} else if (pullRequest.labels.find(l => l.name === label)) {
|
||||
labelsToRemove.push(label);
|
||||
@@ -157,12 +158,13 @@ function printPattern(matcher: Minimatch): string {
|
||||
|
||||
export function checkGlobs(
|
||||
changedFiles: string[],
|
||||
globs: StringOrMatchConfig[]
|
||||
globs: StringOrMatchConfig[],
|
||||
dot: boolean
|
||||
): boolean {
|
||||
for (const glob of globs) {
|
||||
core.debug(` checking pattern ${JSON.stringify(glob)}`);
|
||||
const matchConfig = toMatchConfig(glob);
|
||||
if (checkMatch(changedFiles, matchConfig)) {
|
||||
if (checkMatch(changedFiles, matchConfig, dot)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -184,8 +186,12 @@ function isMatch(changedFile: string, matchers: Minimatch[]): boolean {
|
||||
}
|
||||
|
||||
// equivalent to "Array.some()" but expanded for debugging and clarity
|
||||
function checkAny(changedFiles: string[], globs: string[]): boolean {
|
||||
const matchers = globs.map(g => new Minimatch(g));
|
||||
function checkAny(
|
||||
changedFiles: string[],
|
||||
globs: string[],
|
||||
dot: boolean
|
||||
): boolean {
|
||||
const matchers = globs.map(g => new Minimatch(g, {dot}));
|
||||
core.debug(` checking "any" patterns`);
|
||||
for (const changedFile of changedFiles) {
|
||||
if (isMatch(changedFile, matchers)) {
|
||||
@@ -199,8 +205,12 @@ function checkAny(changedFiles: string[], globs: string[]): boolean {
|
||||
}
|
||||
|
||||
// equivalent to "Array.every()" but expanded for debugging and clarity
|
||||
function checkAll(changedFiles: string[], globs: string[]): boolean {
|
||||
const matchers = globs.map(g => new Minimatch(g));
|
||||
function checkAll(
|
||||
changedFiles: string[],
|
||||
globs: string[],
|
||||
dot: boolean
|
||||
): boolean {
|
||||
const matchers = globs.map(g => new Minimatch(g, {dot}));
|
||||
core.debug(` checking "all" patterns`);
|
||||
for (const changedFile of changedFiles) {
|
||||
if (!isMatch(changedFile, matchers)) {
|
||||
@@ -213,15 +223,19 @@ function checkAll(changedFiles: string[], globs: string[]): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkMatch(changedFiles: string[], matchConfig: MatchConfig): boolean {
|
||||
function checkMatch(
|
||||
changedFiles: string[],
|
||||
matchConfig: MatchConfig,
|
||||
dot: boolean
|
||||
): boolean {
|
||||
if (matchConfig.all !== undefined) {
|
||||
if (!checkAll(changedFiles, matchConfig.all)) {
|
||||
if (!checkAll(changedFiles, matchConfig.all, dot)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (matchConfig.any !== undefined) {
|
||||
if (!checkAny(changedFiles, matchConfig.any)) {
|
||||
if (!checkAny(changedFiles, matchConfig.any, dot)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user