Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9124514c3 | ||
|
|
90ef0b1b22 | ||
|
|
c648759d89 | ||
|
|
b9ea510e42 | ||
|
|
174a2a6360 | ||
|
|
2d0b52f440 | ||
|
|
d0e3a7c3aa | ||
|
|
2c6893c21a | ||
|
|
17ca5bb3e5 | ||
|
|
61845c2b19 | ||
|
|
417f924dea | ||
|
|
c51a48d4f6 | ||
|
|
a625ca325f | ||
|
|
752970edd0 | ||
|
|
7b64c76932 | ||
|
|
6d9ee62035 | ||
|
|
b27dcc252a | ||
|
|
b60e479cea | ||
|
|
ab8493166b | ||
|
|
9333a5cf0c | ||
|
|
8ec721eb3b | ||
|
|
7d1d4d2cce |
@@ -60,6 +60,8 @@
|
|||||||
"@typescript-eslint/promise-function-async": "error",
|
"@typescript-eslint/promise-function-async": "error",
|
||||||
"@typescript-eslint/require-array-sort-compare": "error",
|
"@typescript-eslint/require-array-sort-compare": "error",
|
||||||
"@typescript-eslint/restrict-plus-operands": "error",
|
"@typescript-eslint/restrict-plus-operands": "error",
|
||||||
|
"no-shadow": "off",
|
||||||
|
"@typescript-eslint/no-shadow": "error",
|
||||||
"semi": "off",
|
"semi": "off",
|
||||||
"filenames/match-regex": [
|
"filenames/match-regex": [
|
||||||
"error",
|
"error",
|
||||||
|
|||||||
2
.github/workflows/submodule-sync.yml
vendored
2
.github/workflows/submodule-sync.yml
vendored
@@ -19,7 +19,7 @@ jobs:
|
|||||||
git submodule update --remote --recursive
|
git submodule update --remote --recursive
|
||||||
|
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
uses: peter-evans/create-pull-request@v5.0.1
|
uses: peter-evans/create-pull-request@v5.0.2
|
||||||
with:
|
with:
|
||||||
title: "Updated submodule"
|
title: "Updated submodule"
|
||||||
labels: "merge when passing"
|
labels: "merge when passing"
|
||||||
|
|||||||
2
.github/workflows/sync-release-version.yml
vendored
2
.github/workflows/sync-release-version.yml
vendored
@@ -24,7 +24,7 @@ jobs:
|
|||||||
- name: Run git-cliff
|
- name: Run git-cliff
|
||||||
uses: tj-actions/git-cliff@v1
|
uses: tj-actions/git-cliff@v1
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
uses: peter-evans/create-pull-request@v5.0.1
|
uses: peter-evans/create-pull-request@v5.0.2
|
||||||
with:
|
with:
|
||||||
base: "main"
|
base: "main"
|
||||||
labels: "merge when passing"
|
labels: "merge when passing"
|
||||||
|
|||||||
37
.github/workflows/test.yml
vendored
37
.github/workflows/test.yml
vendored
@@ -78,7 +78,7 @@ jobs:
|
|||||||
yarn all
|
yarn all
|
||||||
|
|
||||||
- name: Verify Changed files
|
- name: Verify Changed files
|
||||||
uses: tj-actions/verify-changed-files@v14
|
uses: tj-actions/verify-changed-files@v15
|
||||||
id: changed_files
|
id: changed_files
|
||||||
if: github.event_name != 'push'
|
if: github.event_name != 'push'
|
||||||
with:
|
with:
|
||||||
@@ -869,6 +869,41 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
shell:
|
shell:
|
||||||
bash
|
bash
|
||||||
|
- name: Run changed-files for old new filenames test rename 2 output as deleted and added
|
||||||
|
id: changed-files-all-old-new-renamed-files-2-output-as-deleted-and-added
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
base_sha: 4d04215
|
||||||
|
sha: fe238e6
|
||||||
|
fetch_depth: 60000
|
||||||
|
include_all_old_new_renamed_files: true
|
||||||
|
output_renamed_files_as_deleted_and_added: true
|
||||||
|
- name: Show output
|
||||||
|
run: |
|
||||||
|
echo '${{ toJSON(steps.changed-files-all-old-new-renamed-files-2-output-as-deleted-and-added.outputs) }}'
|
||||||
|
shell:
|
||||||
|
bash
|
||||||
|
- name: Check all_old_new_renamed_files output
|
||||||
|
if: "!contains(steps.changed-files-all-old-new-renamed-files-2-output-as-deleted-and-added.outputs.all_old_new_renamed_files, 'test/test rename 2.txt,test/test rename-2.txt')"
|
||||||
|
run: |
|
||||||
|
echo "Invalid output: Expected to include (test/test rename 2.txt test/test rename-2.txt) got (${{ steps.changed-files-all-old-new-renamed-files-2-output-as-deleted-and-added.outputs.all_old_new_renamed_files }})"
|
||||||
|
exit 1
|
||||||
|
shell:
|
||||||
|
bash
|
||||||
|
- name: Check deleted_files output
|
||||||
|
if: "!contains(steps.changed-files-all-old-new-renamed-files-2-output-as-deleted-and-added.outputs.deleted_files, 'test/test rename 2.txt')"
|
||||||
|
run: |
|
||||||
|
echo "Invalid output: Expected to include (test/test rename 2.txt) got (${{ steps.changed-files-all-old-new-renamed-files-2-output-as-deleted-and-added.outputs.deleted_files }})"
|
||||||
|
exit 1
|
||||||
|
shell:
|
||||||
|
bash
|
||||||
|
- name: Check added_files output
|
||||||
|
if: "!contains(steps.changed-files-all-old-new-renamed-files-2-output-as-deleted-and-added.outputs.added_files, 'test/test rename-2.txt')"
|
||||||
|
run: |
|
||||||
|
echo "Invalid output: Expected to include (test/test rename-2.txt) got (${{ steps.changed-files-all-old-new-renamed-files-2-output-as-deleted-and-added.outputs.added_files }})"
|
||||||
|
exit 1
|
||||||
|
shell:
|
||||||
|
bash
|
||||||
- name: Run changed-files with specific files
|
- name: Run changed-files with specific files
|
||||||
id: changed-files-specific
|
id: changed-files-specific
|
||||||
uses: ./
|
uses: ./
|
||||||
|
|||||||
2
.github/workflows/update-readme.yml
vendored
2
.github/workflows/update-readme.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
|||||||
uses: tj-actions/remark@v3
|
uses: tj-actions/remark@v3
|
||||||
|
|
||||||
- name: Verify Changed files
|
- name: Verify Changed files
|
||||||
uses: tj-actions/verify-changed-files@v14
|
uses: tj-actions/verify-changed-files@v15
|
||||||
id: verify_changed_files
|
id: verify_changed_files
|
||||||
with:
|
with:
|
||||||
files: |
|
files: |
|
||||||
|
|||||||
73
HISTORY.md
73
HISTORY.md
@@ -1,5 +1,78 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
# [36.2.0](https://github.com/tj-actions/changed-files/compare/v36.1.0...v36.2.0) - (2023-06-14)
|
||||||
|
|
||||||
|
## <!-- 0 -->🚀 Features
|
||||||
|
|
||||||
|
- Switch to use name status ([#1230](https://github.com/tj-actions/changed-files/issues/1230)) ([174a2a6](https://github.com/tj-actions/changed-files/commit/174a2a6360b54a2019877c254c4be78106efc94f)) - (Tonye Jack)
|
||||||
|
|
||||||
|
## <!-- 26 -->🔄 Update
|
||||||
|
|
||||||
|
- Updated README.md ([#1255](https://github.com/tj-actions/changed-files/issues/1255))
|
||||||
|
|
||||||
|
Co-authored-by: jackton1 <jackton1@users.noreply.github.com> ([2c6893c](https://github.com/tj-actions/changed-files/commit/2c6893c21a91f8238df9e0ed2f3e4488efc0629f)) - (tj-actions[bot])
|
||||||
|
- Update action.yml ([17ca5bb](https://github.com/tj-actions/changed-files/commit/17ca5bb3e554d4d9b631e09414186b64b6e64cd6)) - (Tonye Jack)
|
||||||
|
- Updated README.md ([#1249](https://github.com/tj-actions/changed-files/issues/1249))
|
||||||
|
|
||||||
|
Co-authored-by: jackton1 <jackton1@users.noreply.github.com> ([a625ca3](https://github.com/tj-actions/changed-files/commit/a625ca325f498d75648b0ec941834edc16e71a40)) - (tj-actions[bot])
|
||||||
|
- Updated README.md ([#1248](https://github.com/tj-actions/changed-files/issues/1248))
|
||||||
|
|
||||||
|
Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
|
||||||
|
Co-authored-by: Tonye Jack <jtonye@ymail.com> ([752970e](https://github.com/tj-actions/changed-files/commit/752970edd01e2a1b9e1a9ef37207bd59a34c90f4)) - (tj-actions[bot])
|
||||||
|
- Update action.yml ([7b64c76](https://github.com/tj-actions/changed-files/commit/7b64c76932d2ddd0a2be638832dc8f72eacec74c)) - (Tonye Jack)
|
||||||
|
- Updated README.md ([#1246](https://github.com/tj-actions/changed-files/issues/1246))
|
||||||
|
|
||||||
|
Co-authored-by: repo-ranger[bot] <repo-ranger[bot]@users.noreply.github.com> ([9333a5c](https://github.com/tj-actions/changed-files/commit/9333a5cf0c1a85e3dd5876284bb075ade076a9e0)) - (tj-actions[bot])
|
||||||
|
|
||||||
|
## <!-- 7 -->⚙️ Miscellaneous Tasks
|
||||||
|
|
||||||
|
- **deps:** Update peter-evans/create-pull-request action to v5.0.2 ([#1256](https://github.com/tj-actions/changed-files/issues/1256)) ([2d0b52f](https://github.com/tj-actions/changed-files/commit/2d0b52f4408b791c0c5c1eca405d8461b320dd01)) - (renovate[bot])
|
||||||
|
- **deps:** Update typescript-eslint monorepo to v5.59.11 ([#1253](https://github.com/tj-actions/changed-files/issues/1253)) ([d0e3a7c](https://github.com/tj-actions/changed-files/commit/d0e3a7c3aa15c15ace59f95a9fda1bcadf9ab3e2)) - (renovate[bot])
|
||||||
|
- **deps:** Lock file maintenance ([#1252](https://github.com/tj-actions/changed-files/issues/1252)) ([61845c2](https://github.com/tj-actions/changed-files/commit/61845c2b19ec2ad7e3d79a6955e192e66d41cb80)) - (renovate[bot])
|
||||||
|
- **deps:** Update tj-actions/verify-changed-files action to v15 ([#1251](https://github.com/tj-actions/changed-files/issues/1251)) ([417f924](https://github.com/tj-actions/changed-files/commit/417f924dea3b9800ea861d576eee55162ab6607c)) - (renovate[bot])
|
||||||
|
- **deps:** Lock file maintenance ([#1250](https://github.com/tj-actions/changed-files/issues/1250)) ([c51a48d](https://github.com/tj-actions/changed-files/commit/c51a48d4f6bf95820aa0f9e3f3e6516bd427ae7a)) - (renovate[bot])
|
||||||
|
- Update README.md ([6d9ee62](https://github.com/tj-actions/changed-files/commit/6d9ee62035acb0c3942fba9757033c677246f2f4)) - (Tonye Jack)
|
||||||
|
- Update README.md ([b27dcc2](https://github.com/tj-actions/changed-files/commit/b27dcc252ada558d34ecd368bd253994df77acb1)) - (Tonye Jack)
|
||||||
|
- **deps:** Update dependency @types/uuid to v9.0.2 ([#1247](https://github.com/tj-actions/changed-files/issues/1247)) ([b60e479](https://github.com/tj-actions/changed-files/commit/b60e479ceab551d9a8f832d5a989eb3e492d4bf4)) - (renovate[bot])
|
||||||
|
- Update README.md ([#1237](https://github.com/tj-actions/changed-files/issues/1237)) ([8ec721e](https://github.com/tj-actions/changed-files/commit/8ec721eb3b7d57b7afc0d63748bd7242292989b1)) - (tj-actions[bot])
|
||||||
|
- Update README.md ([#1240](https://github.com/tj-actions/changed-files/issues/1240)) ([7d1d4d2](https://github.com/tj-actions/changed-files/commit/7d1d4d2cce628fd1797af3acb779dd1d26b61d31)) - (tj-actions[bot])
|
||||||
|
|
||||||
|
## <!-- 9 -->⬆️ Upgrades
|
||||||
|
|
||||||
|
- Upgraded to v36.1.0 ([#1245](https://github.com/tj-actions/changed-files/issues/1245))
|
||||||
|
|
||||||
|
Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
|
||||||
|
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com> ([ab84931](https://github.com/tj-actions/changed-files/commit/ab8493166b33b74edc5101f3e814b63cd87f05ab)) - (tj-actions[bot])
|
||||||
|
|
||||||
|
# [36.1.0](https://github.com/tj-actions/changed-files/compare/v36.0.18...v36.1.0) - (2023-06-08)
|
||||||
|
|
||||||
|
## <!-- 0 -->🚀 Features
|
||||||
|
|
||||||
|
- Improve warning message ([#1241](https://github.com/tj-actions/changed-files/issues/1241)) ([f41e41f](https://github.com/tj-actions/changed-files/commit/f41e41fa3fdcbdf47c5f73526be7d81e413f832e)) - (Tonye Jack)
|
||||||
|
|
||||||
|
## <!-- 1 -->🐛 Bug Fixes
|
||||||
|
|
||||||
|
- Bug with errors from fork prs ([#1239](https://github.com/tj-actions/changed-files/issues/1239)) ([e208eb4](https://github.com/tj-actions/changed-files/commit/e208eb429a6a5b3444af0a2099bdbbfcd705fae6)) - (Tonye Jack)
|
||||||
|
- Bug with only_(changed|modified|deleted) outputs ([#1238](https://github.com/tj-actions/changed-files/issues/1238)) ([6dc4095](https://github.com/tj-actions/changed-files/commit/6dc409580193a9e2e52aa4a647684c2ea5a99ddb)) - (Tonye Jack)
|
||||||
|
|
||||||
|
## <!-- 26 -->🔄 Update
|
||||||
|
|
||||||
|
- Update test.yml ([37e5be9](https://github.com/tj-actions/changed-files/commit/37e5be95e281cd60c1d89e92bb25242b37e9db3c)) - (Tonye Jack)
|
||||||
|
|
||||||
|
## <!-- 7 -->⚙️ Miscellaneous Tasks
|
||||||
|
|
||||||
|
- Fix bug with nx set shas ([#1244](https://github.com/tj-actions/changed-files/issues/1244)) ([fb20f4d](https://github.com/tj-actions/changed-files/commit/fb20f4d24890fadc539505b1746d260504b213d0)) - (Tonye Jack)
|
||||||
|
- Update test ([#1243](https://github.com/tj-actions/changed-files/issues/1243)) ([b2a0ba4](https://github.com/tj-actions/changed-files/commit/b2a0ba40a4106c5de8de8ac8b0732f404d084f00)) - (Tonye Jack)
|
||||||
|
- Update event name ([#1242](https://github.com/tj-actions/changed-files/issues/1242)) ([c467712](https://github.com/tj-actions/changed-files/commit/c467712045a1fb370c4f8a2ce40f93c718e7888e)) - (Tonye Jack)
|
||||||
|
- Update test.yml ([f490eea](https://github.com/tj-actions/changed-files/commit/f490eeaa59c0a3957b24214e86c462a2e9a6c7fa)) - (tj-actions[bot])
|
||||||
|
- Improve test coverage ([#1235](https://github.com/tj-actions/changed-files/issues/1235)) ([c784b6f](https://github.com/tj-actions/changed-files/commit/c784b6f1c4775e3db7ddc38d464ae017e41b1576)) - (Tonye Jack)
|
||||||
|
|
||||||
|
## <!-- 9 -->⬆️ Upgrades
|
||||||
|
|
||||||
|
- Upgraded to v36.0.18 ([#1234](https://github.com/tj-actions/changed-files/issues/1234))
|
||||||
|
|
||||||
|
Co-authored-by: jackton1 <jackton1@users.noreply.github.com> ([a522bdb](https://github.com/tj-actions/changed-files/commit/a522bdb715e8ee0e5814bc94f576ebc24cebbfd3)) - (tj-actions[bot])
|
||||||
|
|
||||||
# [36.0.18](https://github.com/tj-actions/changed-files/compare/v36.0.17...v36.0.18) - (2023-06-06)
|
# [36.0.18](https://github.com/tj-actions/changed-files/compare/v36.0.17...v36.0.18) - (2023-06-06)
|
||||||
|
|
||||||
## <!-- 0 -->🚀 Features
|
## <!-- 0 -->🚀 Features
|
||||||
|
|||||||
50
README.md
50
README.md
@@ -71,6 +71,7 @@ Retrieve all changed files and directories relative to a target branch, preceedi
|
|||||||
> * For monorepos where pulling all the branch history might not be desired, you can omit [`actions/checkout`](https://github.com/actions/checkout#usage) - `fetch-depth` for `pull_request` events.
|
> * For monorepos where pulling all the branch history might not be desired, you can omit [`actions/checkout`](https://github.com/actions/checkout#usage) - `fetch-depth` for `pull_request` events.
|
||||||
> * All multiline inputs should not use double or single quotes since the value is already a string seperated by a newline character. See [Examples](#examples) for more information.
|
> * All multiline inputs should not use double or single quotes since the value is already a string seperated by a newline character. See [Examples](#examples) for more information.
|
||||||
> * Ensure that `persist-credentials` is set to `true` when configuring [`actions/checkout`](https://github.com/actions/checkout#usage) if `fetch-depth` isn't set to `0`.
|
> * Ensure that `persist-credentials` is set to `true` when configuring [`actions/checkout`](https://github.com/actions/checkout#usage) if `fetch-depth` isn't set to `0`.
|
||||||
|
> * For repositories that have PR's generated from forks when configuring [`actions/checkout`](https://github.com/actions/checkout#usage) set the `repository` to `${{ github.event.pull_request.head.repo.full_name }}`. See: [Example](https://github.com/tj-actions/changed-files/blob/main/.github/workflows/test.yml#L47-L51)
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: CI
|
name: CI
|
||||||
@@ -171,29 +172,29 @@ Support this project with a :star:
|
|||||||
|
|
||||||
<!-- AUTO-DOC-OUTPUT:START - Do not remove or modify this section -->
|
<!-- AUTO-DOC-OUTPUT:START - Do not remove or modify this section -->
|
||||||
|
|
||||||
| OUTPUT | TYPE | DESCRIPTION |
|
| OUTPUT | TYPE | DESCRIPTION |
|
||||||
|--------------------------------|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|--------------------------------|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| added\_files | string | Returns only files that are <br>Added (A). |
|
| added\_files | string | Returns only files that are <br>Added (A). |
|
||||||
| all\_changed\_and\_modified\_files | string | Returns all changed and modified <br>files i.e. *a combination of (ACMRDTUX)* |
|
| all\_changed\_and\_modified\_files | string | Returns all changed and modified <br>files i.e. *a combination of (ACMRDTUX)* |
|
||||||
| all\_changed\_files | string | Returns all changed files i.e. <br>*a combination of all added, copied, modified and renamed files (ACMR)* |
|
| all\_changed\_files | string | Returns all changed files i.e. <br>*a combination of all added, copied, modified and renamed files (ACMR)* |
|
||||||
| all\_modified\_files | string | Returns all changed files i.e. <br>*a combination of all added, copied, modified, renamed and deleted files (ACMRD)*. |
|
| all\_modified\_files | string | Returns all changed files i.e. <br>*a combination of all added, copied, modified, renamed and deleted files (ACMRD)*. |
|
||||||
| all\_old\_new\_renamed\_files | string | Returns only files that are <br>Renamed and list their old <br>and new names. **NOTE:** This <br>requires setting `include_all_old_new_renamed_files` to `true` <br>(R) |
|
| all\_old\_new\_renamed\_files | string | Returns only files that are <br>Renamed and list their old <br>and new names. **NOTE:** This <br>requires setting `include_all_old_new_renamed_files` to `true` <br>(R) |
|
||||||
| any\_changed | string | Returns `true` when any of <br>the filenames provided using the <br>`files` input has changed. i.e. <br>*using a combination of all added, copied, modified and renamed files (ACMR)*. |
|
| any\_changed | string | Returns `true` when any of <br>the filenames provided using the <br>`files*` or `files_ignore*` inputs has changed. i.e. <br>*using a combination of all added, copied, modified and renamed files (ACMR)*. |
|
||||||
| any\_deleted | string | Returns `true` when any of <br>the filenames provided using the <br>`files` input has been deleted. <br>(D) |
|
| any\_deleted | string | Returns `true` when any of <br>the filenames provided using the <br>`files*` or `files_ignore*` inputs has been deleted. <br>(D) |
|
||||||
| any\_modified | string | Returns `true` when any of <br>the filenames provided using the <br>`files` input has been modified. <br>i.e. *using a combination of all added, copied, modified, renamed, and deleted files (ACMRD)*. |
|
| any\_modified | string | Returns `true` when any of <br>the filenames provided using the <br>`files*` or `files_ignore*` inputs has been modified. <br>i.e. *using a combination of all added, copied, modified, renamed, and deleted files (ACMRD)*. |
|
||||||
| copied\_files | string | Returns only files that are <br>Copied (C). |
|
| copied\_files | string | Returns only files that are <br>Copied (C). |
|
||||||
| deleted\_files | string | Returns only files that are <br>Deleted (D). |
|
| deleted\_files | string | Returns only files that are <br>Deleted (D). |
|
||||||
| modified\_files | string | Returns only files that are <br>Modified (M). |
|
| modified\_files | string | Returns only files that are <br>Modified (M). |
|
||||||
| only\_changed | string | Returns `true` when only files <br>provided using the `files` input <br>has changed. i.e. *using a combination of all added, copied, modified and renamed files (ACMR)*. |
|
| only\_changed | string | Returns `true` when only files <br>provided using the `files*` or `files_ignore*` inputs <br>has changed. i.e. *using a combination of all added, copied, modified and renamed files (ACMR)*. |
|
||||||
| only\_deleted | string | Returns `true` when only files <br>provided using the `files` input <br>has been deleted. (D) |
|
| only\_deleted | string | Returns `true` when only files <br>provided using the `files*` or `files_ignore*` inputs <br>has been deleted. (D) |
|
||||||
| only\_modified | string | Returns `true` when only files <br>provided using the `files` input <br>has been modified. (ACMRD). |
|
| only\_modified | string | Returns `true` when only files <br>provided using the `files*` or `files_ignore*` inputs <br>has been modified. (ACMRD). |
|
||||||
| other\_changed\_files | string | Returns all other changed files <br>not listed in the files <br>input i.e. *using a combination of all added, copied, modified and renamed files (ACMR)*. |
|
| other\_changed\_files | string | Returns all other changed files <br>not listed in the files <br>input i.e. *using a combination of all added, copied, modified and renamed files (ACMR)*. |
|
||||||
| other\_deleted\_files | string | Returns all other deleted files <br>not listed in the files <br>input i.e. *a combination of all deleted files (D)* |
|
| other\_deleted\_files | string | Returns all other deleted files <br>not listed in the files <br>input i.e. *a combination of all deleted files (D)* |
|
||||||
| other\_modified\_files | string | Returns all other modified files <br>not listed in the files <br>input i.e. *a combination of all added, copied, modified, and deleted files (ACMRD)* |
|
| other\_modified\_files | string | Returns all other modified files <br>not listed in the files <br>input i.e. *a combination of all added, copied, modified, and deleted files (ACMRD)* |
|
||||||
| renamed\_files | string | Returns only files that are <br>Renamed (R). |
|
| renamed\_files | string | Returns only files that are <br>Renamed (R). |
|
||||||
| type\_changed\_files | string | Returns only files that have <br>their file type changed (T). |
|
| type\_changed\_files | string | Returns only files that have <br>their file type changed (T). |
|
||||||
| unknown\_files | string | Returns only files that are <br>Unknown (X). |
|
| unknown\_files | string | Returns only files that are <br>Unknown (X). |
|
||||||
| unmerged\_files | string | Returns only files that are <br>Unmerged (U). |
|
| unmerged\_files | string | Returns only files that are <br>Unmerged (U). |
|
||||||
|
|
||||||
<!-- AUTO-DOC-OUTPUT:END -->
|
<!-- AUTO-DOC-OUTPUT:END -->
|
||||||
|
|
||||||
@@ -224,6 +225,7 @@ Support this project with a :star:
|
|||||||
| old\_new\_files\_separator | string | false | `" "` | Split character for old and <br>new renamed filename pairs. |
|
| old\_new\_files\_separator | string | false | `" "` | Split character for old and <br>new renamed filename pairs. |
|
||||||
| old\_new\_separator | string | false | `","` | Split character for old and <br>new filename pairs. |
|
| old\_new\_separator | string | false | `","` | Split character for old and <br>new filename pairs. |
|
||||||
| output\_dir | string | false | `".github/outputs"` | Directory to store output files. |
|
| output\_dir | string | false | `".github/outputs"` | Directory to store output files. |
|
||||||
|
| output\_renamed\_files\_as\_deleted\_and\_added | string | false | `"false"` | Output renamed files as deleted <br>and added files. |
|
||||||
| path | string | false | `"."` | Specify a relative path under <br>`$GITHUB_WORKSPACE` to locate the repository. |
|
| path | string | false | `"."` | Specify a relative path under <br>`$GITHUB_WORKSPACE` to locate the repository. |
|
||||||
| quotepath | string | false | `"true"` | Use non ascii characters to <br>match files and output the <br>filenames completely verbatim by setting <br>this to `false` |
|
| quotepath | string | false | `"true"` | Use non ascii characters to <br>match files and output the <br>filenames completely verbatim by setting <br>this to `false` |
|
||||||
| separator | string | false | `" "` | Split character for output strings |
|
| separator | string | false | `" "` | Split character for output strings |
|
||||||
@@ -231,7 +233,7 @@ Support this project with a :star:
|
|||||||
| since | string | false | | Get changed files for commits <br>whose timestamp is older than <br>the given time. |
|
| since | string | false | | Get changed files for commits <br>whose timestamp is older than <br>the given time. |
|
||||||
| since\_last\_remote\_commit | string | false | `"false"` | Use the last commit on <br>the remote branch as the <br>`base_sha`. Defaults to the last <br>non merge commit on the <br>target branch for pull request <br>events and the previous remote <br>commit of the current branch <br>for push events. |
|
| since\_last\_remote\_commit | string | false | `"false"` | Use the last commit on <br>the remote branch as the <br>`base_sha`. Defaults to the last <br>non merge commit on the <br>target branch for pull request <br>events and the previous remote <br>commit of the current branch <br>for push events. |
|
||||||
| until | string | false | | Get changed files for commits <br>whose timestamp is earlier than <br>the given time. |
|
| until | string | false | | Get changed files for commits <br>whose timestamp is earlier than <br>the given time. |
|
||||||
| write\_output\_files | string | false | `"false"` | Write outputs to files in <br>the `.github/outputs` folder by default. |
|
| write\_output\_files | string | false | `"false"` | Write outputs to the `output_dir` <br>defaults to `.github/outputs` folder. **NOTE:** <br>This creates a `.txt` file <br>by default and a `.json` <br>file if `json` is set <br>to `true`. |
|
||||||
|
|
||||||
<!-- AUTO-DOC-INPUT:END -->
|
<!-- AUTO-DOC-INPUT:END -->
|
||||||
|
|
||||||
|
|||||||
18
action.yml
18
action.yml
@@ -110,13 +110,17 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
default: "false"
|
default: "false"
|
||||||
write_output_files:
|
write_output_files:
|
||||||
description: "Write outputs to files in the `.github/outputs` folder by default."
|
description: "Write outputs to the `output_dir` defaults to `.github/outputs` folder. **NOTE:** This creates a `.txt` file by default and a `.json` file if `json` is set to `true`."
|
||||||
required: false
|
required: false
|
||||||
default: "false"
|
default: "false"
|
||||||
output_dir:
|
output_dir:
|
||||||
description: "Directory to store output files."
|
description: "Directory to store output files."
|
||||||
required: false
|
required: false
|
||||||
default: ".github/outputs"
|
default: ".github/outputs"
|
||||||
|
output_renamed_files_as_deleted_and_added:
|
||||||
|
description: "Output renamed files as deleted and added files."
|
||||||
|
required: false
|
||||||
|
default: "false"
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
added_files:
|
added_files:
|
||||||
@@ -142,23 +146,23 @@ outputs:
|
|||||||
all_changed_files:
|
all_changed_files:
|
||||||
description: "Returns all changed files i.e. *a combination of all added, copied, modified and renamed files (ACMR)*"
|
description: "Returns all changed files i.e. *a combination of all added, copied, modified and renamed files (ACMR)*"
|
||||||
any_changed:
|
any_changed:
|
||||||
description: "Returns `true` when any of the filenames provided using the `files` input has changed. i.e. *using a combination of all added, copied, modified and renamed files (ACMR)*."
|
description: "Returns `true` when any of the filenames provided using the `files*` or `files_ignore*` inputs has changed. i.e. *using a combination of all added, copied, modified and renamed files (ACMR)*."
|
||||||
only_changed:
|
only_changed:
|
||||||
description: "Returns `true` when only files provided using the `files` input has changed. i.e. *using a combination of all added, copied, modified and renamed files (ACMR)*."
|
description: "Returns `true` when only files provided using the `files*` or `files_ignore*` inputs has changed. i.e. *using a combination of all added, copied, modified and renamed files (ACMR)*."
|
||||||
other_changed_files:
|
other_changed_files:
|
||||||
description: "Returns all other changed files not listed in the files input i.e. *using a combination of all added, copied, modified and renamed files (ACMR)*."
|
description: "Returns all other changed files not listed in the files input i.e. *using a combination of all added, copied, modified and renamed files (ACMR)*."
|
||||||
all_modified_files:
|
all_modified_files:
|
||||||
description: "Returns all changed files i.e. *a combination of all added, copied, modified, renamed and deleted files (ACMRD)*."
|
description: "Returns all changed files i.e. *a combination of all added, copied, modified, renamed and deleted files (ACMRD)*."
|
||||||
any_modified:
|
any_modified:
|
||||||
description: "Returns `true` when any of the filenames provided using the `files` input has been modified. i.e. *using a combination of all added, copied, modified, renamed, and deleted files (ACMRD)*."
|
description: "Returns `true` when any of the filenames provided using the `files*` or `files_ignore*` inputs has been modified. i.e. *using a combination of all added, copied, modified, renamed, and deleted files (ACMRD)*."
|
||||||
only_modified:
|
only_modified:
|
||||||
description: "Returns `true` when only files provided using the `files` input has been modified. (ACMRD)."
|
description: "Returns `true` when only files provided using the `files*` or `files_ignore*` inputs has been modified. (ACMRD)."
|
||||||
other_modified_files:
|
other_modified_files:
|
||||||
description: "Returns all other modified files not listed in the files input i.e. *a combination of all added, copied, modified, and deleted files (ACMRD)*"
|
description: "Returns all other modified files not listed in the files input i.e. *a combination of all added, copied, modified, and deleted files (ACMRD)*"
|
||||||
any_deleted:
|
any_deleted:
|
||||||
description: "Returns `true` when any of the filenames provided using the `files` input has been deleted. (D)"
|
description: "Returns `true` when any of the filenames provided using the `files*` or `files_ignore*` inputs has been deleted. (D)"
|
||||||
only_deleted:
|
only_deleted:
|
||||||
description: "Returns `true` when only files provided using the `files` input has been deleted. (D)"
|
description: "Returns `true` when only files provided using the `files*` or `files_ignore*` inputs has been deleted. (D)"
|
||||||
other_deleted_files:
|
other_deleted_files:
|
||||||
description: "Returns all other deleted files not listed in the files input i.e. *a combination of all deleted files (D)*"
|
description: "Returns all other deleted files not listed in the files input i.e. *a combination of all deleted files (D)*"
|
||||||
|
|
||||||
|
|||||||
814
dist/index.js
generated
vendored
814
dist/index.js
generated
vendored
File diff suppressed because it is too large
Load Diff
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
51
dist/licenses.txt
generated
vendored
51
dist/licenses.txt
generated
vendored
@@ -134,6 +134,57 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
lodash
|
||||||
|
MIT
|
||||||
|
Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
||||||
|
|
||||||
|
Based on Underscore.js, copyright Jeremy Ashkenas,
|
||||||
|
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
||||||
|
|
||||||
|
This software consists of voluntary contributions made by many
|
||||||
|
individuals. For exact contribution history, see the revision history
|
||||||
|
available at https://github.com/lodash/lodash
|
||||||
|
|
||||||
|
The following license applies to all parts of this software except as
|
||||||
|
documented below:
|
||||||
|
|
||||||
|
====
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
====
|
||||||
|
|
||||||
|
Copyright and related rights for sample code are waived via CC0. Sample
|
||||||
|
code is defined as all source code displayed within the prose of the
|
||||||
|
documentation.
|
||||||
|
|
||||||
|
CC0: http://creativecommons.org/publicdomain/zero/1.0/
|
||||||
|
|
||||||
|
====
|
||||||
|
|
||||||
|
Files located in the node_modules and vendor directories are externally
|
||||||
|
maintained libraries used by this software which have their own
|
||||||
|
licenses; we recommend you read them, as their terms may differ from the
|
||||||
|
terms above.
|
||||||
|
|
||||||
|
|
||||||
micromatch
|
micromatch
|
||||||
MIT
|
MIT
|
||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|||||||
@@ -34,15 +34,17 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "1.10.0",
|
"@actions/core": "1.10.0",
|
||||||
"@actions/exec": "1.1.1",
|
"@actions/exec": "1.1.1",
|
||||||
|
"lodash": "^4.17.15",
|
||||||
"micromatch": "^4.0.5"
|
"micromatch": "^4.0.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "29.5.2",
|
"@types/jest": "29.5.2",
|
||||||
|
"@types/lodash": "^4.14.195",
|
||||||
"@types/micromatch": "^4.0.2",
|
"@types/micromatch": "^4.0.2",
|
||||||
"@types/node": "20.2.1",
|
"@types/node": "20.2.1",
|
||||||
"@types/uuid": "9.0.1",
|
"@types/uuid": "9.0.2",
|
||||||
"@typescript-eslint/eslint-plugin": "5.59.9",
|
"@typescript-eslint/eslint-plugin": "5.59.11",
|
||||||
"@typescript-eslint/parser": "5.59.9",
|
"@typescript-eslint/parser": "5.59.11",
|
||||||
"@vercel/ncc": "0.36.1",
|
"@vercel/ncc": "0.36.1",
|
||||||
"eslint": "8.42.0",
|
"eslint": "8.42.0",
|
||||||
"eslint-plugin-github": "4.8.0",
|
"eslint-plugin-github": "4.8.0",
|
||||||
|
|||||||
@@ -4,11 +4,12 @@ import {DiffResult} from './commitSha'
|
|||||||
import {Inputs} from './inputs'
|
import {Inputs} from './inputs'
|
||||||
import {
|
import {
|
||||||
getDirnameMaxDepth,
|
getDirnameMaxDepth,
|
||||||
gitDiff,
|
|
||||||
gitRenamedFiles,
|
gitRenamedFiles,
|
||||||
gitSubmoduleDiffSHA,
|
gitSubmoduleDiffSHA,
|
||||||
jsonOutput
|
jsonOutput,
|
||||||
|
getAllChangedFiles
|
||||||
} from './utils'
|
} from './utils'
|
||||||
|
import flatten from 'lodash/flatten'
|
||||||
|
|
||||||
export const getRenamedFiles = async ({
|
export const getRenamedFiles = async ({
|
||||||
inputs,
|
inputs,
|
||||||
@@ -68,30 +69,40 @@ export const getRenamedFiles = async ({
|
|||||||
return renamedFiles.join(inputs.oldNewFilesSeparator)
|
return renamedFiles.join(inputs.oldNewFilesSeparator)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getDiffFiles = async ({
|
export enum ChangeTypeEnum {
|
||||||
inputs,
|
Added = 'A',
|
||||||
|
Copied = 'C',
|
||||||
|
Deleted = 'D',
|
||||||
|
Modified = 'M',
|
||||||
|
Renamed = 'R',
|
||||||
|
TypeChanged = 'T',
|
||||||
|
Unmerged = 'U',
|
||||||
|
Unknown = 'X'
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ChangedFiles = {
|
||||||
|
[key in ChangeTypeEnum]: string[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getAllDiffFiles = async ({
|
||||||
workingDirectory,
|
workingDirectory,
|
||||||
hasSubmodule,
|
hasSubmodule,
|
||||||
diffResult,
|
diffResult,
|
||||||
diffFilter,
|
submodulePaths,
|
||||||
filePatterns = [],
|
outputRenamedFilesAsDeletedAndAdded
|
||||||
submodulePaths
|
|
||||||
}: {
|
}: {
|
||||||
inputs: Inputs
|
|
||||||
workingDirectory: string
|
workingDirectory: string
|
||||||
hasSubmodule: boolean
|
hasSubmodule: boolean
|
||||||
diffResult: DiffResult
|
diffResult: DiffResult
|
||||||
diffFilter: string
|
|
||||||
filePatterns?: string[]
|
|
||||||
submodulePaths: string[]
|
submodulePaths: string[]
|
||||||
}): Promise<string> => {
|
outputRenamedFilesAsDeletedAndAdded: boolean
|
||||||
let files = await gitDiff({
|
}): Promise<ChangedFiles> => {
|
||||||
|
const files = await getAllChangedFiles({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
sha1: diffResult.previousSha,
|
sha1: diffResult.previousSha,
|
||||||
sha2: diffResult.currentSha,
|
sha2: diffResult.currentSha,
|
||||||
diff: diffResult.diff,
|
diff: diffResult.diff,
|
||||||
diffFilter,
|
outputRenamedFilesAsDeletedAndAdded
|
||||||
filePatterns
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if (hasSubmodule) {
|
if (hasSubmodule) {
|
||||||
@@ -110,32 +121,108 @@ export const getDiffFiles = async ({
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (submoduleShaResult.currentSha && submoduleShaResult.previousSha) {
|
if (submoduleShaResult.currentSha && submoduleShaResult.previousSha) {
|
||||||
const submoduleFiles = await gitDiff({
|
const submoduleFiles = await getAllChangedFiles({
|
||||||
cwd: submoduleWorkingDirectory,
|
cwd: submoduleWorkingDirectory,
|
||||||
sha1: submoduleShaResult.previousSha,
|
sha1: submoduleShaResult.previousSha,
|
||||||
sha2: submoduleShaResult.currentSha,
|
sha2: submoduleShaResult.currentSha,
|
||||||
diff: diffResult.diff,
|
diff: diffResult.diff,
|
||||||
diffFilter,
|
|
||||||
isSubmodule: true,
|
isSubmodule: true,
|
||||||
filePatterns,
|
parentDir: submodulePath,
|
||||||
parentDir: submodulePath
|
outputRenamedFilesAsDeletedAndAdded
|
||||||
})
|
})
|
||||||
files.push(...submoduleFiles)
|
|
||||||
|
for (const changeType of Object.keys(
|
||||||
|
submoduleFiles
|
||||||
|
) as ChangeTypeEnum[]) {
|
||||||
|
if (!files[changeType]) {
|
||||||
|
files[changeType] = []
|
||||||
|
}
|
||||||
|
files[changeType].push(...submoduleFiles[changeType])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inputs.dirNames) {
|
return files
|
||||||
files = files.map(file =>
|
}
|
||||||
getDirnameMaxDepth({
|
|
||||||
pathStr: file,
|
function* getChangeTypeFilesGenerator({
|
||||||
dirNamesMaxDepth: inputs.dirNamesMaxDepth,
|
inputs,
|
||||||
excludeCurrentDir:
|
changedFiles,
|
||||||
inputs.dirNamesExcludeRoot || inputs.dirNamesExcludeCurrentDir
|
changeTypes
|
||||||
})
|
}: {
|
||||||
)
|
inputs: Inputs
|
||||||
files = [...new Set(files)]
|
changedFiles: ChangedFiles
|
||||||
|
changeTypes: ChangeTypeEnum[]
|
||||||
|
}): Generator<string> {
|
||||||
|
for (const changeType of changeTypes) {
|
||||||
|
const files = changedFiles[changeType] || []
|
||||||
|
for (const file of files) {
|
||||||
|
if (inputs.dirNames) {
|
||||||
|
yield getDirnameMaxDepth({
|
||||||
|
pathStr: file,
|
||||||
|
dirNamesMaxDepth: inputs.dirNamesMaxDepth,
|
||||||
|
excludeCurrentDir:
|
||||||
|
inputs.dirNamesExcludeRoot || inputs.dirNamesExcludeCurrentDir
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
yield file
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getChangeTypeFiles = async ({
|
||||||
|
inputs,
|
||||||
|
changedFiles,
|
||||||
|
changeTypes
|
||||||
|
}: {
|
||||||
|
inputs: Inputs
|
||||||
|
changedFiles: ChangedFiles
|
||||||
|
changeTypes: ChangeTypeEnum[]
|
||||||
|
}): Promise<string> => {
|
||||||
|
const files = [
|
||||||
|
...new Set(getChangeTypeFilesGenerator({inputs, changedFiles, changeTypes}))
|
||||||
|
]
|
||||||
|
|
||||||
|
if (inputs.json) {
|
||||||
|
return jsonOutput({value: files, shouldEscape: inputs.escapeJson})
|
||||||
|
}
|
||||||
|
|
||||||
|
return files.join(inputs.separator)
|
||||||
|
}
|
||||||
|
|
||||||
|
function* getAllChangeTypeFilesGenerator({
|
||||||
|
inputs,
|
||||||
|
changedFiles
|
||||||
|
}: {
|
||||||
|
inputs: Inputs
|
||||||
|
changedFiles: ChangedFiles
|
||||||
|
}): Generator<string> {
|
||||||
|
for (const file of flatten(Object.values(changedFiles))) {
|
||||||
|
if (inputs.dirNames) {
|
||||||
|
yield getDirnameMaxDepth({
|
||||||
|
pathStr: file,
|
||||||
|
dirNamesMaxDepth: inputs.dirNamesMaxDepth,
|
||||||
|
excludeCurrentDir:
|
||||||
|
inputs.dirNamesExcludeRoot || inputs.dirNamesExcludeCurrentDir
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
yield file
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getAllChangeTypeFiles = async ({
|
||||||
|
inputs,
|
||||||
|
changedFiles
|
||||||
|
}: {
|
||||||
|
inputs: Inputs
|
||||||
|
changedFiles: ChangedFiles
|
||||||
|
}): Promise<string> => {
|
||||||
|
const files = [
|
||||||
|
...new Set(getAllChangeTypeFilesGenerator({inputs, changedFiles}))
|
||||||
|
]
|
||||||
|
|
||||||
if (inputs.json) {
|
if (inputs.json) {
|
||||||
return jsonOutput({value: files, shouldEscape: inputs.escapeJson})
|
return jsonOutput({value: files, shouldEscape: inputs.escapeJson})
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ export const getSHAForPushEvent = async (
|
|||||||
workingDirectory: string,
|
workingDirectory: string,
|
||||||
isShallow: boolean,
|
isShallow: boolean,
|
||||||
hasSubmodule: boolean,
|
hasSubmodule: boolean,
|
||||||
gitExtraArgs: string[],
|
gitFetchExtraArgs: string[],
|
||||||
isTag: boolean
|
isTag: boolean
|
||||||
): Promise<DiffResult> => {
|
): Promise<DiffResult> => {
|
||||||
let targetBranch = env.GITHUB_REF_NAME
|
let targetBranch = env.GITHUB_REF_NAME
|
||||||
@@ -102,7 +102,7 @@ export const getSHAForPushEvent = async (
|
|||||||
await gitFetch({
|
await gitFetch({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
args: [
|
args: [
|
||||||
...gitExtraArgs,
|
...gitFetchExtraArgs,
|
||||||
'-u',
|
'-u',
|
||||||
'--progress',
|
'--progress',
|
||||||
`--deepen=${inputs.fetchDepth}`,
|
`--deepen=${inputs.fetchDepth}`,
|
||||||
@@ -114,7 +114,7 @@ export const getSHAForPushEvent = async (
|
|||||||
await gitFetch({
|
await gitFetch({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
args: [
|
args: [
|
||||||
...gitExtraArgs,
|
...gitFetchExtraArgs,
|
||||||
'-u',
|
'-u',
|
||||||
'--progress',
|
'--progress',
|
||||||
`--deepen=${inputs.fetchDepth}`,
|
`--deepen=${inputs.fetchDepth}`,
|
||||||
@@ -128,7 +128,7 @@ export const getSHAForPushEvent = async (
|
|||||||
await gitFetchSubmodules({
|
await gitFetchSubmodules({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
args: [
|
args: [
|
||||||
...gitExtraArgs,
|
...gitFetchExtraArgs,
|
||||||
'-u',
|
'-u',
|
||||||
'--progress',
|
'--progress',
|
||||||
`--deepen=${inputs.fetchDepth}`
|
`--deepen=${inputs.fetchDepth}`
|
||||||
@@ -263,7 +263,7 @@ export const getSHAForPullRequestEvent = async (
|
|||||||
workingDirectory: string,
|
workingDirectory: string,
|
||||||
isShallow: boolean,
|
isShallow: boolean,
|
||||||
hasSubmodule: boolean,
|
hasSubmodule: boolean,
|
||||||
gitExtraArgs: string[]
|
gitFetchExtraArgs: string[]
|
||||||
): Promise<DiffResult> => {
|
): Promise<DiffResult> => {
|
||||||
let targetBranch = env.GITHUB_EVENT_PULL_REQUEST_BASE_REF
|
let targetBranch = env.GITHUB_EVENT_PULL_REQUEST_BASE_REF
|
||||||
const currentBranch = env.GITHUB_EVENT_PULL_REQUEST_HEAD_REF
|
const currentBranch = env.GITHUB_EVENT_PULL_REQUEST_HEAD_REF
|
||||||
@@ -277,7 +277,7 @@ export const getSHAForPullRequestEvent = async (
|
|||||||
let prFetchExitCode = await gitFetch({
|
let prFetchExitCode = await gitFetch({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
args: [
|
args: [
|
||||||
...gitExtraArgs,
|
...gitFetchExtraArgs,
|
||||||
'-u',
|
'-u',
|
||||||
'--progress',
|
'--progress',
|
||||||
'origin',
|
'origin',
|
||||||
@@ -289,7 +289,7 @@ export const getSHAForPullRequestEvent = async (
|
|||||||
prFetchExitCode = await gitFetch({
|
prFetchExitCode = await gitFetch({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
args: [
|
args: [
|
||||||
...gitExtraArgs,
|
...gitFetchExtraArgs,
|
||||||
'-u',
|
'-u',
|
||||||
'--progress',
|
'--progress',
|
||||||
`--deepen=${inputs.fetchDepth}`,
|
`--deepen=${inputs.fetchDepth}`,
|
||||||
@@ -310,7 +310,7 @@ export const getSHAForPullRequestEvent = async (
|
|||||||
await gitFetch({
|
await gitFetch({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
args: [
|
args: [
|
||||||
...gitExtraArgs,
|
...gitFetchExtraArgs,
|
||||||
'-u',
|
'-u',
|
||||||
'--progress',
|
'--progress',
|
||||||
`--deepen=${inputs.fetchDepth}`,
|
`--deepen=${inputs.fetchDepth}`,
|
||||||
@@ -323,7 +323,7 @@ export const getSHAForPullRequestEvent = async (
|
|||||||
await gitFetchSubmodules({
|
await gitFetchSubmodules({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
args: [
|
args: [
|
||||||
...gitExtraArgs,
|
...gitFetchExtraArgs,
|
||||||
'-u',
|
'-u',
|
||||||
'--progress',
|
'--progress',
|
||||||
`--deepen=${inputs.fetchDepth}`
|
`--deepen=${inputs.fetchDepth}`
|
||||||
@@ -373,8 +373,14 @@ export const getSHAForPullRequestEvent = async (
|
|||||||
previousSha = env.GITHUB_EVENT_BEFORE
|
previousSha = env.GITHUB_EVENT_BEFORE
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(await verifyCommitSha({sha: previousSha, cwd: workingDirectory})) !== 0
|
!previousSha ||
|
||||||
|
(previousSha &&
|
||||||
|
(await verifyCommitSha({sha: previousSha, cwd: workingDirectory})) !==
|
||||||
|
0)
|
||||||
) {
|
) {
|
||||||
|
core.warning(
|
||||||
|
'Unable to locate the remote branch head sha. Falling back to the pull request base sha.'
|
||||||
|
)
|
||||||
previousSha = env.GITHUB_EVENT_PULL_REQUEST_BASE_SHA
|
previousSha = env.GITHUB_EVENT_PULL_REQUEST_BASE_SHA
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -404,7 +410,7 @@ export const getSHAForPullRequestEvent = async (
|
|||||||
await gitFetch({
|
await gitFetch({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
args: [
|
args: [
|
||||||
...gitExtraArgs,
|
...gitFetchExtraArgs,
|
||||||
'-u',
|
'-u',
|
||||||
'--progress',
|
'--progress',
|
||||||
`--deepen=${inputs.fetchDepth}`,
|
`--deepen=${inputs.fetchDepth}`,
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ export type Inputs = {
|
|||||||
sinceLastRemoteCommit: boolean
|
sinceLastRemoteCommit: boolean
|
||||||
writeOutputFiles: boolean
|
writeOutputFiles: boolean
|
||||||
outputDir: string
|
outputDir: string
|
||||||
|
outputRenamedFilesAsDeletedAndAdded: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getInputs = (): Inputs => {
|
export const getInputs = (): Inputs => {
|
||||||
@@ -111,6 +112,10 @@ export const getInputs = (): Inputs => {
|
|||||||
required: false
|
required: false
|
||||||
})
|
})
|
||||||
const outputDir = core.getInput('output_dir', {required: false})
|
const outputDir = core.getInput('output_dir', {required: false})
|
||||||
|
const outputRenamedFilesAsDeletedAndAdded = core.getBooleanInput(
|
||||||
|
'output_renamed_files_as_deleted_and_added',
|
||||||
|
{required: false}
|
||||||
|
)
|
||||||
|
|
||||||
const inputs: Inputs = {
|
const inputs: Inputs = {
|
||||||
files,
|
files,
|
||||||
@@ -139,7 +144,8 @@ export const getInputs = (): Inputs => {
|
|||||||
escapeJson,
|
escapeJson,
|
||||||
sinceLastRemoteCommit,
|
sinceLastRemoteCommit,
|
||||||
writeOutputFiles,
|
writeOutputFiles,
|
||||||
outputDir
|
outputDir,
|
||||||
|
outputRenamedFilesAsDeletedAndAdded
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fetchDepth) {
|
if (fetchDepth) {
|
||||||
|
|||||||
199
src/main.ts
199
src/main.ts
@@ -1,15 +1,22 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import {getDiffFiles, getRenamedFiles} from './changedFiles'
|
|
||||||
import {
|
import {
|
||||||
|
getAllChangeTypeFiles,
|
||||||
|
getAllDiffFiles,
|
||||||
|
getChangeTypeFiles,
|
||||||
|
getRenamedFiles,
|
||||||
|
ChangeTypeEnum
|
||||||
|
} from './changedFiles'
|
||||||
|
import {
|
||||||
|
DiffResult,
|
||||||
getSHAForPullRequestEvent,
|
getSHAForPullRequestEvent,
|
||||||
getSHAForPushEvent,
|
getSHAForPushEvent
|
||||||
DiffResult
|
|
||||||
} from './commitSha'
|
} from './commitSha'
|
||||||
import {getEnv} from './env'
|
import {getEnv} from './env'
|
||||||
import {getInputs} from './inputs'
|
import {getInputs} from './inputs'
|
||||||
import {
|
import {
|
||||||
getFilePatterns,
|
getFilePatterns,
|
||||||
|
getFilteredChangedFiles,
|
||||||
getSubmodulePath,
|
getSubmodulePath,
|
||||||
isRepoShallow,
|
isRepoShallow,
|
||||||
setOutput,
|
setOutput,
|
||||||
@@ -52,8 +59,10 @@ export async function run(): Promise<void> {
|
|||||||
)
|
)
|
||||||
const isShallow = await isRepoShallow({cwd: workingDirectory})
|
const isShallow = await isRepoShallow({cwd: workingDirectory})
|
||||||
const hasSubmodule = await submoduleExists({cwd: workingDirectory})
|
const hasSubmodule = await submoduleExists({cwd: workingDirectory})
|
||||||
let gitExtraArgs = ['--no-tags', '--prune', '--recurse-submodules']
|
let gitFetchExtraArgs = ['--no-tags', '--prune', '--recurse-submodules']
|
||||||
const isTag = env.GITHUB_REF?.startsWith('refs/tags/')
|
const isTag = env.GITHUB_REF?.startsWith('refs/tags/')
|
||||||
|
const outputRenamedFilesAsDeletedAndAdded =
|
||||||
|
inputs.outputRenamedFilesAsDeletedAndAdded
|
||||||
let submodulePaths: string[] = []
|
let submodulePaths: string[] = []
|
||||||
|
|
||||||
if (hasSubmodule) {
|
if (hasSubmodule) {
|
||||||
@@ -61,7 +70,7 @@ export async function run(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isTag) {
|
if (isTag) {
|
||||||
gitExtraArgs = ['--prune', '--no-recurse-submodules']
|
gitFetchExtraArgs = ['--prune', '--no-recurse-submodules']
|
||||||
}
|
}
|
||||||
|
|
||||||
let diffResult: DiffResult
|
let diffResult: DiffResult
|
||||||
@@ -74,7 +83,7 @@ export async function run(): Promise<void> {
|
|||||||
workingDirectory,
|
workingDirectory,
|
||||||
isShallow,
|
isShallow,
|
||||||
hasSubmodule,
|
hasSubmodule,
|
||||||
gitExtraArgs,
|
gitFetchExtraArgs,
|
||||||
isTag
|
isTag
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
@@ -87,7 +96,7 @@ export async function run(): Promise<void> {
|
|||||||
workingDirectory,
|
workingDirectory,
|
||||||
isShallow,
|
isShallow,
|
||||||
hasSubmodule,
|
hasSubmodule,
|
||||||
gitExtraArgs
|
gitFetchExtraArgs
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,15 +114,27 @@ export async function run(): Promise<void> {
|
|||||||
inputs,
|
inputs,
|
||||||
workingDirectory
|
workingDirectory
|
||||||
})
|
})
|
||||||
|
core.debug(`File patterns: ${filePatterns}`)
|
||||||
|
|
||||||
const addedFiles = await getDiffFiles({
|
const allDiffFiles = await getAllDiffFiles({
|
||||||
inputs,
|
|
||||||
workingDirectory,
|
workingDirectory,
|
||||||
hasSubmodule,
|
hasSubmodule,
|
||||||
diffResult,
|
diffResult,
|
||||||
diffFilter: 'A',
|
submodulePaths,
|
||||||
filePatterns,
|
outputRenamedFilesAsDeletedAndAdded
|
||||||
submodulePaths
|
})
|
||||||
|
core.debug(`All diff files: ${JSON.stringify(allDiffFiles)}`)
|
||||||
|
|
||||||
|
const allFilteredDiffFiles = await getFilteredChangedFiles({
|
||||||
|
allDiffFiles,
|
||||||
|
filePatterns
|
||||||
|
})
|
||||||
|
core.debug(`All filtered diff files: ${JSON.stringify(allFilteredDiffFiles)}`)
|
||||||
|
|
||||||
|
const addedFiles = await getChangeTypeFiles({
|
||||||
|
inputs,
|
||||||
|
changedFiles: allFilteredDiffFiles,
|
||||||
|
changeTypes: [ChangeTypeEnum.Added]
|
||||||
})
|
})
|
||||||
core.debug(`Added files: ${addedFiles}`)
|
core.debug(`Added files: ${addedFiles}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
@@ -122,14 +143,10 @@ export async function run(): Promise<void> {
|
|||||||
inputs
|
inputs
|
||||||
})
|
})
|
||||||
|
|
||||||
const copiedFiles = await getDiffFiles({
|
const copiedFiles = await getChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [ChangeTypeEnum.Copied]
|
||||||
diffResult,
|
|
||||||
diffFilter: 'C',
|
|
||||||
filePatterns,
|
|
||||||
submodulePaths
|
|
||||||
})
|
})
|
||||||
core.debug(`Copied files: ${copiedFiles}`)
|
core.debug(`Copied files: ${copiedFiles}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
@@ -138,14 +155,10 @@ export async function run(): Promise<void> {
|
|||||||
inputs
|
inputs
|
||||||
})
|
})
|
||||||
|
|
||||||
const modifiedFiles = await getDiffFiles({
|
const modifiedFiles = await getChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [ChangeTypeEnum.Modified]
|
||||||
diffResult,
|
|
||||||
diffFilter: 'M',
|
|
||||||
filePatterns,
|
|
||||||
submodulePaths
|
|
||||||
})
|
})
|
||||||
core.debug(`Modified files: ${modifiedFiles}`)
|
core.debug(`Modified files: ${modifiedFiles}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
@@ -154,14 +167,10 @@ export async function run(): Promise<void> {
|
|||||||
inputs
|
inputs
|
||||||
})
|
})
|
||||||
|
|
||||||
const renamedFiles = await getDiffFiles({
|
const renamedFiles = await getChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [ChangeTypeEnum.Renamed]
|
||||||
diffResult,
|
|
||||||
diffFilter: 'R',
|
|
||||||
filePatterns,
|
|
||||||
submodulePaths
|
|
||||||
})
|
})
|
||||||
core.debug(`Renamed files: ${renamedFiles}`)
|
core.debug(`Renamed files: ${renamedFiles}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
@@ -170,14 +179,10 @@ export async function run(): Promise<void> {
|
|||||||
inputs
|
inputs
|
||||||
})
|
})
|
||||||
|
|
||||||
const typeChangedFiles = await getDiffFiles({
|
const typeChangedFiles = await getChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [ChangeTypeEnum.TypeChanged]
|
||||||
diffResult,
|
|
||||||
diffFilter: 'T',
|
|
||||||
filePatterns,
|
|
||||||
submodulePaths
|
|
||||||
})
|
})
|
||||||
core.debug(`Type changed files: ${typeChangedFiles}`)
|
core.debug(`Type changed files: ${typeChangedFiles}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
@@ -186,14 +191,10 @@ export async function run(): Promise<void> {
|
|||||||
inputs
|
inputs
|
||||||
})
|
})
|
||||||
|
|
||||||
const unmergedFiles = await getDiffFiles({
|
const unmergedFiles = await getChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [ChangeTypeEnum.Unmerged]
|
||||||
diffResult,
|
|
||||||
diffFilter: 'U',
|
|
||||||
filePatterns,
|
|
||||||
submodulePaths
|
|
||||||
})
|
})
|
||||||
core.debug(`Unmerged files: ${unmergedFiles}`)
|
core.debug(`Unmerged files: ${unmergedFiles}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
@@ -202,14 +203,10 @@ export async function run(): Promise<void> {
|
|||||||
inputs
|
inputs
|
||||||
})
|
})
|
||||||
|
|
||||||
const unknownFiles = await getDiffFiles({
|
const unknownFiles = await getChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [ChangeTypeEnum.Unknown]
|
||||||
diffResult,
|
|
||||||
diffFilter: 'X',
|
|
||||||
filePatterns,
|
|
||||||
submodulePaths
|
|
||||||
})
|
})
|
||||||
core.debug(`Unknown files: ${unknownFiles}`)
|
core.debug(`Unknown files: ${unknownFiles}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
@@ -218,14 +215,9 @@ export async function run(): Promise<void> {
|
|||||||
inputs
|
inputs
|
||||||
})
|
})
|
||||||
|
|
||||||
const allChangedAndModifiedFiles = await getDiffFiles({
|
const allChangedAndModifiedFiles = await getAllChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles
|
||||||
hasSubmodule,
|
|
||||||
diffResult,
|
|
||||||
diffFilter: 'ACDMRTUX',
|
|
||||||
filePatterns,
|
|
||||||
submodulePaths
|
|
||||||
})
|
})
|
||||||
core.debug(`All changed and modified files: ${allChangedAndModifiedFiles}`)
|
core.debug(`All changed and modified files: ${allChangedAndModifiedFiles}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
@@ -234,14 +226,15 @@ export async function run(): Promise<void> {
|
|||||||
inputs
|
inputs
|
||||||
})
|
})
|
||||||
|
|
||||||
const allChangedFiles = await getDiffFiles({
|
const allChangedFiles = await getChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [
|
||||||
diffResult,
|
ChangeTypeEnum.Added,
|
||||||
diffFilter: 'ACMR',
|
ChangeTypeEnum.Copied,
|
||||||
filePatterns,
|
ChangeTypeEnum.Modified,
|
||||||
submodulePaths
|
ChangeTypeEnum.Renamed
|
||||||
|
]
|
||||||
})
|
})
|
||||||
core.debug(`All changed files: ${allChangedFiles}`)
|
core.debug(`All changed files: ${allChangedFiles}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
@@ -256,20 +249,23 @@ export async function run(): Promise<void> {
|
|||||||
inputs
|
inputs
|
||||||
})
|
})
|
||||||
|
|
||||||
const allOtherChangedFiles = await getDiffFiles({
|
const allOtherChangedFiles = await getChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [
|
||||||
diffResult,
|
ChangeTypeEnum.Added,
|
||||||
diffFilter: 'ACMR',
|
ChangeTypeEnum.Copied,
|
||||||
submodulePaths
|
ChangeTypeEnum.Modified,
|
||||||
|
ChangeTypeEnum.Renamed
|
||||||
|
]
|
||||||
})
|
})
|
||||||
core.debug(`All other changed files: ${allOtherChangedFiles}`)
|
core.debug(`All other changed files: ${allOtherChangedFiles}`)
|
||||||
|
|
||||||
const otherChangedFiles = allOtherChangedFiles
|
const otherChangedFiles = allOtherChangedFiles
|
||||||
.split(inputs.separator)
|
.split(inputs.separator)
|
||||||
.filter(
|
.filter(
|
||||||
filePath => !allChangedFiles.split(inputs.separator).includes(filePath)
|
(filePath: string) =>
|
||||||
|
!allChangedFiles.split(inputs.separator).includes(filePath)
|
||||||
)
|
)
|
||||||
|
|
||||||
const onlyChanged =
|
const onlyChanged =
|
||||||
@@ -289,14 +285,16 @@ export async function run(): Promise<void> {
|
|||||||
inputs
|
inputs
|
||||||
})
|
})
|
||||||
|
|
||||||
const allModifiedFiles = await getDiffFiles({
|
const allModifiedFiles = await getChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [
|
||||||
diffResult,
|
ChangeTypeEnum.Added,
|
||||||
diffFilter: 'ACMRD',
|
ChangeTypeEnum.Copied,
|
||||||
filePatterns,
|
ChangeTypeEnum.Modified,
|
||||||
submodulePaths
|
ChangeTypeEnum.Renamed,
|
||||||
|
ChangeTypeEnum.Deleted
|
||||||
|
]
|
||||||
})
|
})
|
||||||
core.debug(`All modified files: ${allModifiedFiles}`)
|
core.debug(`All modified files: ${allModifiedFiles}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
@@ -311,19 +309,23 @@ export async function run(): Promise<void> {
|
|||||||
inputs
|
inputs
|
||||||
})
|
})
|
||||||
|
|
||||||
const allOtherModifiedFiles = await getDiffFiles({
|
const allOtherModifiedFiles = await getChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [
|
||||||
diffResult,
|
ChangeTypeEnum.Added,
|
||||||
diffFilter: 'ACMRD',
|
ChangeTypeEnum.Copied,
|
||||||
submodulePaths
|
ChangeTypeEnum.Modified,
|
||||||
|
ChangeTypeEnum.Renamed,
|
||||||
|
ChangeTypeEnum.Deleted
|
||||||
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
const otherModifiedFiles = allOtherModifiedFiles
|
const otherModifiedFiles = allOtherModifiedFiles
|
||||||
.split(inputs.separator)
|
.split(inputs.separator)
|
||||||
.filter(
|
.filter(
|
||||||
filePath => !allModifiedFiles.split(inputs.separator).includes(filePath)
|
(filePath: string) =>
|
||||||
|
!allModifiedFiles.split(inputs.separator).includes(filePath)
|
||||||
)
|
)
|
||||||
|
|
||||||
const onlyModified =
|
const onlyModified =
|
||||||
@@ -343,14 +345,10 @@ export async function run(): Promise<void> {
|
|||||||
inputs
|
inputs
|
||||||
})
|
})
|
||||||
|
|
||||||
const deletedFiles = await getDiffFiles({
|
const deletedFiles = await getChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [ChangeTypeEnum.Deleted]
|
||||||
diffResult,
|
|
||||||
diffFilter: 'D',
|
|
||||||
filePatterns,
|
|
||||||
submodulePaths
|
|
||||||
})
|
})
|
||||||
core.debug(`Deleted files: ${deletedFiles}`)
|
core.debug(`Deleted files: ${deletedFiles}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
@@ -365,13 +363,10 @@ export async function run(): Promise<void> {
|
|||||||
inputs
|
inputs
|
||||||
})
|
})
|
||||||
|
|
||||||
const allOtherDeletedFiles = await getDiffFiles({
|
const allOtherDeletedFiles = await getChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [ChangeTypeEnum.Deleted]
|
||||||
diffResult,
|
|
||||||
diffFilter: 'D',
|
|
||||||
submodulePaths
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const otherDeletedFiles = allOtherDeletedFiles
|
const otherDeletedFiles = allOtherDeletedFiles
|
||||||
|
|||||||
99
src/utils.ts
99
src/utils.ts
@@ -5,6 +5,7 @@ import {createReadStream, promises as fs} from 'fs'
|
|||||||
import mm from 'micromatch'
|
import mm from 'micromatch'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import {createInterface} from 'readline'
|
import {createInterface} from 'readline'
|
||||||
|
import {ChangedFiles, ChangeTypeEnum} from './changedFiles'
|
||||||
|
|
||||||
import {Inputs} from './inputs'
|
import {Inputs} from './inputs'
|
||||||
|
|
||||||
@@ -403,32 +404,30 @@ export const gitRenamedFiles = async ({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const gitDiff = async ({
|
export const getAllChangedFiles = async ({
|
||||||
cwd,
|
cwd,
|
||||||
sha1,
|
sha1,
|
||||||
sha2,
|
sha2,
|
||||||
diff,
|
diff,
|
||||||
diffFilter,
|
|
||||||
filePatterns = [],
|
|
||||||
isSubmodule = false,
|
isSubmodule = false,
|
||||||
parentDir = ''
|
parentDir = '',
|
||||||
|
outputRenamedFilesAsDeletedAndAdded = false
|
||||||
}: {
|
}: {
|
||||||
cwd: string
|
cwd: string
|
||||||
sha1: string
|
sha1: string
|
||||||
sha2: string
|
sha2: string
|
||||||
diffFilter: string
|
|
||||||
diff: string
|
diff: string
|
||||||
filePatterns?: string[]
|
|
||||||
isSubmodule?: boolean
|
isSubmodule?: boolean
|
||||||
parentDir?: string
|
parentDir?: string
|
||||||
}): Promise<string[]> => {
|
outputRenamedFilesAsDeletedAndAdded?: boolean
|
||||||
|
}): Promise<ChangedFiles> => {
|
||||||
const {exitCode, stdout, stderr} = await exec.getExecOutput(
|
const {exitCode, stdout, stderr} = await exec.getExecOutput(
|
||||||
'git',
|
'git',
|
||||||
[
|
[
|
||||||
'diff',
|
'diff',
|
||||||
'--name-only',
|
'--name-status',
|
||||||
'--ignore-submodules=all',
|
'--ignore-submodules=all',
|
||||||
`--diff-filter=${diffFilter}`,
|
`--diff-filter=ACDMRTUX`,
|
||||||
`${sha1}${diff}${sha2}`
|
`${sha1}${diff}${sha2}`
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
@@ -437,6 +436,16 @@ export const gitDiff = async ({
|
|||||||
silent: process.env.RUNNER_DEBUG !== '1'
|
silent: process.env.RUNNER_DEBUG !== '1'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
const changedFiles: ChangedFiles = {
|
||||||
|
[ChangeTypeEnum.Added]: [],
|
||||||
|
[ChangeTypeEnum.Copied]: [],
|
||||||
|
[ChangeTypeEnum.Deleted]: [],
|
||||||
|
[ChangeTypeEnum.Modified]: [],
|
||||||
|
[ChangeTypeEnum.Renamed]: [],
|
||||||
|
[ChangeTypeEnum.TypeChanged]: [],
|
||||||
|
[ChangeTypeEnum.Unmerged]: [],
|
||||||
|
[ChangeTypeEnum.Unknown]: []
|
||||||
|
}
|
||||||
|
|
||||||
if (exitCode !== 0) {
|
if (exitCode !== 0) {
|
||||||
if (isSubmodule) {
|
if (isSubmodule) {
|
||||||
@@ -453,28 +462,68 @@ export const gitDiff = async ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return []
|
return changedFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
const files = stdout
|
const lines = stdout.split('\n').filter(Boolean)
|
||||||
.split('\n')
|
|
||||||
.filter(Boolean)
|
for (const line of lines) {
|
||||||
.map((p: string) => {
|
const [changeType, filePath, newPath = ''] = line.split('\t')
|
||||||
if (isSubmodule) {
|
const normalizedFilePath = isSubmodule
|
||||||
return normalizePath(path.join(parentDir, p))
|
? normalizePath(path.join(parentDir, filePath))
|
||||||
|
: normalizePath(filePath)
|
||||||
|
const normalizedNewPath = isSubmodule
|
||||||
|
? normalizePath(path.join(parentDir, newPath))
|
||||||
|
: normalizePath(newPath)
|
||||||
|
|
||||||
|
if (changeType.startsWith('R')) {
|
||||||
|
if (outputRenamedFilesAsDeletedAndAdded) {
|
||||||
|
changedFiles[ChangeTypeEnum.Deleted].push(normalizedFilePath)
|
||||||
|
changedFiles[ChangeTypeEnum.Added].push(normalizedNewPath)
|
||||||
|
} else {
|
||||||
|
changedFiles[ChangeTypeEnum.Renamed].push(normalizedFilePath)
|
||||||
}
|
}
|
||||||
return normalizePath(p)
|
} else {
|
||||||
})
|
changedFiles[changeType as ChangeTypeEnum].push(normalizedFilePath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return changedFiles
|
||||||
|
}
|
||||||
|
|
||||||
if (filePatterns.length === 0) {
|
export const getFilteredChangedFiles = async ({
|
||||||
return files
|
allDiffFiles,
|
||||||
|
filePatterns
|
||||||
|
}: {
|
||||||
|
allDiffFiles: ChangedFiles
|
||||||
|
filePatterns: string[]
|
||||||
|
}): Promise<ChangedFiles> => {
|
||||||
|
const changedFiles: ChangedFiles = {
|
||||||
|
[ChangeTypeEnum.Added]: [],
|
||||||
|
[ChangeTypeEnum.Copied]: [],
|
||||||
|
[ChangeTypeEnum.Deleted]: [],
|
||||||
|
[ChangeTypeEnum.Modified]: [],
|
||||||
|
[ChangeTypeEnum.Renamed]: [],
|
||||||
|
[ChangeTypeEnum.TypeChanged]: [],
|
||||||
|
[ChangeTypeEnum.Unmerged]: [],
|
||||||
|
[ChangeTypeEnum.Unknown]: []
|
||||||
}
|
}
|
||||||
|
|
||||||
return mm(files, filePatterns, {
|
for (const changeType of Object.keys(allDiffFiles)) {
|
||||||
dot: true,
|
const files = allDiffFiles[changeType as ChangeTypeEnum]
|
||||||
windows: IS_WINDOWS,
|
const hasFilePatterns = filePatterns.length > 0
|
||||||
noext: true
|
|
||||||
})
|
if (hasFilePatterns) {
|
||||||
|
changedFiles[changeType as ChangeTypeEnum] = mm(files, filePatterns, {
|
||||||
|
dot: true,
|
||||||
|
windows: IS_WINDOWS,
|
||||||
|
noext: true
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
changedFiles[changeType as ChangeTypeEnum] = files
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return changedFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
export const gitLog = async ({
|
export const gitLog = async ({
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
This is a test file with non ascii character in the filename.
|
This is a test file with non ASCII character in the filename.
|
||||||
|
|||||||
Reference in New Issue
Block a user