From 54f37035de4da94142f10f4ad576c04869f4150e Mon Sep 17 00:00:00 2001 From: Sargun Vohra Date: Mon, 15 Mar 2021 14:34:06 -0700 Subject: [PATCH 01/25] Remove response.data.status check It's perfectly valid for a head to be "behind" a base when comparing commits for pull request events. For example, PRing a feature branch of `main` while other commits have landed on `main` after the feature branch was started but before the PR was created, or a PR to merge a "development" branch onto a slower moving "release" branch that has some hotfixes on it. --- src/main.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/main.ts b/src/main.ts index 0f0fdd6..7c41c07 100644 --- a/src/main.ts +++ b/src/main.ts @@ -74,14 +74,6 @@ async function run(): Promise { ) } - // Ensure that the head commit is ahead of the base commit. - if (response.data.status !== 'ahead') { - core.setFailed( - `The head commit for this ${context.eventName} event is not ahead of the base commit. ` + - "Please submit an issue on this action's GitHub repo." - ) - } - // Get the changed files from the response payload. const files = response.data.files const all = [] as string[], From 900e9d7f557f812f4ffde7037c86ba8f08f4e94c Mon Sep 17 00:00:00 2001 From: Sargun Vohra Date: Mon, 15 Mar 2021 14:36:54 -0700 Subject: [PATCH 02/25] build --- dist/index.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/dist/index.js b/dist/index.js index 72c1662..56e1f8b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3565,11 +3565,6 @@ function run() { core.setFailed(`The GitHub API for comparing the base and head commits for this ${github_1.context.eventName} event returned ${response.status}, expected 200. ` + "Please submit an issue on this action's GitHub repo."); } - // Ensure that the head commit is ahead of the base commit. - if (response.data.status !== 'ahead') { - core.setFailed(`The head commit for this ${github_1.context.eventName} event is not ahead of the base commit. ` + - "Please submit an issue on this action's GitHub repo."); - } // Get the changed files from the response payload. const files = response.data.files; const all = [], added = [], modified = [], removed = [], renamed = [], addedModified = []; From 1beff3279ca32d1a505f9e7e5124caefd3227355 Mon Sep 17 00:00:00 2001 From: Ana Maria Martinez Gomez Date: Wed, 19 May 2021 22:42:03 +0200 Subject: [PATCH 03/25] Support pull_request_target `pull_request_target` is granted a read/write repository token and runs in the context of the base of the pull request. It allows to create workflows that label and comment on pull requests based on the contents of the event payload. The `get-changed-files` action is useful for some of those actions and the code works for this case with almost no modification. --- README.md | 2 +- dist/index.js | 1 + src/main.ts | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3f4401b..51860f8 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ # Get All Changed Files -Get all of the files changed/modified in a pull request or push's commits. +Get all of the files changed/modified in a pull request (`pull_request` or `pull_request_target`) or push's commits. You can choose to get all changed files, only added files, only modified files, only removed files, only renamed files, or all added and modified files. These outputs are available via the `steps` output context. The `steps` output context exposes the output names `all`, `added`, `modified`, `removed`, `renamed`, and `added_modified`. diff --git a/dist/index.js b/dist/index.js index 72c1662..cf95355 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3529,6 +3529,7 @@ function run() { let base; let head; switch (eventName) { + case 'pull_request_target': case 'pull_request': base = (_b = (_a = github_1.context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.base) === null || _b === void 0 ? void 0 : _b.sha; head = (_d = (_c = github_1.context.payload.pull_request) === null || _c === void 0 ? void 0 : _c.head) === null || _d === void 0 ? void 0 : _d.sha; diff --git a/src/main.ts b/src/main.ts index 0f0fdd6..307b988 100644 --- a/src/main.ts +++ b/src/main.ts @@ -26,6 +26,7 @@ async function run(): Promise { let head: string | undefined switch (eventName) { + case 'pull_request_target': case 'pull_request': base = context.payload.pull_request?.base?.sha head = context.payload.pull_request?.head?.sha From c55c40899de56eede1f70bedf665c2aa5c005509 Mon Sep 17 00:00:00 2001 From: Ana Maria Martinez Gomez Date: Wed, 26 May 2021 16:32:14 +0200 Subject: [PATCH 04/25] Update node to a newer version Fix tests. --- package.json | 4 ++-- yarn.lock | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index d6c348a..1279abb 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ ], "main": "lib/main.js", "engines": { - "node": "^12.0.0" + "node": "^14.17.0" }, "scripts": { "build": "tsc", @@ -45,7 +45,7 @@ "devDependencies": { "@octokit/rest": "^16.40.2", "@types/jest": "^25.1.1", - "@types/node": "^12.12.29", + "@types/node": "^14.17.0", "@typescript-eslint/parser": "^2.8.0", "@zeit/ncc": "^0.21.0", "eslint": "^6.8.0", diff --git a/yarn.lock b/yarn.lock index 353d5f9..d46c300 100644 --- a/yarn.lock +++ b/yarn.lock @@ -613,10 +613,10 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-13.9.3.tgz#6356df2647de9eac569f9a52eda3480fa9e70b4d" integrity sha512-01s+ac4qerwd6RHD+mVbOEsraDHSgUaefQlEdBbUolnQFjKwCr7luvAlEwW1RFojh67u0z4OUTjPn9LEl4zIkA== -"@types/node@^12.12.29": - version "12.12.30" - resolved "https://registry.yarnpkg.com/@types/node/-/node-12.12.30.tgz#3501e6f09b954de9c404671cefdbcc5d9d7c45f6" - integrity sha512-sz9MF/zk6qVr3pAnM0BSQvYIBK44tS75QC5N+VbWSE4DjCV/pJ+UzCW/F+vVnl7TkOPcuwQureKNtSSwjBTaMg== +"@types/node@^14.17.0": + version "14.17.1" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.17.1.tgz#5e07e0cb2ff793aa7a1b41deae76221e6166049f" + integrity sha512-/tpUyFD7meeooTRwl3sYlihx2BrJE7q9XF71EguPFIySj9B7qgnRtHsHTho+0AUm4m1SvWGm6uSncrR94q6Vtw== "@types/normalize-package-data@^2.4.0": version "2.4.0" From 494461cb1ce3e87c94ffb285cb2601a5cdc46450 Mon Sep 17 00:00:00 2001 From: Ana Maria Martinez Gomez Date: Wed, 26 May 2021 16:39:04 +0200 Subject: [PATCH 05/25] Rename master branch => main https://github.blog/changelog/2020-10-01-the-default-branch-for-newly-created-repositories-is-now-main --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 954272c..57538e6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,7 +4,7 @@ on: pull_request: push: branches: - - master + - main - releases/* jobs: From 4a8eff50d34ffa052a40d1d5c25e316b00b1242c Mon Sep 17 00:00:00 2001 From: Mohamed RHAMNIA Date: Fri, 30 Apr 2021 20:34:35 +0200 Subject: [PATCH 06/25] Add filter regex --- README.md | 4 ++++ dist/index.js | 4 +++- src/main.ts | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 51860f8..8b64ec1 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,8 @@ See [action.yml](action.yml) # Can be 'space-delimited', 'csv', or 'json'. # Default: 'space-delimited' format: '' + # Filter files using a regex + filter: '*' ``` # Scenarios @@ -36,6 +38,8 @@ Consider using one of the other formats if that's the case. ```yaml - id: files uses: jitterbit/get-changed-files@v1 + with: + filter: '*.php' - run: | for changed_file in ${{ steps.files.outputs.all }}; do echo "Do something with this ${changed_file}." diff --git a/dist/index.js b/dist/index.js index cf95355..e6a38bc 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3517,6 +3517,7 @@ function run() { // Create GitHub client with the API token. const client = new github_1.GitHub(core.getInput('token', { required: true })); const format = core.getInput('format', { required: true }); + const filter = core.getInput('filter', { required: true }) || '*'; // Ensure that the format parameter is set properly. if (format !== 'space-delimited' && format !== 'csv' && format !== 'json') { core.setFailed(`Format must be one of 'string-delimited', 'csv', or 'json', got '${format}'.`); @@ -3571,8 +3572,9 @@ function run() { core.setFailed(`The head commit for this ${github_1.context.eventName} event is not ahead of the base commit. ` + "Please submit an issue on this action's GitHub repo."); } + const regex = new RegExp(`/${filter}\\b`, 'g'); // Get the changed files from the response payload. - const files = response.data.files; + const files = response.data.files.filter(file => file.filename.match(regex)); const all = [], added = [], modified = [], removed = [], renamed = [], addedModified = []; for (const file of files) { const filename = file.filename; diff --git a/src/main.ts b/src/main.ts index 307b988..d800be8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -9,6 +9,7 @@ async function run(): Promise { // Create GitHub client with the API token. const client = new GitHub(core.getInput('token', {required: true})) const format = core.getInput('format', {required: true}) as Format + const filter = core.getInput('filter', {required: true}) || '*' // Ensure that the format parameter is set properly. if (format !== 'space-delimited' && format !== 'csv' && format !== 'json') { @@ -83,8 +84,9 @@ async function run(): Promise { ) } + const regex = new RegExp(`/${filter}\\b`, 'g') // Get the changed files from the response payload. - const files = response.data.files + const files = response.data.files.filter(file => file.filename.match(regex)) const all = [] as string[], added = [] as string[], modified = [] as string[], From 5e2c31d8a78e2116ea0f0e49446834665639ac9f Mon Sep 17 00:00:00 2001 From: Ana Maria Martinez Gomez Date: Wed, 26 May 2021 17:03:22 +0200 Subject: [PATCH 07/25] Fix filter in action.yml Make '*' the default filter. --- action.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/action.yml b/action.yml index 2536c03..98ed9a8 100644 --- a/action.yml +++ b/action.yml @@ -20,6 +20,9 @@ inputs: Can be 'space-delimited', 'csv', or 'json'. required: true default: space-delimited + filter: + required: true + default: '*' outputs: all: description: > From 45d873a6a75f1a7f115025d3f3d0157fbfbb94e0 Mon Sep 17 00:00:00 2001 From: Ana Maria Martinez Gomez Date: Wed, 26 May 2021 17:15:21 +0200 Subject: [PATCH 08/25] Prepare release of v1.1 Improve readme and prepare release of v1.1. --- README.md | 15 ++++++++------- action.yml | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 8b64ec1..767bf1b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ -

- jitterbit/get-changed-files status -

+[![CI status](https://github.com/Ana06/get-changed-files/workflows/Test/badge.svg)](https://github.com/Ana06/get-changed-files/actions?query=event%3Apush+branch%3Amain) +[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE.txt) + +This project is a fork of https://github.com/jitterbit/get-changed-files, which supports `pull_request_target` and allow to filter files using regular expressions. # Get All Changed Files @@ -14,7 +15,7 @@ The `steps` output context exposes the output names `all`, `added`, `modified`, See [action.yml](action.yml) ```yaml -- uses: jitterbit/get-changed-files@v1 +- uses: Ana06/get-changed-files@v1.1 with: # Format of the steps output context. # Can be 'space-delimited', 'csv', or 'json'. @@ -37,7 +38,7 @@ Consider using one of the other formats if that's the case. ```yaml - id: files - uses: jitterbit/get-changed-files@v1 + uses: Ana06/get-changed-files@v1.1 with: filter: '*.php' - run: | @@ -50,7 +51,7 @@ Consider using one of the other formats if that's the case. ```yaml - id: files - uses: jitterbit/get-changed-files@v1 + uses: Ana06/get-changed-files@v1.1 with: format: 'csv' - run: | @@ -64,7 +65,7 @@ Consider using one of the other formats if that's the case. ```yaml - id: files - uses: jitterbit/get-changed-files@v1 + uses: Ana06/get-changed-files@v1.1 with: format: 'json' - run: | diff --git a/action.yml b/action.yml index 98ed9a8..ea845ad 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,5 @@ -name: Get All Changed Files -description: Get all of the files changed/modified in a pull request or push's commits. +name: Get Changed Files +description: Get all files changed/modified in a pull request or push's commits. This project is a fork of https://github.com/jitterbit/get-changedfiles, which supports pull_request_target and allow to filter files using regular expressions author: Jitterbit, Inc. branding: icon: file From f51efe59fcc624cc2a79d1bf87344432da0ad6ca Mon Sep 17 00:00:00 2001 From: Sargun Vohra Date: Mon, 15 Mar 2021 14:34:06 -0700 Subject: [PATCH 09/25] Remove response.data.status check It's perfectly valid for a head to be "behind" a base when comparing commits for pull request events. For example, PRing a feature branch of `main` while other commits have landed on `main` after the feature branch was started but before the PR was created, or a PR to merge a "development" branch onto a slower moving "release" branch that has some hotfixes on it. --- src/main.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/main.ts b/src/main.ts index d800be8..6f755aa 100644 --- a/src/main.ts +++ b/src/main.ts @@ -76,14 +76,6 @@ async function run(): Promise { ) } - // Ensure that the head commit is ahead of the base commit. - if (response.data.status !== 'ahead') { - core.setFailed( - `The head commit for this ${context.eventName} event is not ahead of the base commit. ` + - "Please submit an issue on this action's GitHub repo." - ) - } - const regex = new RegExp(`/${filter}\\b`, 'g') // Get the changed files from the response payload. const files = response.data.files.filter(file => file.filename.match(regex)) From a2f6df8c195e713211f9f6258baafc445149355b Mon Sep 17 00:00:00 2001 From: Ana Maria Martinez Gomez Date: Fri, 4 Jun 2021 13:44:27 +0200 Subject: [PATCH 10/25] Prepare release of v1.2 I have cherry-picked the removal of the ahead check: https://github.com/jitterbit/get-changed-files/pull/25 This seems to be a change Jitterbit's community agrees on: https://github.com/jitterbit/get-changed-files/issues/17 Build this change and prepare v1.2 release. --- README.md | 10 +++++----- dist/index.js | 5 ----- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 767bf1b..f0433e2 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ [![CI status](https://github.com/Ana06/get-changed-files/workflows/Test/badge.svg)](https://github.com/Ana06/get-changed-files/actions?query=event%3Apush+branch%3Amain) [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE.txt) -This project is a fork of https://github.com/jitterbit/get-changed-files, which supports `pull_request_target` and allow to filter files using regular expressions. +This project is a fork of https://github.com/jitterbit/get-changed-files, which supports `pull_request_target`, allow to filter files using regular expressions and removes the ahead check. # Get All Changed Files @@ -15,7 +15,7 @@ The `steps` output context exposes the output names `all`, `added`, `modified`, See [action.yml](action.yml) ```yaml -- uses: Ana06/get-changed-files@v1.1 +- uses: Ana06/get-changed-files@v1.2 with: # Format of the steps output context. # Can be 'space-delimited', 'csv', or 'json'. @@ -38,7 +38,7 @@ Consider using one of the other formats if that's the case. ```yaml - id: files - uses: Ana06/get-changed-files@v1.1 + uses: Ana06/get-changed-files@v1.2 with: filter: '*.php' - run: | @@ -51,7 +51,7 @@ Consider using one of the other formats if that's the case. ```yaml - id: files - uses: Ana06/get-changed-files@v1.1 + uses: Ana06/get-changed-files@v1.2 with: format: 'csv' - run: | @@ -65,7 +65,7 @@ Consider using one of the other formats if that's the case. ```yaml - id: files - uses: Ana06/get-changed-files@v1.1 + uses: Ana06/get-changed-files@v1.2 with: format: 'json' - run: | diff --git a/dist/index.js b/dist/index.js index e6a38bc..3790d50 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3567,11 +3567,6 @@ function run() { core.setFailed(`The GitHub API for comparing the base and head commits for this ${github_1.context.eventName} event returned ${response.status}, expected 200. ` + "Please submit an issue on this action's GitHub repo."); } - // Ensure that the head commit is ahead of the base commit. - if (response.data.status !== 'ahead') { - core.setFailed(`The head commit for this ${github_1.context.eventName} event is not ahead of the base commit. ` + - "Please submit an issue on this action's GitHub repo."); - } const regex = new RegExp(`/${filter}\\b`, 'g'); // Get the changed files from the response payload. const files = response.data.files.filter(file => file.filename.match(regex)); From 48961ca8c2f8b2d64d2f6684f7e181208289d406 Mon Sep 17 00:00:00 2001 From: RenaudS Date: Mon, 28 Jun 2021 16:34:54 +0200 Subject: [PATCH 11/25] Merge pull request #2 from rnsc/main [Feature] include/exclude filters (#1) --- .github/workflows/test.yml | 27 +- README.md | 78 +- dist/index.js | 1469 +++++++++++++++++++++++++++++++++++- package.json | 6 +- src/main.ts | 22 +- 5 files changed, 1550 insertions(+), 52 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 57538e6..3abde94 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -85,8 +85,10 @@ jobs: - id: files name: Run the action uses: ./ + with: + glob-filter: '*' - - name: Print steps context output + - name: Print files run: | echo 'steps.files.outputs.all=${{ steps.files.outputs.all }}' echo 'steps.files.outputs.added=${{ steps.files.outputs.added }}' @@ -94,3 +96,26 @@ jobs: echo 'steps.files.outputs.removed=${{ steps.files.outputs.removed }}' echo 'steps.files.outputs.renamed=${{ steps.files.outputs.renamed }}' echo 'steps.files.outputs.added_modified=${{ steps.files.outputs.added_modified }}' + + - id: files-filtered + name: Run the action + uses: ./ + with: + glob-filter: | + *.yml + !.github/*/*.yml + *.js + *.ts + package* + !*.json + + + - name: Print files-filtered + run: | + echo 'steps.files-filtered.outputs.all=${{ steps.files-filtered.outputs.all }}' + echo 'steps.files-filtered.outputs.added=${{ steps.files-filtered.outputs.added }}' + echo 'steps.files-filtered.outputs.modified=${{ steps.files-filtered.outputs.modified }}' + echo 'steps.files-filtered.outputs.removed=${{ steps.files-filtered.outputs.removed }}' + echo 'steps.files-filtered.outputs.renamed=${{ steps.files-filtered.outputs.renamed }}' + echo 'steps.files-filtered.outputs.added_modified=${{ steps.files-filtered.outputs.added_modified }}' + diff --git a/README.md b/README.md index f0433e2..1c1c858 100644 --- a/README.md +++ b/README.md @@ -1,44 +1,68 @@ +# get-changed-files + [![CI status](https://github.com/Ana06/get-changed-files/workflows/Test/badge.svg)](https://github.com/Ana06/get-changed-files/actions?query=event%3Apush+branch%3Amain) [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE.txt) -This project is a fork of https://github.com/jitterbit/get-changed-files, which supports `pull_request_target`, allow to filter files using regular expressions and removes the ahead check. +This project is a fork of , which supports `pull_request_target`, allow to filter files using regular expressions and removes the ahead check. -# Get All Changed Files +## Get All Changed Files Get all of the files changed/modified in a pull request (`pull_request` or `pull_request_target`) or push's commits. You can choose to get all changed files, only added files, only modified files, only removed files, only renamed files, or all added and modified files. These outputs are available via the `steps` output context. The `steps` output context exposes the output names `all`, `added`, `modified`, `removed`, `renamed`, and `added_modified`. -# Usage +## Usage See [action.yml](action.yml) ```yaml -- uses: Ana06/get-changed-files@v1.2 +- uses: Ana06/get-changed-files@v2.0.0 with: # Format of the steps output context. # Can be 'space-delimited', 'csv', or 'json'. # Default: 'space-delimited' format: '' - # Filter files using a regex + # Filter files using a glob filter filter: '*' ``` -# Scenarios +## Scenarios -- [Get all changed files as space-delimited](#get-all-changed-files-as-space-delimited) -- [Get all added and modified files as CSV](#get-all-added-and-modified-files-as-csv) -- [Get all removed files as JSON](#get-all-removed-files-as-json) +- [get-changed-files](#get-changed-files) + - [Get All Changed Files](#get-all-changed-files) + - [Usage](#usage) + - [Scenarios](#scenarios) + - [Get all changed files as space-delimited](#get-all-changed-files-as-space-delimited) + - [Get all changed *.php files as space-delimited](#get-all-changed-php-files-as-space-delimited) + - [Get all changed *.yml files but exclude .github/*/*.yml files](#get-all-changed-yml-files-but-exclude-githubyml-files) + - [Get all added and modified files as CSV](#get-all-added-and-modified-files-as-csv) + - [Get all removed files as JSON](#get-all-removed-files-as-json) + - [Install, Build, Lint, Test, and Package](#install-build-lint-test-and-package) + - [License](#license) -## Get all changed files as space-delimited +### Get all changed files as space-delimited If there are any files with spaces in them, then this method won't work and the step will fail. Consider using one of the other formats if that's the case. ```yaml - id: files - uses: Ana06/get-changed-files@v1.2 + uses: Ana06/get-changed-files@v2.0.0 +- run: | + for changed_file in ${{ steps.files.outputs.all }}; do + echo "Do something with this ${changed_file}." + done +``` + +### Get all changed *.php files as space-delimited + +If there are any files with spaces in them, then this method won't work and the step will fail. +Consider using one of the other formats if that's the case. + +```yaml +- id: files + uses: Ana06/get-changed-files@v2.0.0 with: filter: '*.php' - run: | @@ -47,13 +71,28 @@ Consider using one of the other formats if that's the case. done ``` -## Get all added and modified files as CSV +### Get all changed *.yml files but exclude .github/*/*.yml files + +Be careful that the order of the glob has an importance. +Therefore, including all YML files first and excluding the YML files of your `.github/*/` directories is the way to go to exclude them. +If those two globs were inverted, you **would** include all the YML files, with the ones in your `.github/*/` directories. + +```yaml +- uses: Ana06/get-changed-files@v2.0.0 + with: + filter: | + *.yml + !.github/*/*.yml +``` + +### Get all added and modified files as CSV ```yaml - id: files - uses: Ana06/get-changed-files@v1.2 + uses: Ana06/get-changed-files@v2.0.0 with: format: 'csv' + filter: '*' - run: | mapfile -d ',' -t added_modified_files < <(printf '%s,' '${{ steps.files.outputs.added_modified }}') for added_modified_file in "${added_modified_files[@]}"; do @@ -61,13 +100,14 @@ Consider using one of the other formats if that's the case. done ``` -## Get all removed files as JSON +### Get all removed files as JSON ```yaml - id: files - uses: Ana06/get-changed-files@v1.2 + uses: Ana06/get-changed-files@v2.0.0 with: format: 'json' + filter: '*' - run: | readarray -t removed_files <<<"$(jq -r '.[]' <<<'${{ steps.files.outputs.removed }}')" for removed_file in ${removed_files[@]}; do @@ -75,15 +115,15 @@ Consider using one of the other formats if that's the case. done ``` -# Install, Build, Lint, Test, and Package +## Install, Build, Lint, Test, and Package Make sure to do the following before checking in any code changes. ```bash -$ yarn -$ yarn all +yarn +yarn all ``` -# License +## License The scripts and documentation in this project are released under the [MIT License](LICENSE) diff --git a/dist/index.js b/dist/index.js index 3790d50..32a94da 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1973,6 +1973,33 @@ const windowsRelease = release => { module.exports = windowsRelease; +/***/ }), + +/***/ 82: +/***/ (function(__unusedmodule, exports) { + +"use strict"; + +// We use any as a valid input type +/* eslint-disable @typescript-eslint/no-explicit-any */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.toCommandValue = void 0; +/** + * Sanitizes an input into a string so it can be passed into issueCommand safely + * @param input input to sanitize into a string + */ +function toCommandValue(input) { + if (input === null || input === undefined) { + return ''; + } + else if (typeof input === 'string' || input instanceof String) { + return input; + } + return JSON.stringify(input); +} +exports.toCommandValue = toCommandValue; +//# sourceMappingURL=utils.js.map + /***/ }), /***/ 87: @@ -1982,6 +2009,985 @@ module.exports = require("os"); /***/ }), +/***/ 93: +/***/ (function(module, __unusedexports, __webpack_require__) { + +module.exports = minimatch +minimatch.Minimatch = Minimatch + +var path = { sep: '/' } +try { + path = __webpack_require__(622) +} catch (er) {} + +var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {} +var expand = __webpack_require__(306) + +var plTypes = { + '!': { open: '(?:(?!(?:', close: '))[^/]*?)'}, + '?': { open: '(?:', close: ')?' }, + '+': { open: '(?:', close: ')+' }, + '*': { open: '(?:', close: ')*' }, + '@': { open: '(?:', close: ')' } +} + +// any single thing other than / +// don't need to escape / when using new RegExp() +var qmark = '[^/]' + +// * => any number of characters +var star = qmark + '*?' + +// ** when dots are allowed. Anything goes, except .. and . +// not (^ or / followed by one or two dots followed by $ or /), +// followed by anything, any number of times. +var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?' + +// not a ^ or / followed by a dot, +// followed by anything, any number of times. +var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?' + +// characters that need to be escaped in RegExp. +var reSpecials = charSet('().*{}+?[]^$\\!') + +// "abc" -> { a:true, b:true, c:true } +function charSet (s) { + return s.split('').reduce(function (set, c) { + set[c] = true + return set + }, {}) +} + +// normalizes slashes. +var slashSplit = /\/+/ + +minimatch.filter = filter +function filter (pattern, options) { + options = options || {} + return function (p, i, list) { + return minimatch(p, pattern, options) + } +} + +function ext (a, b) { + a = a || {} + b = b || {} + var t = {} + Object.keys(b).forEach(function (k) { + t[k] = b[k] + }) + Object.keys(a).forEach(function (k) { + t[k] = a[k] + }) + return t +} + +minimatch.defaults = function (def) { + if (!def || !Object.keys(def).length) return minimatch + + var orig = minimatch + + var m = function minimatch (p, pattern, options) { + return orig.minimatch(p, pattern, ext(def, options)) + } + + m.Minimatch = function Minimatch (pattern, options) { + return new orig.Minimatch(pattern, ext(def, options)) + } + + return m +} + +Minimatch.defaults = function (def) { + if (!def || !Object.keys(def).length) return Minimatch + return minimatch.defaults(def).Minimatch +} + +function minimatch (p, pattern, options) { + if (typeof pattern !== 'string') { + throw new TypeError('glob pattern string required') + } + + if (!options) options = {} + + // shortcut: comments match nothing. + if (!options.nocomment && pattern.charAt(0) === '#') { + return false + } + + // "" only matches "" + if (pattern.trim() === '') return p === '' + + return new Minimatch(pattern, options).match(p) +} + +function Minimatch (pattern, options) { + if (!(this instanceof Minimatch)) { + return new Minimatch(pattern, options) + } + + if (typeof pattern !== 'string') { + throw new TypeError('glob pattern string required') + } + + if (!options) options = {} + pattern = pattern.trim() + + // windows support: need to use /, not \ + if (path.sep !== '/') { + pattern = pattern.split(path.sep).join('/') + } + + this.options = options + this.set = [] + this.pattern = pattern + this.regexp = null + this.negate = false + this.comment = false + this.empty = false + + // make the set of regexps etc. + this.make() +} + +Minimatch.prototype.debug = function () {} + +Minimatch.prototype.make = make +function make () { + // don't do it more than once. + if (this._made) return + + var pattern = this.pattern + var options = this.options + + // empty patterns and comments match nothing. + if (!options.nocomment && pattern.charAt(0) === '#') { + this.comment = true + return + } + if (!pattern) { + this.empty = true + return + } + + // step 1: figure out negation, etc. + this.parseNegate() + + // step 2: expand braces + var set = this.globSet = this.braceExpand() + + if (options.debug) this.debug = console.error + + this.debug(this.pattern, set) + + // step 3: now we have a set, so turn each one into a series of path-portion + // matching patterns. + // These will be regexps, except in the case of "**", which is + // set to the GLOBSTAR object for globstar behavior, + // and will not contain any / characters + set = this.globParts = set.map(function (s) { + return s.split(slashSplit) + }) + + this.debug(this.pattern, set) + + // glob --> regexps + set = set.map(function (s, si, set) { + return s.map(this.parse, this) + }, this) + + this.debug(this.pattern, set) + + // filter out everything that didn't compile properly. + set = set.filter(function (s) { + return s.indexOf(false) === -1 + }) + + this.debug(this.pattern, set) + + this.set = set +} + +Minimatch.prototype.parseNegate = parseNegate +function parseNegate () { + var pattern = this.pattern + var negate = false + var options = this.options + var negateOffset = 0 + + if (options.nonegate) return + + for (var i = 0, l = pattern.length + ; i < l && pattern.charAt(i) === '!' + ; i++) { + negate = !negate + negateOffset++ + } + + if (negateOffset) this.pattern = pattern.substr(negateOffset) + this.negate = negate +} + +// Brace expansion: +// a{b,c}d -> abd acd +// a{b,}c -> abc ac +// a{0..3}d -> a0d a1d a2d a3d +// a{b,c{d,e}f}g -> abg acdfg acefg +// a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg +// +// Invalid sets are not expanded. +// a{2..}b -> a{2..}b +// a{b}c -> a{b}c +minimatch.braceExpand = function (pattern, options) { + return braceExpand(pattern, options) +} + +Minimatch.prototype.braceExpand = braceExpand + +function braceExpand (pattern, options) { + if (!options) { + if (this instanceof Minimatch) { + options = this.options + } else { + options = {} + } + } + + pattern = typeof pattern === 'undefined' + ? this.pattern : pattern + + if (typeof pattern === 'undefined') { + throw new TypeError('undefined pattern') + } + + if (options.nobrace || + !pattern.match(/\{.*\}/)) { + // shortcut. no need to expand. + return [pattern] + } + + return expand(pattern) +} + +// parse a component of the expanded set. +// At this point, no pattern may contain "/" in it +// so we're going to return a 2d array, where each entry is the full +// pattern, split on '/', and then turned into a regular expression. +// A regexp is made at the end which joins each array with an +// escaped /, and another full one which joins each regexp with |. +// +// Following the lead of Bash 4.1, note that "**" only has special meaning +// when it is the *only* thing in a path portion. Otherwise, any series +// of * is equivalent to a single *. Globstar behavior is enabled by +// default, and can be disabled by setting options.noglobstar. +Minimatch.prototype.parse = parse +var SUBPARSE = {} +function parse (pattern, isSub) { + if (pattern.length > 1024 * 64) { + throw new TypeError('pattern is too long') + } + + var options = this.options + + // shortcuts + if (!options.noglobstar && pattern === '**') return GLOBSTAR + if (pattern === '') return '' + + var re = '' + var hasMagic = !!options.nocase + var escaping = false + // ? => one single character + var patternListStack = [] + var negativeLists = [] + var stateChar + var inClass = false + var reClassStart = -1 + var classStart = -1 + // . and .. never match anything that doesn't start with ., + // even when options.dot is set. + var patternStart = pattern.charAt(0) === '.' ? '' // anything + // not (start or / followed by . or .. followed by / or end) + : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' + : '(?!\\.)' + var self = this + + function clearStateChar () { + if (stateChar) { + // we had some state-tracking character + // that wasn't consumed by this pass. + switch (stateChar) { + case '*': + re += star + hasMagic = true + break + case '?': + re += qmark + hasMagic = true + break + default: + re += '\\' + stateChar + break + } + self.debug('clearStateChar %j %j', stateChar, re) + stateChar = false + } + } + + for (var i = 0, len = pattern.length, c + ; (i < len) && (c = pattern.charAt(i)) + ; i++) { + this.debug('%s\t%s %s %j', pattern, i, re, c) + + // skip over any that are escaped. + if (escaping && reSpecials[c]) { + re += '\\' + c + escaping = false + continue + } + + switch (c) { + case '/': + // completely not allowed, even escaped. + // Should already be path-split by now. + return false + + case '\\': + clearStateChar() + escaping = true + continue + + // the various stateChar values + // for the "extglob" stuff. + case '?': + case '*': + case '+': + case '@': + case '!': + this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c) + + // all of those are literals inside a class, except that + // the glob [!a] means [^a] in regexp + if (inClass) { + this.debug(' in class') + if (c === '!' && i === classStart + 1) c = '^' + re += c + continue + } + + // if we already have a stateChar, then it means + // that there was something like ** or +? in there. + // Handle the stateChar, then proceed with this one. + self.debug('call clearStateChar %j', stateChar) + clearStateChar() + stateChar = c + // if extglob is disabled, then +(asdf|foo) isn't a thing. + // just clear the statechar *now*, rather than even diving into + // the patternList stuff. + if (options.noext) clearStateChar() + continue + + case '(': + if (inClass) { + re += '(' + continue + } + + if (!stateChar) { + re += '\\(' + continue + } + + patternListStack.push({ + type: stateChar, + start: i - 1, + reStart: re.length, + open: plTypes[stateChar].open, + close: plTypes[stateChar].close + }) + // negation is (?:(?!js)[^/]*) + re += stateChar === '!' ? '(?:(?!(?:' : '(?:' + this.debug('plType %j %j', stateChar, re) + stateChar = false + continue + + case ')': + if (inClass || !patternListStack.length) { + re += '\\)' + continue + } + + clearStateChar() + hasMagic = true + var pl = patternListStack.pop() + // negation is (?:(?!js)[^/]*) + // The others are (?:) + re += pl.close + if (pl.type === '!') { + negativeLists.push(pl) + } + pl.reEnd = re.length + continue + + case '|': + if (inClass || !patternListStack.length || escaping) { + re += '\\|' + escaping = false + continue + } + + clearStateChar() + re += '|' + continue + + // these are mostly the same in regexp and glob + case '[': + // swallow any state-tracking char before the [ + clearStateChar() + + if (inClass) { + re += '\\' + c + continue + } + + inClass = true + classStart = i + reClassStart = re.length + re += c + continue + + case ']': + // a right bracket shall lose its special + // meaning and represent itself in + // a bracket expression if it occurs + // first in the list. -- POSIX.2 2.8.3.2 + if (i === classStart + 1 || !inClass) { + re += '\\' + c + escaping = false + continue + } + + // handle the case where we left a class open. + // "[z-a]" is valid, equivalent to "\[z-a\]" + if (inClass) { + // split where the last [ was, make sure we don't have + // an invalid re. if so, re-walk the contents of the + // would-be class to re-translate any characters that + // were passed through as-is + // TODO: It would probably be faster to determine this + // without a try/catch and a new RegExp, but it's tricky + // to do safely. For now, this is safe and works. + var cs = pattern.substring(classStart + 1, i) + try { + RegExp('[' + cs + ']') + } catch (er) { + // not a valid class! + var sp = this.parse(cs, SUBPARSE) + re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]' + hasMagic = hasMagic || sp[1] + inClass = false + continue + } + } + + // finish up the class. + hasMagic = true + inClass = false + re += c + continue + + default: + // swallow any state char that wasn't consumed + clearStateChar() + + if (escaping) { + // no need + escaping = false + } else if (reSpecials[c] + && !(c === '^' && inClass)) { + re += '\\' + } + + re += c + + } // switch + } // for + + // handle the case where we left a class open. + // "[abc" is valid, equivalent to "\[abc" + if (inClass) { + // split where the last [ was, and escape it + // this is a huge pita. We now have to re-walk + // the contents of the would-be class to re-translate + // any characters that were passed through as-is + cs = pattern.substr(classStart + 1) + sp = this.parse(cs, SUBPARSE) + re = re.substr(0, reClassStart) + '\\[' + sp[0] + hasMagic = hasMagic || sp[1] + } + + // handle the case where we had a +( thing at the *end* + // of the pattern. + // each pattern list stack adds 3 chars, and we need to go through + // and escape any | chars that were passed through as-is for the regexp. + // Go through and escape them, taking care not to double-escape any + // | chars that were already escaped. + for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) { + var tail = re.slice(pl.reStart + pl.open.length) + this.debug('setting tail', re, pl) + // maybe some even number of \, then maybe 1 \, followed by a | + tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) { + if (!$2) { + // the | isn't already escaped, so escape it. + $2 = '\\' + } + + // need to escape all those slashes *again*, without escaping the + // one that we need for escaping the | character. As it works out, + // escaping an even number of slashes can be done by simply repeating + // it exactly after itself. That's why this trick works. + // + // I am sorry that you have to see this. + return $1 + $1 + $2 + '|' + }) + + this.debug('tail=%j\n %s', tail, tail, pl, re) + var t = pl.type === '*' ? star + : pl.type === '?' ? qmark + : '\\' + pl.type + + hasMagic = true + re = re.slice(0, pl.reStart) + t + '\\(' + tail + } + + // handle trailing things that only matter at the very end. + clearStateChar() + if (escaping) { + // trailing \\ + re += '\\\\' + } + + // only need to apply the nodot start if the re starts with + // something that could conceivably capture a dot + var addPatternStart = false + switch (re.charAt(0)) { + case '.': + case '[': + case '(': addPatternStart = true + } + + // Hack to work around lack of negative lookbehind in JS + // A pattern like: *.!(x).!(y|z) needs to ensure that a name + // like 'a.xyz.yz' doesn't match. So, the first negative + // lookahead, has to look ALL the way ahead, to the end of + // the pattern. + for (var n = negativeLists.length - 1; n > -1; n--) { + var nl = negativeLists[n] + + var nlBefore = re.slice(0, nl.reStart) + var nlFirst = re.slice(nl.reStart, nl.reEnd - 8) + var nlLast = re.slice(nl.reEnd - 8, nl.reEnd) + var nlAfter = re.slice(nl.reEnd) + + nlLast += nlAfter + + // Handle nested stuff like *(*.js|!(*.json)), where open parens + // mean that we should *not* include the ) in the bit that is considered + // "after" the negated section. + var openParensBefore = nlBefore.split('(').length - 1 + var cleanAfter = nlAfter + for (i = 0; i < openParensBefore; i++) { + cleanAfter = cleanAfter.replace(/\)[+*?]?/, '') + } + nlAfter = cleanAfter + + var dollar = '' + if (nlAfter === '' && isSub !== SUBPARSE) { + dollar = '$' + } + var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast + re = newRe + } + + // if the re is not "" at this point, then we need to make sure + // it doesn't match against an empty path part. + // Otherwise a/* will match a/, which it should not. + if (re !== '' && hasMagic) { + re = '(?=.)' + re + } + + if (addPatternStart) { + re = patternStart + re + } + + // parsing just a piece of a larger pattern. + if (isSub === SUBPARSE) { + return [re, hasMagic] + } + + // skip the regexp for non-magical patterns + // unescape anything in it, though, so that it'll be + // an exact match against a file etc. + if (!hasMagic) { + return globUnescape(pattern) + } + + var flags = options.nocase ? 'i' : '' + try { + var regExp = new RegExp('^' + re + '$', flags) + } catch (er) { + // If it was an invalid regular expression, then it can't match + // anything. This trick looks for a character after the end of + // the string, which is of course impossible, except in multi-line + // mode, but it's not a /m regex. + return new RegExp('$.') + } + + regExp._glob = pattern + regExp._src = re + + return regExp +} + +minimatch.makeRe = function (pattern, options) { + return new Minimatch(pattern, options || {}).makeRe() +} + +Minimatch.prototype.makeRe = makeRe +function makeRe () { + if (this.regexp || this.regexp === false) return this.regexp + + // at this point, this.set is a 2d array of partial + // pattern strings, or "**". + // + // It's better to use .match(). This function shouldn't + // be used, really, but it's pretty convenient sometimes, + // when you just want to work with a regex. + var set = this.set + + if (!set.length) { + this.regexp = false + return this.regexp + } + var options = this.options + + var twoStar = options.noglobstar ? star + : options.dot ? twoStarDot + : twoStarNoDot + var flags = options.nocase ? 'i' : '' + + var re = set.map(function (pattern) { + return pattern.map(function (p) { + return (p === GLOBSTAR) ? twoStar + : (typeof p === 'string') ? regExpEscape(p) + : p._src + }).join('\\\/') + }).join('|') + + // must match entire pattern + // ending in a * or ** will make it less strict. + re = '^(?:' + re + ')$' + + // can match anything, as long as it's not this. + if (this.negate) re = '^(?!' + re + ').*$' + + try { + this.regexp = new RegExp(re, flags) + } catch (ex) { + this.regexp = false + } + return this.regexp +} + +minimatch.match = function (list, pattern, options) { + options = options || {} + var mm = new Minimatch(pattern, options) + list = list.filter(function (f) { + return mm.match(f) + }) + if (mm.options.nonull && !list.length) { + list.push(pattern) + } + return list +} + +Minimatch.prototype.match = match +function match (f, partial) { + this.debug('match', f, this.pattern) + // short-circuit in the case of busted things. + // comments, etc. + if (this.comment) return false + if (this.empty) return f === '' + + if (f === '/' && partial) return true + + var options = this.options + + // windows: need to use /, not \ + if (path.sep !== '/') { + f = f.split(path.sep).join('/') + } + + // treat the test path as a set of pathparts. + f = f.split(slashSplit) + this.debug(this.pattern, 'split', f) + + // just ONE of the pattern sets in this.set needs to match + // in order for it to be valid. If negating, then just one + // match means that we have failed. + // Either way, return on the first hit. + + var set = this.set + this.debug(this.pattern, 'set', set) + + // Find the basename of the path by looking for the last non-empty segment + var filename + var i + for (i = f.length - 1; i >= 0; i--) { + filename = f[i] + if (filename) break + } + + for (i = 0; i < set.length; i++) { + var pattern = set[i] + var file = f + if (options.matchBase && pattern.length === 1) { + file = [filename] + } + var hit = this.matchOne(file, pattern, partial) + if (hit) { + if (options.flipNegate) return true + return !this.negate + } + } + + // didn't get any hits. this is success if it's a negative + // pattern, failure otherwise. + if (options.flipNegate) return false + return this.negate +} + +// set partial to true to test if, for example, +// "/a/b" matches the start of "/*/b/*/d" +// Partial means, if you run out of file before you run +// out of pattern, then that's fine, as long as all +// the parts match. +Minimatch.prototype.matchOne = function (file, pattern, partial) { + var options = this.options + + this.debug('matchOne', + { 'this': this, file: file, pattern: pattern }) + + this.debug('matchOne', file.length, pattern.length) + + for (var fi = 0, + pi = 0, + fl = file.length, + pl = pattern.length + ; (fi < fl) && (pi < pl) + ; fi++, pi++) { + this.debug('matchOne loop') + var p = pattern[pi] + var f = file[fi] + + this.debug(pattern, p, f) + + // should be impossible. + // some invalid regexp stuff in the set. + if (p === false) return false + + if (p === GLOBSTAR) { + this.debug('GLOBSTAR', [pattern, p, f]) + + // "**" + // a/**/b/**/c would match the following: + // a/b/x/y/z/c + // a/x/y/z/b/c + // a/b/x/b/x/c + // a/b/c + // To do this, take the rest of the pattern after + // the **, and see if it would match the file remainder. + // If so, return success. + // If not, the ** "swallows" a segment, and try again. + // This is recursively awful. + // + // a/**/b/**/c matching a/b/x/y/z/c + // - a matches a + // - doublestar + // - matchOne(b/x/y/z/c, b/**/c) + // - b matches b + // - doublestar + // - matchOne(x/y/z/c, c) -> no + // - matchOne(y/z/c, c) -> no + // - matchOne(z/c, c) -> no + // - matchOne(c, c) yes, hit + var fr = fi + var pr = pi + 1 + if (pr === pl) { + this.debug('** at the end') + // a ** at the end will just swallow the rest. + // We have found a match. + // however, it will not swallow /.x, unless + // options.dot is set. + // . and .. are *never* matched by **, for explosively + // exponential reasons. + for (; fi < fl; fi++) { + if (file[fi] === '.' || file[fi] === '..' || + (!options.dot && file[fi].charAt(0) === '.')) return false + } + return true + } + + // ok, let's see if we can swallow whatever we can. + while (fr < fl) { + var swallowee = file[fr] + + this.debug('\nglobstar while', file, fr, pattern, pr, swallowee) + + // XXX remove this slice. Just pass the start index. + if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) { + this.debug('globstar found match!', fr, fl, swallowee) + // found a match. + return true + } else { + // can't swallow "." or ".." ever. + // can only swallow ".foo" when explicitly asked. + if (swallowee === '.' || swallowee === '..' || + (!options.dot && swallowee.charAt(0) === '.')) { + this.debug('dot detected!', file, fr, pattern, pr) + break + } + + // ** swallows a segment, and continue. + this.debug('globstar swallow a segment, and continue') + fr++ + } + } + + // no match was found. + // However, in partial mode, we can't say this is necessarily over. + // If there's more *pattern* left, then + if (partial) { + // ran out of file + this.debug('\n>>> no match, partial?', file, fr, pattern, pr) + if (fr === fl) return true + } + return false + } + + // something other than ** + // non-magic patterns just have to match exactly + // patterns with magic have been turned into regexps. + var hit + if (typeof p === 'string') { + if (options.nocase) { + hit = f.toLowerCase() === p.toLowerCase() + } else { + hit = f === p + } + this.debug('string match', p, f, hit) + } else { + hit = f.match(p) + this.debug('pattern match', p, f, hit) + } + + if (!hit) return false + } + + // Note: ending in / means that we'll get a final "" + // at the end of the pattern. This can only match a + // corresponding "" at the end of the file. + // If the file ends in /, then it can only match a + // a pattern that ends in /, unless the pattern just + // doesn't have any more for it. But, a/b/ should *not* + // match "a/b/*", even though "" matches against the + // [^/]*? pattern, except in partial mode, where it might + // simply not be reached yet. + // However, a/b/ should still satisfy a/* + + // now either we fell off the end of the pattern, or we're done. + if (fi === fl && pi === pl) { + // ran out of pattern and filename at the same time. + // an exact hit! + return true + } else if (fi === fl) { + // ran out of file, but still had pattern left. + // this is ok if we're doing the match as part of + // a glob fs traversal. + return partial + } else if (pi === pl) { + // ran out of pattern, still have file left. + // this is only acceptable if we're on the very last + // empty segment of a file with a trailing slash. + // a/* should match a/b/ + var emptyFileEnd = (fi === fl - 1) && (file[fi] === '') + return emptyFileEnd + } + + // should be unreachable. + throw new Error('wtf?') +} + +// replace stuff like \* with * +function globUnescape (s) { + return s.replace(/\\(.)/g, '$1') +} + +function regExpEscape (s) { + return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') +} + + +/***/ }), + +/***/ 102: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +// For internal use, subject to change. +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.issueCommand = void 0; +// We use any as a valid input type +/* eslint-disable @typescript-eslint/no-explicit-any */ +const fs = __importStar(__webpack_require__(747)); +const os = __importStar(__webpack_require__(87)); +const utils_1 = __webpack_require__(82); +function issueCommand(command, message) { + const filePath = process.env[`GITHUB_${command}`]; + if (!filePath) { + throw new Error(`Unable to find environment variable for file command ${command}`); + } + if (!fs.existsSync(filePath)) { + throw new Error(`Missing file at path: ${filePath}`); + } + fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, { + encoding: 'utf8' + }); +} +exports.issueCommand = issueCommand; +//# sourceMappingURL=file-command.js.map + +/***/ }), + /***/ 118: /***/ (function(module, __unusedexports, __webpack_require__) { @@ -3507,9 +4513,13 @@ var __importStar = (this && this.__importStar) || function (mod) { result["default"] = mod; return result; }; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); const core = __importStar(__webpack_require__(470)); const github_1 = __webpack_require__(469); +const minimatch_1 = __importDefault(__webpack_require__(93)); function run() { var _a, _b, _c, _d; return __awaiter(this, void 0, void 0, function* () { @@ -3517,7 +4527,7 @@ function run() { // Create GitHub client with the API token. const client = new github_1.GitHub(core.getInput('token', { required: true })); const format = core.getInput('format', { required: true }); - const filter = core.getInput('filter', { required: true }) || '*'; + const filter = core.getMultilineInput('filter', { required: true }) || '*'; // Ensure that the format parameter is set properly. if (format !== 'space-delimited' && format !== 'csv' && format !== 'json') { core.setFailed(`Format must be one of 'string-delimited', 'csv', or 'json', got '${format}'.`); @@ -3567,9 +4577,22 @@ function run() { core.setFailed(`The GitHub API for comparing the base and head commits for this ${github_1.context.eventName} event returned ${response.status}, expected 200. ` + "Please submit an issue on this action's GitHub repo."); } - const regex = new RegExp(`/${filter}\\b`, 'g'); - // Get the changed files from the response payload. - const files = response.data.files.filter(file => file.filename.match(regex)); + const files = response.data.files.filter(file => { + let match = false; + for (const item of filter) { + const pattern = item; + core.debug(`Test ${file.filename} against ${pattern}`); + core.debug(`current match value: ${match}`); + if (pattern.startsWith('!')) { + match = match && minimatch_1.default(file.filename, pattern, { matchBase: true, dot: true }); + } + else { + match = match || minimatch_1.default(file.filename, pattern, { matchBase: true, dot: true }); + } + core.debug(`match: ${match}`); + } + return match; + }); const all = [], added = [], modified = [], removed = [], renamed = [], addedModified = []; for (const file of files) { const filename = file.filename; @@ -4054,6 +5077,73 @@ function register (state, name, method, options) { } +/***/ }), + +/***/ 284: +/***/ (function(module) { + +"use strict"; + +module.exports = balanced; +function balanced(a, b, str) { + if (a instanceof RegExp) a = maybeMatch(a, str); + if (b instanceof RegExp) b = maybeMatch(b, str); + + var r = range(a, b, str); + + return r && { + start: r[0], + end: r[1], + pre: str.slice(0, r[0]), + body: str.slice(r[0] + a.length, r[1]), + post: str.slice(r[1] + b.length) + }; +} + +function maybeMatch(reg, str) { + var m = str.match(reg); + return m ? m[0] : null; +} + +balanced.range = range; +function range(a, b, str) { + var begs, beg, left, right, result; + var ai = str.indexOf(a); + var bi = str.indexOf(b, ai + 1); + var i = ai; + + if (ai >= 0 && bi > 0) { + begs = []; + left = str.length; + + while (i >= 0 && !result) { + if (i == ai) { + begs.push(i); + ai = str.indexOf(a, i + 1); + } else if (begs.length == 1) { + result = [ begs.pop(), bi ]; + } else { + beg = begs.pop(); + if (beg < left) { + left = beg; + right = bi; + } + + bi = str.indexOf(b, i + 1); + } + + i = ai < bi && ai >= 0 ? ai : bi; + } + + if (begs.length) { + result = [ left, right ]; + } + } + + return result; +} + + /***/ }), /***/ 293: @@ -4390,6 +5480,214 @@ exports.paginateRest = paginateRest; //# sourceMappingURL=index.js.map +/***/ }), + +/***/ 306: +/***/ (function(module, __unusedexports, __webpack_require__) { + +var concatMap = __webpack_require__(896); +var balanced = __webpack_require__(284); + +module.exports = expandTop; + +var escSlash = '\0SLASH'+Math.random()+'\0'; +var escOpen = '\0OPEN'+Math.random()+'\0'; +var escClose = '\0CLOSE'+Math.random()+'\0'; +var escComma = '\0COMMA'+Math.random()+'\0'; +var escPeriod = '\0PERIOD'+Math.random()+'\0'; + +function numeric(str) { + return parseInt(str, 10) == str + ? parseInt(str, 10) + : str.charCodeAt(0); +} + +function escapeBraces(str) { + return str.split('\\\\').join(escSlash) + .split('\\{').join(escOpen) + .split('\\}').join(escClose) + .split('\\,').join(escComma) + .split('\\.').join(escPeriod); +} + +function unescapeBraces(str) { + return str.split(escSlash).join('\\') + .split(escOpen).join('{') + .split(escClose).join('}') + .split(escComma).join(',') + .split(escPeriod).join('.'); +} + + +// Basically just str.split(","), but handling cases +// where we have nested braced sections, which should be +// treated as individual members, like {a,{b,c},d} +function parseCommaParts(str) { + if (!str) + return ['']; + + var parts = []; + var m = balanced('{', '}', str); + + if (!m) + return str.split(','); + + var pre = m.pre; + var body = m.body; + var post = m.post; + var p = pre.split(','); + + p[p.length-1] += '{' + body + '}'; + var postParts = parseCommaParts(post); + if (post.length) { + p[p.length-1] += postParts.shift(); + p.push.apply(p, postParts); + } + + parts.push.apply(parts, p); + + return parts; +} + +function expandTop(str) { + if (!str) + return []; + + // I don't know why Bash 4.3 does this, but it does. + // Anything starting with {} will have the first two bytes preserved + // but *only* at the top level, so {},a}b will not expand to anything, + // but a{},b}c will be expanded to [a}c,abc]. + // One could argue that this is a bug in Bash, but since the goal of + // this module is to match Bash's rules, we escape a leading {} + if (str.substr(0, 2) === '{}') { + str = '\\{\\}' + str.substr(2); + } + + return expand(escapeBraces(str), true).map(unescapeBraces); +} + +function identity(e) { + return e; +} + +function embrace(str) { + return '{' + str + '}'; +} +function isPadded(el) { + return /^-?0\d/.test(el); +} + +function lte(i, y) { + return i <= y; +} +function gte(i, y) { + return i >= y; +} + +function expand(str, isTop) { + var expansions = []; + + var m = balanced('{', '}', str); + if (!m || /\$$/.test(m.pre)) return [str]; + + var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); + var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); + var isSequence = isNumericSequence || isAlphaSequence; + var isOptions = m.body.indexOf(',') >= 0; + if (!isSequence && !isOptions) { + // {a},b} + if (m.post.match(/,.*\}/)) { + str = m.pre + '{' + m.body + escClose + m.post; + return expand(str); + } + return [str]; + } + + var n; + if (isSequence) { + n = m.body.split(/\.\./); + } else { + n = parseCommaParts(m.body); + if (n.length === 1) { + // x{{a,b}}y ==> x{a}y x{b}y + n = expand(n[0], false).map(embrace); + if (n.length === 1) { + var post = m.post.length + ? expand(m.post, false) + : ['']; + return post.map(function(p) { + return m.pre + n[0] + p; + }); + } + } + } + + // at this point, n is the parts, and we know it's not a comma set + // with a single entry. + + // no need to expand pre, since it is guaranteed to be free of brace-sets + var pre = m.pre; + var post = m.post.length + ? expand(m.post, false) + : ['']; + + var N; + + if (isSequence) { + var x = numeric(n[0]); + var y = numeric(n[1]); + var width = Math.max(n[0].length, n[1].length) + var incr = n.length == 3 + ? Math.abs(numeric(n[2])) + : 1; + var test = lte; + var reverse = y < x; + if (reverse) { + incr *= -1; + test = gte; + } + var pad = n.some(isPadded); + + N = []; + + for (var i = x; test(i, y); i += incr) { + var c; + if (isAlphaSequence) { + c = String.fromCharCode(i); + if (c === '\\') + c = ''; + } else { + c = String(i); + if (pad) { + var need = width - c.length; + if (need > 0) { + var z = new Array(need + 1).join('0'); + if (i < 0) + c = '-' + z + c.slice(1); + else + c = z + c; + } + } + } + N.push(c); + } + } else { + N = concatMap(n, function(el) { return expand(el, false) }); + } + + for (var j = 0; j < N.length; j++) { + for (var k = 0; k < post.length; k++) { + var expansion = pre + N[j] + post[k]; + if (!isTop || isSequence || expansion) + expansions.push(expansion); + } + } + + return expansions; +} + + + /***/ }), /***/ 323: @@ -5230,15 +6528,29 @@ function octokitValidate(octokit) { "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); +exports.issue = exports.issueCommand = void 0; const os = __importStar(__webpack_require__(87)); +const utils_1 = __webpack_require__(82); /** * Commands * @@ -5293,13 +6605,13 @@ class Command { } } function escapeData(s) { - return (s || '') + return utils_1.toCommandValue(s) .replace(/%/g, '%25') .replace(/\r/g, '%0D') .replace(/\n/g, '%0A'); } function escapeProperty(s) { - return (s || '') + return utils_1.toCommandValue(s) .replace(/%/g, '%25') .replace(/\r/g, '%0D') .replace(/\n/g, '%0A') @@ -7268,6 +8580,25 @@ exports.GitHub = GitHub; "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { @@ -7277,15 +8608,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; Object.defineProperty(exports, "__esModule", { value: true }); +exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0; const command_1 = __webpack_require__(431); +const file_command_1 = __webpack_require__(102); +const utils_1 = __webpack_require__(82); const os = __importStar(__webpack_require__(87)); const path = __importStar(__webpack_require__(622)); /** @@ -7308,11 +8635,21 @@ var ExitCode; /** * Sets env variable for this action and future actions in the job * @param name the name of the variable to set - * @param val the value of the variable + * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any function exportVariable(name, val) { - process.env[name] = val; - command_1.issueCommand('set-env', { name }, val); + const convertedVal = utils_1.toCommandValue(val); + process.env[name] = convertedVal; + const filePath = process.env['GITHUB_ENV'] || ''; + if (filePath) { + const delimiter = '_GitHubActionsFileCommandDelimeter_'; + const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; + file_command_1.issueCommand('ENV', commandValue); + } + else { + command_1.issueCommand('set-env', { name }, convertedVal); + } } exports.exportVariable = exportVariable; /** @@ -7328,12 +8665,20 @@ exports.setSecret = setSecret; * @param inputPath */ function addPath(inputPath) { - command_1.issueCommand('add-path', {}, inputPath); + const filePath = process.env['GITHUB_PATH'] || ''; + if (filePath) { + file_command_1.issueCommand('PATH', inputPath); + } + else { + command_1.issueCommand('add-path', {}, inputPath); + } process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`; } exports.addPath = addPath; /** - * Gets the value of an input. The value is also trimmed. + * Gets the value of an input. + * Unless trimWhitespace is set to false in InputOptions, the value is also trimmed. + * Returns an empty string if the value is not defined. * * @param name name of the input to get * @param options optional. See InputOptions. @@ -7344,19 +8689,70 @@ function getInput(name, options) { if (options && options.required && !val) { throw new Error(`Input required and not supplied: ${name}`); } + if (options && options.trimWhitespace === false) { + return val; + } return val.trim(); } exports.getInput = getInput; +/** + * Gets the values of an multiline input. Each value is also trimmed. + * + * @param name name of the input to get + * @param options optional. See InputOptions. + * @returns string[] + * + */ +function getMultilineInput(name, options) { + const inputs = getInput(name, options) + .split('\n') + .filter(x => x !== ''); + return inputs; +} +exports.getMultilineInput = getMultilineInput; +/** + * Gets the input value of the boolean type in the YAML 1.2 "core schema" specification. + * Support boolean input list: `true | True | TRUE | false | False | FALSE` . + * The return value is also in boolean type. + * ref: https://yaml.org/spec/1.2/spec.html#id2804923 + * + * @param name name of the input to get + * @param options optional. See InputOptions. + * @returns boolean + */ +function getBooleanInput(name, options) { + const trueValue = ['true', 'True', 'TRUE']; + const falseValue = ['false', 'False', 'FALSE']; + const val = getInput(name, options); + if (trueValue.includes(val)) + return true; + if (falseValue.includes(val)) + return false; + throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}\n` + + `Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); +} +exports.getBooleanInput = getBooleanInput; /** * Sets the value of an output. * * @param name name of the output to set - * @param value value to store + * @param value value to store. Non-string values will be converted to a string via JSON.stringify */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any function setOutput(name, value) { + process.stdout.write(os.EOL); command_1.issueCommand('set-output', { name }, value); } exports.setOutput = setOutput; +/** + * Enables or disables the echoing of commands into stdout for the rest of the step. + * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set. + * + */ +function setCommandEcho(enabled) { + command_1.issue('echo', enabled ? 'on' : 'off'); +} +exports.setCommandEcho = setCommandEcho; //----------------------------------------------------------------------- // Results //----------------------------------------------------------------------- @@ -7390,18 +8786,18 @@ function debug(message) { exports.debug = debug; /** * Adds an error issue - * @param message error issue message + * @param message error issue message. Errors will be converted to string via toString() */ function error(message) { - command_1.issue('error', message); + command_1.issue('error', message instanceof Error ? message.toString() : message); } exports.error = error; /** * Adds an warning issue - * @param message warning issue message + * @param message warning issue message. Errors will be converted to string via toString() */ function warning(message) { - command_1.issue('warning', message); + command_1.issue('warning', message instanceof Error ? message.toString() : message); } exports.warning = warning; /** @@ -7459,8 +8855,9 @@ exports.group = group; * Saves state for current action, the state can only be retrieved by this action's post job execution. * * @param name name of the state to store - * @param value value to store + * @param value value to store. Non-string values will be converted to a string via JSON.stringify */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any function saveState(name, value) { command_1.issueCommand('save-state', { name }, value); } @@ -24776,6 +26173,26 @@ function set(object, path, value) { module.exports = set; +/***/ }), + +/***/ 896: +/***/ (function(module) { + +module.exports = function (xs, fn) { + var res = []; + for (var i = 0; i < xs.length; i++) { + var x = fn(xs[i], i); + if (isArray(x)) res.push.apply(res, x); + else res.push(x); + } + return res; +}; + +var isArray = Array.isArray || function (xs) { + return Object.prototype.toString.call(xs) === '[object Array]'; +}; + + /***/ }), /***/ 898: diff --git a/package.json b/package.json index 1279abb..e0ed0da 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "get-changed-files", "description": "GitHub action that gets all changed files in a pull request or push.", - "version": "1.0.0", + "version": "2.0.0", "private": true, "author": "Jitterbit, Inc.", "license": "MIT", @@ -39,12 +39,13 @@ "all": "yarn clean && yarn build && yarn format && yarn lint && yarn package && yarn test" }, "dependencies": { - "@actions/core": "^1.2.2", + "@actions/core": "^1.4.0", "@actions/github": "^2.1.0" }, "devDependencies": { "@octokit/rest": "^16.40.2", "@types/jest": "^25.1.1", + "@types/minimatch": "3.0.4", "@types/node": "^14.17.0", "@typescript-eslint/parser": "^2.8.0", "@zeit/ncc": "^0.21.0", @@ -55,6 +56,7 @@ "jest": "^25.1.0", "jest-circus": "^25.1.0", "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", "prettier": "^1.19.1", "rimraf": "^3.0.0", "ts-jest": "^25.1.0", diff --git a/src/main.ts b/src/main.ts index 6f755aa..51a4a97 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,6 @@ import * as core from '@actions/core' import {context, GitHub} from '@actions/github' +import minimatch from 'minimatch' type Format = 'space-delimited' | 'csv' | 'json' type FileStatus = 'added' | 'modified' | 'removed' | 'renamed' @@ -9,7 +10,7 @@ async function run(): Promise { // Create GitHub client with the API token. const client = new GitHub(core.getInput('token', {required: true})) const format = core.getInput('format', {required: true}) as Format - const filter = core.getInput('filter', {required: true}) || '*' + const filter = core.getMultilineInput('filter', {required: true}) || '*' // Ensure that the format parameter is set properly. if (format !== 'space-delimited' && format !== 'csv' && format !== 'json') { @@ -76,9 +77,22 @@ async function run(): Promise { ) } - const regex = new RegExp(`/${filter}\\b`, 'g') - // Get the changed files from the response payload. - const files = response.data.files.filter(file => file.filename.match(regex)) + const files = response.data.files.filter(file => { + let match = false + for (const item of filter) { + const pattern = item + core.debug(`Test ${file.filename} against ${pattern}`) + core.debug(`current match value: ${match}`) + if (pattern.startsWith('!')) { + match = match && minimatch(file.filename, pattern, {matchBase: true, dot: true}) + } else { + match = match || minimatch(file.filename, pattern, {matchBase: true, dot: true}) + } + core.debug(`match: ${match}`) + } + return match + }) + const all = [] as string[], added = [] as string[], modified = [] as string[], From 42676e4ca4ddda128ec381fd20e4beac3e20d911 Mon Sep 17 00:00:00 2001 From: Ana Maria Martinez Gomez Date: Tue, 27 Jul 2021 15:24:33 +0200 Subject: [PATCH 12/25] Replace glob-filter by filter in test workflow There as a discussion on the name to use in #2 and we forgot to change these. --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3abde94..efac3e0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -86,7 +86,7 @@ jobs: name: Run the action uses: ./ with: - glob-filter: '*' + filter: '*' - name: Print files run: | @@ -101,7 +101,7 @@ jobs: name: Run the action uses: ./ with: - glob-filter: | + filter: | *.yml !.github/*/*.yml *.js From 32ee6f5764494198ef107457ca516477a549a5d6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 27 Jul 2021 13:53:17 +0000 Subject: [PATCH 13/25] chore(deps): bump glob-parent from 5.1.1 to 5.1.2 Bumps [glob-parent](https://github.com/gulpjs/glob-parent) from 5.1.1 to 5.1.2. - [Release notes](https://github.com/gulpjs/glob-parent/releases) - [Changelog](https://github.com/gulpjs/glob-parent/blob/main/CHANGELOG.md) - [Commits](https://github.com/gulpjs/glob-parent/compare/v5.1.1...v5.1.2) --- updated-dependencies: - dependency-name: glob-parent dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/yarn.lock b/yarn.lock index d46c300..23f5e60 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,10 +2,10 @@ # yarn lockfile v1 -"@actions/core@^1.2.2": - version "1.2.3" - resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.3.tgz#e844b4fa0820e206075445079130868f95bfca95" - integrity sha512-Wp4xnyokakM45Uuj4WLUxdsa8fJjKVl1fDTsPbTEcTcuu0Nb26IPQbOtjmnfaCPGcaoPOOqId8H9NapZ8gii4w== +"@actions/core@^1.4.0": + version "1.4.0" + resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.4.0.tgz#cf2e6ee317e314b03886adfeb20e448d50d6e524" + integrity sha512-CGx2ilGq5i7zSLgiiGUtBCxhRRxibJYU6Fim0Q1Wg2aQL2LTnF27zbqZOrxfvFQ55eSBW0L8uVStgtKMpa0Qlg== "@actions/github@^2.1.0": version "2.1.1" @@ -608,6 +608,11 @@ resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.4.tgz#38fd73ddfd9b55abb1e1b2ed578cb55bd7b7d339" integrity sha512-8+KAKzEvSUdeo+kmqnKrqgeE+LcA0tjYWFY7RPProVYwnqDjukzO+3b6dLD56rYX5TdWejnEOLJYOIeh4CXKuA== +"@types/minimatch@3.0.4": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.4.tgz#f0ec25dbf2f0e4b18647313ac031134ca5b24b21" + integrity sha512-1z8k4wzFnNjVK/tlxvrWuK5WMt6mydWWP7+zvH5eFep4oj+UkrfiJTRtjCeBXNpwaA/FYqqtb4/QS4ianFpIRA== + "@types/node@>= 8": version "13.9.3" resolved "https://registry.yarnpkg.com/@types/node/-/node-13.9.3.tgz#6356df2647de9eac569f9a52eda3480fa9e70b4d" @@ -2047,9 +2052,9 @@ getpass@^0.1.1: assert-plus "^1.0.0" glob-parent@^5.0.0: - version "5.1.1" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.1.tgz#b6c1ef417c4e5663ea498f1c45afac6916bbc229" - integrity sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ== + version "5.1.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" + integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== dependencies: is-glob "^4.0.1" From b2354441ed0b03955dbd41369fd710f3b7bfb838 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 27 Jul 2021 13:53:19 +0000 Subject: [PATCH 14/25] chore(deps): bump y18n from 4.0.0 to 4.0.3 Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.3. - [Release notes](https://github.com/yargs/y18n/releases) - [Changelog](https://github.com/yargs/y18n/blob/y18n-v4.0.3/CHANGELOG.md) - [Commits](https://github.com/yargs/y18n/compare/v4.0.0...y18n-v4.0.3) --- updated-dependencies: - dependency-name: y18n dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/yarn.lock b/yarn.lock index d46c300..de0d6bb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,10 +2,10 @@ # yarn lockfile v1 -"@actions/core@^1.2.2": - version "1.2.3" - resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.3.tgz#e844b4fa0820e206075445079130868f95bfca95" - integrity sha512-Wp4xnyokakM45Uuj4WLUxdsa8fJjKVl1fDTsPbTEcTcuu0Nb26IPQbOtjmnfaCPGcaoPOOqId8H9NapZ8gii4w== +"@actions/core@^1.4.0": + version "1.4.0" + resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.4.0.tgz#cf2e6ee317e314b03886adfeb20e448d50d6e524" + integrity sha512-CGx2ilGq5i7zSLgiiGUtBCxhRRxibJYU6Fim0Q1Wg2aQL2LTnF27zbqZOrxfvFQ55eSBW0L8uVStgtKMpa0Qlg== "@actions/github@^2.1.0": version "2.1.1" @@ -608,6 +608,11 @@ resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.4.tgz#38fd73ddfd9b55abb1e1b2ed578cb55bd7b7d339" integrity sha512-8+KAKzEvSUdeo+kmqnKrqgeE+LcA0tjYWFY7RPProVYwnqDjukzO+3b6dLD56rYX5TdWejnEOLJYOIeh4CXKuA== +"@types/minimatch@3.0.4": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.4.tgz#f0ec25dbf2f0e4b18647313ac031134ca5b24b21" + integrity sha512-1z8k4wzFnNjVK/tlxvrWuK5WMt6mydWWP7+zvH5eFep4oj+UkrfiJTRtjCeBXNpwaA/FYqqtb4/QS4ianFpIRA== + "@types/node@>= 8": version "13.9.3" resolved "https://registry.yarnpkg.com/@types/node/-/node-13.9.3.tgz#6356df2647de9eac569f9a52eda3480fa9e70b4d" @@ -4830,9 +4835,9 @@ xregexp@^4.3.0: "@babel/runtime-corejs3" "^7.8.3" y18n@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b" - integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w== + version "4.0.3" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.3.tgz#b5f259c82cd6e336921efd7bfd8bf560de9eeedf" + integrity sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ== yargs-parser@^16.1.0: version "16.1.0" From bd65f20ecd28ff1b862d651af386a96291059a3f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 27 Jul 2021 13:53:27 +0000 Subject: [PATCH 15/25] chore(deps): bump lodash from 4.17.15 to 4.17.21 Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.21. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.21) --- updated-dependencies: - dependency-name: lodash dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/yarn.lock b/yarn.lock index d46c300..3a79d24 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,10 +2,10 @@ # yarn lockfile v1 -"@actions/core@^1.2.2": - version "1.2.3" - resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.3.tgz#e844b4fa0820e206075445079130868f95bfca95" - integrity sha512-Wp4xnyokakM45Uuj4WLUxdsa8fJjKVl1fDTsPbTEcTcuu0Nb26IPQbOtjmnfaCPGcaoPOOqId8H9NapZ8gii4w== +"@actions/core@^1.4.0": + version "1.4.0" + resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.4.0.tgz#cf2e6ee317e314b03886adfeb20e448d50d6e524" + integrity sha512-CGx2ilGq5i7zSLgiiGUtBCxhRRxibJYU6Fim0Q1Wg2aQL2LTnF27zbqZOrxfvFQ55eSBW0L8uVStgtKMpa0Qlg== "@actions/github@^2.1.0": version "2.1.1" @@ -608,6 +608,11 @@ resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.4.tgz#38fd73ddfd9b55abb1e1b2ed578cb55bd7b7d339" integrity sha512-8+KAKzEvSUdeo+kmqnKrqgeE+LcA0tjYWFY7RPProVYwnqDjukzO+3b6dLD56rYX5TdWejnEOLJYOIeh4CXKuA== +"@types/minimatch@3.0.4": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.4.tgz#f0ec25dbf2f0e4b18647313ac031134ca5b24b21" + integrity sha512-1z8k4wzFnNjVK/tlxvrWuK5WMt6mydWWP7+zvH5eFep4oj+UkrfiJTRtjCeBXNpwaA/FYqqtb4/QS4ianFpIRA== + "@types/node@>= 8": version "13.9.3" resolved "https://registry.yarnpkg.com/@types/node/-/node-13.9.3.tgz#6356df2647de9eac569f9a52eda3480fa9e70b4d" @@ -3140,9 +3145,9 @@ lodash.uniq@^4.5.0: integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M= lodash@^4.11.1, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4: - version "4.17.15" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" - integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== + version "4.17.21" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" + integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== lolex@^5.0.0: version "5.1.2" From 98e4db70cc39ce8465b7a1c148561d4fb7a2815f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 27 Jul 2021 13:55:38 +0000 Subject: [PATCH 16/25] chore(deps): bump hosted-git-info from 2.8.8 to 2.8.9 Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.8 to 2.8.9. - [Release notes](https://github.com/npm/hosted-git-info/releases) - [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md) - [Commits](https://github.com/npm/hosted-git-info/compare/v2.8.8...v2.8.9) --- updated-dependencies: - dependency-name: hosted-git-info dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 23f5e60..320565e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2190,9 +2190,9 @@ has@^1.0.3: function-bind "^1.1.1" hosted-git-info@^2.1.4: - version "2.8.8" - resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488" - integrity sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg== + version "2.8.9" + resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9" + integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw== html-encoding-sniffer@^1.0.2: version "1.0.2" From cb55a1037e5b674aaa3cc3339b7f0056f4143230 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 27 Jul 2021 13:55:38 +0000 Subject: [PATCH 17/25] chore(deps): bump ws from 7.2.3 to 7.5.3 Bumps [ws](https://github.com/websockets/ws) from 7.2.3 to 7.5.3. - [Release notes](https://github.com/websockets/ws/releases) - [Commits](https://github.com/websockets/ws/compare/7.2.3...7.5.3) --- updated-dependencies: - dependency-name: ws dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 23f5e60..e14d9b4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4813,9 +4813,9 @@ write@1.0.3: mkdirp "^0.5.1" ws@^7.0.0: - version "7.2.3" - resolved "https://registry.yarnpkg.com/ws/-/ws-7.2.3.tgz#a5411e1fb04d5ed0efee76d26d5c46d830c39b46" - integrity sha512-HTDl9G9hbkNDk98naoR/cHDws7+EyYMOdL1BmjsZXRUjf7d+MficC4B7HLUPlSiho0vg+CWKrGIt/VJBd1xunQ== + version "7.5.3" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.3.tgz#160835b63c7d97bfab418fc1b8a9fced2ac01a74" + integrity sha512-kQ/dHIzuLrS6Je9+uv81ueZomEwH0qVYstcAQ4/Z93K8zeko9gtAbttJWzoC5ukqXY1PpoouV3+VSOqEAFt5wg== xml-name-validator@^3.0.0: version "3.0.0" From ea75ed777daf24d6e95f43957bd26b1eab20806c Mon Sep 17 00:00:00 2001 From: Ana Maria Martinez Gomez Date: Tue, 27 Jul 2021 16:00:53 +0200 Subject: [PATCH 18/25] Small improvements in test workflow Make easier to read the log. --- .github/workflows/test.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index efac3e0..e7af1b4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -83,10 +83,7 @@ jobs: uses: actions/checkout@v2 - id: files - name: Run the action - uses: ./ - with: - filter: '*' + name: Run the action without filtering - name: Print files run: | @@ -96,10 +93,9 @@ jobs: echo 'steps.files.outputs.removed=${{ steps.files.outputs.removed }}' echo 'steps.files.outputs.renamed=${{ steps.files.outputs.renamed }}' echo 'steps.files.outputs.added_modified=${{ steps.files.outputs.added_modified }}' - + - id: files-filtered - name: Run the action - uses: ./ + name: Run the action with filtering with: filter: | *.yml @@ -108,7 +104,6 @@ jobs: *.ts package* !*.json - - name: Print files-filtered run: | @@ -118,4 +113,4 @@ jobs: echo 'steps.files-filtered.outputs.removed=${{ steps.files-filtered.outputs.removed }}' echo 'steps.files-filtered.outputs.renamed=${{ steps.files-filtered.outputs.renamed }}' echo 'steps.files-filtered.outputs.added_modified=${{ steps.files-filtered.outputs.added_modified }}' - + From 40a8521966f01e4a6c55ebe1c7163fe136881615 Mon Sep 17 00:00:00 2001 From: Jared Forsyth Date: Wed, 4 Aug 2021 10:18:13 -0500 Subject: [PATCH 19/25] Add option to prepend the workspace path to the list of files --- action.yml | 5 +++++ src/main.ts | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 2536c03..1356e24 100644 --- a/action.yml +++ b/action.yml @@ -20,6 +20,11 @@ inputs: Can be 'space-delimited', 'csv', or 'json'. required: true default: space-delimited + absolute: + description: > + Prepend the workspace root to the file paths. + Useful if you're checking them out. + required: false outputs: all: description: > diff --git a/src/main.ts b/src/main.ts index 0f0fdd6..4edec3f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,3 +1,4 @@ +import path from 'path' import * as core from '@actions/core' import {context, GitHub} from '@actions/github' @@ -9,6 +10,7 @@ async function run(): Promise { // Create GitHub client with the API token. const client = new GitHub(core.getInput('token', {required: true})) const format = core.getInput('format', {required: true}) as Format + const absolute = !!core.getInput('absolute', {required: false}) // Ensure that the format parameter is set properly. if (format !== 'space-delimited' && format !== 'csv' && format !== 'json') { @@ -91,7 +93,10 @@ async function run(): Promise { renamed = [] as string[], addedModified = [] as string[] for (const file of files) { - const filename = file.filename + let filename = file.filename + if (absolute) { + filename = path.join(process.env.GITHUB_WORKSPACE, filename) + } // If we're using the 'space-delimited' format and any of the filenames have a space in them, // then fail the step. if (format === 'space-delimited' && filename.includes(' ')) { From b4d0970914d0ab359c84f1ece7c3b3a41835d8b2 Mon Sep 17 00:00:00 2001 From: Jared Forsyth Date: Wed, 4 Aug 2021 10:37:43 -0500 Subject: [PATCH 20/25] redist --- dist/index.js | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/dist/index.js b/dist/index.js index 72c1662..bdab88d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3491,6 +3491,25 @@ function checkMode (stat, options) { "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { @@ -3500,14 +3519,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); +const path_1 = __importDefault(__webpack_require__(622)); const core = __importStar(__webpack_require__(470)); const github_1 = __webpack_require__(469); function run() { @@ -3517,6 +3533,7 @@ function run() { // Create GitHub client with the API token. const client = new github_1.GitHub(core.getInput('token', { required: true })); const format = core.getInput('format', { required: true }); + const absolute = !!core.getInput('absolute', { required: false }); // Ensure that the format parameter is set properly. if (format !== 'space-delimited' && format !== 'csv' && format !== 'json') { core.setFailed(`Format must be one of 'string-delimited', 'csv', or 'json', got '${format}'.`); @@ -3574,7 +3591,10 @@ function run() { const files = response.data.files; const all = [], added = [], modified = [], removed = [], renamed = [], addedModified = []; for (const file of files) { - const filename = file.filename; + let filename = file.filename; + if (absolute) { + filename = path_1.default.join(process.env.GITHUB_WORKSPACE, filename); + } // If we're using the 'space-delimited' format and any of the filenames have a space in them, // then fail the step. if (format === 'space-delimited' && filename.includes(' ')) { From e78d01855cc42357784d7171fcb65e96e72216cd Mon Sep 17 00:00:00 2001 From: Jared Forsyth Date: Wed, 4 Aug 2021 10:55:05 -0500 Subject: [PATCH 21/25] fix --- src/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 33a1589..94ffcd2 100644 --- a/src/main.ts +++ b/src/main.ts @@ -87,7 +87,7 @@ async function run(): Promise { for (const file of files) { let filename = file.filename if (absolute) { - filename = path.join(process.env.GITHUB_WORKSPACE, filename) + filename = path.join(process.env.GITHUB_WORKSPACE || '', filename) } // If we're using the 'space-delimited' format and any of the filenames have a space in them, // then fail the step. From 696e6f79663205e7f00ff5856e87d59c03160982 Mon Sep 17 00:00:00 2001 From: Jared Forsyth Date: Wed, 4 Aug 2021 11:40:25 -0500 Subject: [PATCH 22/25] try using the base /ref/ --- src/main.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main.ts b/src/main.ts index 8577410..0297514 100644 --- a/src/main.ts +++ b/src/main.ts @@ -31,7 +31,7 @@ async function run(): Promise { switch (eventName) { case 'pull_request_target': case 'pull_request': - base = context.payload.pull_request?.base?.sha + base = context.payload.pull_request?.base?.ref head = context.payload.pull_request?.head?.sha break case 'push': @@ -45,7 +45,7 @@ async function run(): Promise { ) } - // Log the base and head commits + // Log the base ref and head commit core.info(`Base commit: ${base}`) core.info(`Head commit: ${head}`) @@ -57,8 +57,7 @@ async function run(): Promise { ) // To satisfy TypeScript, even though this is unreachable. - base = '' - head = '' + process.exit(1) } // Use GitHub's compare two commits API. From 89d3dca932c398add78c3a16b639ee42f9cae4d2 Mon Sep 17 00:00:00 2001 From: Jared Forsyth Date: Wed, 4 Aug 2021 11:45:18 -0500 Subject: [PATCH 23/25] oh rebuild for real --- dist/index.js | 47 ++++++++++++++++------------------------------- src/main.ts | 2 +- 2 files changed, 17 insertions(+), 32 deletions(-) diff --git a/dist/index.js b/dist/index.js index bdab88d..173bf75 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3491,25 +3491,6 @@ function checkMode (stat, options) { "use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { @@ -3522,6 +3503,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; Object.defineProperty(exports, "__esModule", { value: true }); const path_1 = __importDefault(__webpack_require__(622)); const core = __importStar(__webpack_require__(470)); @@ -3534,6 +3522,7 @@ function run() { const client = new github_1.GitHub(core.getInput('token', { required: true })); const format = core.getInput('format', { required: true }); const absolute = !!core.getInput('absolute', { required: false }); + const filter = core.getInput('filter', { required: true }) || '*'; // Ensure that the format parameter is set properly. if (format !== 'space-delimited' && format !== 'csv' && format !== 'json') { core.setFailed(`Format must be one of 'string-delimited', 'csv', or 'json', got '${format}'.`); @@ -3546,8 +3535,9 @@ function run() { let base; let head; switch (eventName) { + case 'pull_request_target': case 'pull_request': - base = (_b = (_a = github_1.context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.base) === null || _b === void 0 ? void 0 : _b.sha; + base = (_b = (_a = github_1.context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.base) === null || _b === void 0 ? void 0 : _b.ref; head = (_d = (_c = github_1.context.payload.pull_request) === null || _c === void 0 ? void 0 : _c.head) === null || _d === void 0 ? void 0 : _d.sha; break; case 'push': @@ -3558,16 +3548,15 @@ function run() { core.setFailed(`This action only supports pull requests and pushes, ${github_1.context.eventName} events are not supported. ` + "Please submit an issue on this action's GitHub repo if you believe this in correct."); } - // Log the base and head commits - core.info(`Base commit: ${base}`); + // Log the base ref and head commit + core.info(`Base ref: ${base}`); core.info(`Head commit: ${head}`); // Ensure that the base and head properties are set on the payload. if (!base || !head) { core.setFailed(`The base and head commits are missing from the payload for this ${github_1.context.eventName} event. ` + "Please submit an issue on this action's GitHub repo."); // To satisfy TypeScript, even though this is unreachable. - base = ''; - head = ''; + process.exit(1); } // Use GitHub's compare two commits API. // https://developer.github.com/v3/repos/commits/#compare-two-commits @@ -3582,18 +3571,14 @@ function run() { core.setFailed(`The GitHub API for comparing the base and head commits for this ${github_1.context.eventName} event returned ${response.status}, expected 200. ` + "Please submit an issue on this action's GitHub repo."); } - // Ensure that the head commit is ahead of the base commit. - if (response.data.status !== 'ahead') { - core.setFailed(`The head commit for this ${github_1.context.eventName} event is not ahead of the base commit. ` + - "Please submit an issue on this action's GitHub repo."); - } + const regex = new RegExp(`/${filter}\\b`, 'g'); // Get the changed files from the response payload. - const files = response.data.files; + const files = response.data.files.filter(file => file.filename.match(regex)); const all = [], added = [], modified = [], removed = [], renamed = [], addedModified = []; for (const file of files) { let filename = file.filename; if (absolute) { - filename = path_1.default.join(process.env.GITHUB_WORKSPACE, filename); + filename = path_1.default.join(process.env.GITHUB_WORKSPACE || '', filename); } // If we're using the 'space-delimited' format and any of the filenames have a space in them, // then fail the step. diff --git a/src/main.ts b/src/main.ts index 0297514..1469e27 100644 --- a/src/main.ts +++ b/src/main.ts @@ -46,7 +46,7 @@ async function run(): Promise { } // Log the base ref and head commit - core.info(`Base commit: ${base}`) + core.info(`Base ref: ${base}`) core.info(`Head commit: ${head}`) // Ensure that the base and head properties are set on the payload. From e43e53e2fc72576ab3291ffe4c5337368f5da13f Mon Sep 17 00:00:00 2001 From: Jared Forsyth Date: Wed, 4 Aug 2021 14:25:10 -0500 Subject: [PATCH 24/25] 1.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1279abb..24fea7f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "get-changed-files", "description": "GitHub action that gets all changed files in a pull request or push.", - "version": "1.0.0", + "version": "1.0.1", "private": true, "author": "Jitterbit, Inc.", "license": "MIT", From 8b82882449cc3ec5c2e7baa90a4a8e97157e6bdf Mon Sep 17 00:00:00 2001 From: Jared Forsyth Date: Wed, 4 Aug 2021 14:42:18 -0500 Subject: [PATCH 25/25] revert --- .github/workflows/test.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ef32357..e7af1b4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -55,10 +55,6 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: '12' - - name: Install dependencies run: | yarn