Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1754a427f | ||
|
|
f573054697 | ||
|
|
c3c3db7fee | ||
|
|
480e87dd66 | ||
|
|
7fcd53ac00 | ||
|
|
749fe3bb28 | ||
|
|
d7af20bab3 | ||
|
|
690b721958 | ||
|
|
77f9e6c7c6 | ||
|
|
c82a34e7e5 | ||
|
|
7a1c64e8b1 | ||
|
|
71290f02ff | ||
|
|
ecf455a884 | ||
|
|
432e0c810c | ||
|
|
fcdeb5b3d7 | ||
|
|
01e83d6024 | ||
|
|
c706c70eed | ||
|
|
d4f86e9d16 | ||
|
|
d9105a4631 | ||
|
|
0621d936c0 | ||
|
|
024cd58ac6 | ||
|
|
c9a1c56f6d | ||
|
|
54a8c99a03 |
149
.github/workflows/test.yml
vendored
149
.github/workflows/test.yml
vendored
@@ -601,6 +601,155 @@ jobs:
|
||||
shell:
|
||||
bash
|
||||
|
||||
test_recover_deleted_file:
|
||||
name: Test changed-files recover deleted file
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
strategy:
|
||||
fail-fast: false
|
||||
max-parallel: 4
|
||||
matrix:
|
||||
fetch-depth: [0, 1, 2]
|
||||
|
||||
steps:
|
||||
- name: Checkout branch
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha || github.sha }}
|
||||
submodules: recursive
|
||||
fetch-depth: ${{ matrix.fetch-depth }}
|
||||
|
||||
- name: Download build assets
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: build-assets
|
||||
|
||||
- name: Run changed-files with recover_deleted_files
|
||||
id: changed-files-recover-deleted-files
|
||||
uses: ./
|
||||
with:
|
||||
base_sha: "fcdeb5b3d797752d95f6dbe98552a95c29dad338"
|
||||
sha: "432e0c810c60ef1332850a971c5ec39022034b4c"
|
||||
recover_deleted_files: true
|
||||
|
||||
- name: Show output
|
||||
run: |
|
||||
echo "${{ toJSON(steps.changed-files-recover-deleted-files.outputs) }}"
|
||||
shell:
|
||||
bash
|
||||
|
||||
- name: Verify deleted files
|
||||
if: steps.changed-files-recover-deleted-files.outputs.deleted_files != 'test/test deleted.txt'
|
||||
run: |
|
||||
echo "Expected: (test/test deleted.txt) got ${{ steps.changed-files-recover-deleted-files.outputs.deleted_files }}"
|
||||
exit 1
|
||||
|
||||
- name: Verify that test/test deleted.txt is restored
|
||||
run: |
|
||||
if [ ! -f "test/test deleted.txt" ]; then
|
||||
echo "Expected: (test/test deleted.txt) to exist"
|
||||
exit 1
|
||||
else
|
||||
cat "test/test deleted.txt"
|
||||
rm "test/test deleted.txt"
|
||||
fi
|
||||
|
||||
- name: Run changed-files with recover_deleted_files and files input
|
||||
id: changed-files-recover-deleted-files-with-files
|
||||
uses: ./
|
||||
with:
|
||||
base_sha: "fcdeb5b3d797752d95f6dbe98552a95c29dad338"
|
||||
sha: "432e0c810c60ef1332850a971c5ec39022034b4c"
|
||||
files: |
|
||||
test
|
||||
recover_deleted_files: true
|
||||
|
||||
- name: Show output
|
||||
run: |
|
||||
echo "${{ toJSON(steps.changed-files-recover-deleted-files-with-files.outputs) }}"
|
||||
shell:
|
||||
bash
|
||||
|
||||
- name: Verify deleted files
|
||||
if: steps.changed-files-recover-deleted-files-with-files.outputs.deleted_files != 'test/test deleted.txt'
|
||||
run: |
|
||||
echo "Expected: (test/test deleted.txt) got ${{ steps.changed-files-recover-deleted-files-with-files.outputs.deleted_files }}"
|
||||
exit 1
|
||||
|
||||
- name: Verify that test/test deleted.txt is restored
|
||||
run: |
|
||||
if [ ! -f "test/test deleted.txt" ]; then
|
||||
echo "Expected: (test/test deleted.txt) to exist"
|
||||
exit 1
|
||||
else
|
||||
cat "test/test deleted.txt"
|
||||
rm "test/test deleted.txt"
|
||||
fi
|
||||
|
||||
- name: Run changed-files with recover_deleted_files and files_yaml input
|
||||
id: changed-files-recover-deleted-files-with-files-yaml
|
||||
uses: ./
|
||||
with:
|
||||
base_sha: "fcdeb5b3d797752d95f6dbe98552a95c29dad338"
|
||||
sha: "432e0c810c60ef1332850a971c5ec39022034b4c"
|
||||
files_yaml: |
|
||||
test:
|
||||
- test/**.txt
|
||||
- test/**.md
|
||||
recover_deleted_files: true
|
||||
|
||||
- name: Show output
|
||||
run: |
|
||||
echo "${{ toJSON(steps.changed-files-recover-deleted-files-with-files-yaml.outputs) }}"
|
||||
shell:
|
||||
bash
|
||||
|
||||
- name: Verify deleted files
|
||||
if: steps.changed-files-recover-deleted-files-with-files-yaml.outputs.test_deleted_files != 'test/test deleted.txt'
|
||||
run: |
|
||||
echo "Expected: (test/test deleted.txt) got ${{ steps.changed-files-recover-deleted-files-with-files-yaml.outputs.test_deleted_files }}"
|
||||
exit 1
|
||||
|
||||
- name: Verify that test/test deleted.txt is restored
|
||||
run: |
|
||||
if [ ! -f "test/test deleted.txt" ]; then
|
||||
echo "Expected: (test/test deleted.txt) to exist"
|
||||
exit 1
|
||||
else
|
||||
cat "test/test deleted.txt"
|
||||
rm "test/test deleted.txt"
|
||||
fi
|
||||
|
||||
- name: Run changed-files with recover_deleted_files and recover_deleted_files_to_destination
|
||||
id: changed-files-recover-deleted-files-to-destination
|
||||
uses: ./
|
||||
with:
|
||||
base_sha: "fcdeb5b3d797752d95f6dbe98552a95c29dad338"
|
||||
sha: "432e0c810c60ef1332850a971c5ec39022034b4c"
|
||||
recover_deleted_files: true
|
||||
recover_deleted_files_to_destination: "deleted_files"
|
||||
|
||||
- name: Show output
|
||||
run: |
|
||||
echo "${{ toJSON(steps.changed-files-recover-deleted-files-to-destination.outputs) }}"
|
||||
shell:
|
||||
bash
|
||||
|
||||
- name: Verify deleted files
|
||||
if: steps.changed-files-recover-deleted-files-to-destination.outputs.deleted_files != 'test/test deleted.txt'
|
||||
run: |
|
||||
echo "Expected: (test/test deleted.txt) got ${{ steps.changed-files-recover-deleted-files-to-destination.outputs.deleted_files }}"
|
||||
exit 1
|
||||
|
||||
- name: Verify that test/test deleted.txt is restored
|
||||
run: |
|
||||
if [ ! -f "deleted_files/test/test deleted.txt" ]; then
|
||||
echo "Expected: (deleted_files/test/test deleted.txt) to exist"
|
||||
exit 1
|
||||
else
|
||||
cat "deleted_files/test/test deleted.txt"
|
||||
fi
|
||||
|
||||
test:
|
||||
name: Test changed-files
|
||||
runs-on: ${{ matrix.platform }}
|
||||
|
||||
29
HISTORY.md
29
HISTORY.md
@@ -1,5 +1,34 @@
|
||||
# Changelog
|
||||
|
||||
# [36.3.0](https://github.com/tj-actions/changed-files/compare/v36.2.1...v36.3.0) - (2023-06-16)
|
||||
|
||||
## <!-- 0 -->🚀 Features
|
||||
|
||||
- Add support for complex filters ([#1265](https://github.com/tj-actions/changed-files/issues/1265)) ([c25c77a](https://github.com/tj-actions/changed-files/commit/c25c77a67a4da177bd7550612cacb74714d054f6)) - (Tonye Jack)
|
||||
|
||||
## <!-- 26 -->🔄 Update
|
||||
|
||||
- Updated README.md ([#1266](https://github.com/tj-actions/changed-files/issues/1266))
|
||||
|
||||
Co-authored-by: repo-ranger[bot] <repo-ranger[bot]@users.noreply.github.com> ([9bf0914](https://github.com/tj-actions/changed-files/commit/9bf09145c3560e451e8d8e87b42ccb3fef5b692d)) - (tj-actions[bot])
|
||||
- Updated README.md ([#1264](https://github.com/tj-actions/changed-files/issues/1264))
|
||||
|
||||
Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
|
||||
Co-authored-by: GitHub Action <action@github.com> ([d144c0c](https://github.com/tj-actions/changed-files/commit/d144c0c92d678494b332227c803cea83b4f7bdee)) - (tj-actions[bot])
|
||||
- Update README.md ([341b80d](https://github.com/tj-actions/changed-files/commit/341b80da8b4d69e7a389dc6f2df8c8ee41ea5736)) - (Tonye Jack)
|
||||
|
||||
## <!-- 7 -->⚙️ Miscellaneous Tasks
|
||||
|
||||
- Update test.yml ([ea90b5c](https://github.com/tj-actions/changed-files/commit/ea90b5ced9a0c8d0d18077656d2ecada2bb67ff3)) - (Tonye Jack)
|
||||
- Move check out of loop ([6cf9c82](https://github.com/tj-actions/changed-files/commit/6cf9c8246e3225cbcdc00d6c86ba6d6a05b2e231)) - (Tonye Jack)
|
||||
- **deps:** Lock file maintenance ([#1263](https://github.com/tj-actions/changed-files/issues/1263)) ([9559461](https://github.com/tj-actions/changed-files/commit/955946132d0133d584404b86a03462e591ff30b3)) - (renovate[bot])
|
||||
|
||||
## <!-- 9 -->⬆️ Upgrades
|
||||
|
||||
- Upgraded to v36.2.1 ([#1262](https://github.com/tj-actions/changed-files/issues/1262))
|
||||
|
||||
Co-authored-by: jackton1 <jackton1@users.noreply.github.com> ([1f2cb3b](https://github.com/tj-actions/changed-files/commit/1f2cb3b00f32f8700ede1b03398337e39a64d448)) - (tj-actions[bot])
|
||||
|
||||
# [36.2.1](https://github.com/tj-actions/changed-files/compare/v36.2.0...v36.2.1) - (2023-06-14)
|
||||
|
||||
## <!-- 0 -->🚀 Features
|
||||
|
||||
112
README.md
112
README.md
@@ -19,7 +19,7 @@
|
||||
|
||||
## changed-files
|
||||
|
||||
Retrieve all changed files and directories relative to a target branch, preceding commit or the last remote commit returning **relative paths** from the project root.
|
||||
Effortlessly track all changed files and directories relative to a target branch, preceding commit or the last remote commit returning **relative paths** from the project root.
|
||||
|
||||
## Table of contents
|
||||
|
||||
@@ -39,34 +39,37 @@ Retrieve all changed files and directories relative to a target branch, precedin
|
||||
|
||||
## Features
|
||||
|
||||
* Fast execution (0-10 seconds on average).
|
||||
* Easy to debug.
|
||||
* Scales to large repositories.
|
||||
* Provides fast execution, averaging 0-10 seconds.
|
||||
* Facilitates easy debugging.
|
||||
* Scales to handle large repositories.
|
||||
* Supports Git submodules.
|
||||
* Escaped JSON output which can be used to run matrix jobs based on changed files.
|
||||
* List changed directories.
|
||||
* Limit the matching changed directories to a maximum depth.
|
||||
* Optionally exclude the current directory
|
||||
* Write outputs to a `.txt` or `.json` file at a specified location for further processing.
|
||||
* Monorepos (Fetches a fixed number of commits).
|
||||
* Supports all platforms (Linux, MacOS, Windows).
|
||||
* [GitHub-hosted runners](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners) support
|
||||
* [GitHub Enterprise Server](https://docs.github.com/en/enterprise-server@3.3/admin/github-actions/getting-started-with-github-actions-for-your-enterprise/getting-started-with-github-actions-for-github-enterprise-server) support.
|
||||
* [self-hosted runners](https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners) support.
|
||||
* List all files and directories that have changed:
|
||||
* Generates escaped JSON output for running matrix jobs based on changed files.
|
||||
* Lists changed directories.
|
||||
* Allows limiting the matching changed directories to a specified maximum depth.
|
||||
* Optionally excludes the current directory.
|
||||
* Writes outputs to a designated `.txt` or `.json` file for further processing.
|
||||
* Restores deleted files to their previous location or a newly specified location.
|
||||
* Supports Monorepos by fetching a fixed number of commits.
|
||||
* Compatible with all platforms (Linux, MacOS, Windows).
|
||||
* Supports [GitHub-hosted runners](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners).
|
||||
* Supports [GitHub Enterprise Server](https://docs.github.com/en/enterprise-server@3.3/admin/github-actions/getting-started-with-github-actions-for-your-enterprise/getting-started-with-github-actions-for-github-enterprise-server).
|
||||
* Supports [self-hosted runners](https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners).
|
||||
* Lists all files and directories that have changed:
|
||||
* Between the current pull request branch and the last commit on the target branch.
|
||||
* Between the last commit and the current pushed change.
|
||||
* Between the last remote branch commit and the current HEAD.
|
||||
* Restrict change detection to a subset of files and directories:
|
||||
* Boolean output indicating that certain files have been changed.
|
||||
* Using [Glob pattern](https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet) matching.
|
||||
* Globstar.
|
||||
* Brace expansion.
|
||||
* Negation.
|
||||
* Using [YAML](https://yaml.org/) syntax for specifying the patterns for files and directories.
|
||||
* Restricts change detection to a subset of files and directories:
|
||||
* Provides boolean output indicating changes in specific files.
|
||||
* Uses [Glob pattern](https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet) matching.
|
||||
* Supports Globstar.
|
||||
* Supports brace expansion.
|
||||
* Supports negation.
|
||||
* Uses [YAML](https://yaml.org/) syntax for specifying patterns.
|
||||
* Supports [YAML anchors & aliases](https://www.educative.io/blog/advanced-yaml-syntax-cheatsheet#anchors).
|
||||
* Supports [YAML multi-line strings](https://learnxinyminutes.com/docs/yaml/).
|
||||
|
||||
And many more.
|
||||
|
||||
## Usage
|
||||
|
||||
> **Warning**:
|
||||
@@ -147,7 +150,7 @@ jobs:
|
||||
echo "List all the files that have changed: ${{ steps.changed-files-excluded.outputs.all_changed_files }}"
|
||||
|
||||
# Example 4
|
||||
- name: Get all test files, doc and src files that have changed
|
||||
- name: Get all test, doc and src files that have changed
|
||||
id: changed-files-yml
|
||||
uses: tj-actions/changed-files@v36
|
||||
with:
|
||||
@@ -205,29 +208,44 @@ Support this project with a :star:
|
||||
|
||||
<!-- AUTO-DOC-OUTPUT:START - Do not remove or modify this section -->
|
||||
|
||||
| OUTPUT | TYPE | DESCRIPTION |
|
||||
|--------------------------------|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| 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\_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\_old\_new\_renamed\_files | string | Returns only files that are <br>Renamed and lists their old <br>and new names. **NOTE:** This <br>requires setting `include_all_old_new_renamed_files` to `true`. <br>Also, keep in mind that <br>this output is global and <br>wouldn't be nested in outputs <br>generated when the `*_yaml_*` input <br>is used. (R) |
|
||||
| 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*` 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*` 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). |
|
||||
| deleted\_files | string | Returns only files that are <br>Deleted (D). |
|
||||
| modified\_files | string | Returns only files that are <br>Modified (M). |
|
||||
| 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*` or `files_ignore*` inputs <br>has been deleted. (D) |
|
||||
| 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\_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)* |
|
||||
| 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). |
|
||||
| unknown\_files | string | Returns only files that are <br>Unknown (X). |
|
||||
| unmerged\_files | string | Returns only files that are <br>Unmerged (U). |
|
||||
| OUTPUT | TYPE | DESCRIPTION |
|
||||
|--------------------------------------|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| added\_files | string | Returns only files that are <br>Added (A). |
|
||||
| added\_files\_count | string | Returns the number of `added_files` |
|
||||
| all\_changed\_and\_modified\_files | string | Returns all changed and modified <br>files i.e. *a combination of (ACMRDTUX)* |
|
||||
| all\_changed\_and\_modified\_files\_count | string | Returns the number of `all_changed_and_modified_files` |
|
||||
| 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\_count | string | Returns the number of `all_changed_files` |
|
||||
| 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\_count | string | Returns the number of `all_modified_files` |
|
||||
| all\_old\_new\_renamed\_files | string | Returns only files that are <br>Renamed and lists their old <br>and new names. **NOTE:** This <br>requires setting `include_all_old_new_renamed_files` to `true`. <br>Also, keep in mind that <br>this output is global and <br>wouldn't be nested in outputs <br>generated when the `*_yaml_*` input <br>is used. (R) |
|
||||
| all\_old\_new\_renamed\_files\_count | string | Returns the number of `all_old_new_renamed_files` |
|
||||
| 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*` 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*` 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\_count | string | Returns the number of `copied_files` |
|
||||
| deleted\_files | string | Returns only files that are <br>Deleted (D). |
|
||||
| deleted\_files\_count | string | Returns the number of `deleted_files` |
|
||||
| modified\_files | string | Returns only files that are <br>Modified (M). |
|
||||
| modified\_files\_count | string | Returns the number of `modified_files` |
|
||||
| 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*` or `files_ignore*` inputs <br>has been deleted. (D) |
|
||||
| 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\_count | string | Returns the number of `other_changed_files` |
|
||||
| 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\_count | string | Returns the number of `other_deleted_files` |
|
||||
| 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\_count | string | Returns the number of `other_modified_files` |
|
||||
| renamed\_files | string | Returns only files that are <br>Renamed (R). |
|
||||
| renamed\_files\_count | string | Returns the number of `renamed_files` |
|
||||
| type\_changed\_files | string | Returns only files that have <br>their file type changed (T). |
|
||||
| type\_changed\_files\_count | string | Returns the number of `type_changed_files` |
|
||||
| unknown\_files | string | Returns only files that are <br>Unknown (X). |
|
||||
| unknown\_files\_count | string | Returns the number of `unknown_files` |
|
||||
| unmerged\_files | string | Returns only files that are <br>Unmerged (U). |
|
||||
| unmerged\_files\_count | string | Returns the number of `unmerged_files` |
|
||||
|
||||
<!-- AUTO-DOC-OUTPUT:END -->
|
||||
|
||||
@@ -267,6 +285,8 @@ Support this project with a :star:
|
||||
| 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. |
|
||||
| quotepath | string | false | `"true"` | Use non-ascii characters to match <br>files and output the filenames <br>completely verbatim by setting this <br>to `false` |
|
||||
| recover\_deleted\_files | string | false | `"false"` | Recover deleted files. |
|
||||
| recover\_deleted\_files\_to\_destination | string | false | | Recover deleted files to a <br>new destination directory, defaults to <br>the original location. |
|
||||
| separator | string | false | `" "` | Split character for output strings |
|
||||
| sha | string | false | | Specify a different commit SHA <br>used for comparing changes |
|
||||
| since | string | false | | Get changed files for commits <br>whose timestamp is older than <br>the given time. |
|
||||
|
||||
38
action.yml
38
action.yml
@@ -145,50 +145,88 @@ inputs:
|
||||
description: "Output renamed files as deleted and added files."
|
||||
required: false
|
||||
default: "false"
|
||||
recover_deleted_files:
|
||||
description: "Recover deleted files."
|
||||
required: false
|
||||
default: "false"
|
||||
recover_deleted_files_to_destination:
|
||||
description: "Recover deleted files to a new destination directory, defaults to the original location."
|
||||
required: false
|
||||
default: ""
|
||||
|
||||
outputs:
|
||||
added_files:
|
||||
description: "Returns only files that are Added (A)."
|
||||
added_files_count:
|
||||
description: "Returns the number of `added_files`"
|
||||
copied_files:
|
||||
description: "Returns only files that are Copied (C)."
|
||||
copied_files_count:
|
||||
description: "Returns the number of `copied_files`"
|
||||
deleted_files:
|
||||
description: "Returns only files that are Deleted (D)."
|
||||
deleted_files_count:
|
||||
description: "Returns the number of `deleted_files`"
|
||||
modified_files:
|
||||
description: "Returns only files that are Modified (M)."
|
||||
modified_files_count:
|
||||
description: "Returns the number of `modified_files`"
|
||||
renamed_files:
|
||||
description: "Returns only files that are Renamed (R)."
|
||||
renamed_files_count:
|
||||
description: "Returns the number of `renamed_files`"
|
||||
all_old_new_renamed_files:
|
||||
description: "Returns only files that are Renamed and lists their old and new names. **NOTE:** This requires setting `include_all_old_new_renamed_files` to `true`. Also, keep in mind that this output is global and wouldn't be nested in outputs generated when the `*_yaml_*` input is used. (R)"
|
||||
all_old_new_renamed_files_count:
|
||||
description: "Returns the number of `all_old_new_renamed_files`"
|
||||
type_changed_files:
|
||||
description: "Returns only files that have their file type changed (T)."
|
||||
type_changed_files_count:
|
||||
description: "Returns the number of `type_changed_files`"
|
||||
unmerged_files:
|
||||
description: "Returns only files that are Unmerged (U)."
|
||||
unmerged_files_count:
|
||||
description: "Returns the number of `unmerged_files`"
|
||||
unknown_files:
|
||||
description: "Returns only files that are Unknown (X)."
|
||||
unknown_files_count:
|
||||
description: "Returns the number of `unknown_files`"
|
||||
all_changed_and_modified_files:
|
||||
description: "Returns all changed and modified files i.e. *a combination of (ACMRDTUX)*"
|
||||
all_changed_and_modified_files_count:
|
||||
description: "Returns the number of `all_changed_and_modified_files`"
|
||||
all_changed_files:
|
||||
description: "Returns all changed files i.e. *a combination of all added, copied, modified and renamed files (ACMR)*"
|
||||
all_changed_files_count:
|
||||
description: "Returns the number of `all_changed_files`"
|
||||
any_changed:
|
||||
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:
|
||||
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:
|
||||
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)*."
|
||||
other_changed_files_count:
|
||||
description: "Returns the number of `other_changed_files`"
|
||||
all_modified_files:
|
||||
description: "Returns all changed files i.e. *a combination of all added, copied, modified, renamed and deleted files (ACMRD)*."
|
||||
all_modified_files_count:
|
||||
description: "Returns the number of `all_modified_files`"
|
||||
any_modified:
|
||||
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:
|
||||
description: "Returns `true` when only files provided using the `files*` or `files_ignore*` inputs has been modified. (ACMRD)."
|
||||
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)*"
|
||||
other_modified_files_count:
|
||||
description: "Returns the number of `other_modified_files`"
|
||||
any_deleted:
|
||||
description: "Returns `true` when any of the filenames provided using the `files*` or `files_ignore*` inputs has been deleted. (D)"
|
||||
only_deleted:
|
||||
description: "Returns `true` when only files provided using the `files*` or `files_ignore*` inputs has been deleted. (D)"
|
||||
other_deleted_files:
|
||||
description: "Returns all other deleted files not listed in the files input i.e. *a combination of all deleted files (D)*"
|
||||
other_deleted_files_count:
|
||||
description: "Returns the number of `other_deleted_files`"
|
||||
|
||||
runs:
|
||||
using: 'node16'
|
||||
|
||||
214
dist/index.js
generated
vendored
214
dist/index.js
generated
vendored
@@ -79,9 +79,15 @@ const getRenamedFiles = ({ inputs, workingDirectory, hasSubmodule, diffResult, s
|
||||
}
|
||||
}
|
||||
if (inputs.json) {
|
||||
return (0, utils_1.jsonOutput)({ value: renamedFiles, shouldEscape: inputs.escapeJson });
|
||||
return {
|
||||
paths: (0, utils_1.jsonOutput)({ value: renamedFiles, shouldEscape: inputs.escapeJson }),
|
||||
count: renamedFiles.length.toString()
|
||||
};
|
||||
}
|
||||
return renamedFiles.join(inputs.oldNewFilesSeparator);
|
||||
return {
|
||||
paths: renamedFiles.join(inputs.oldNewFilesSeparator),
|
||||
count: renamedFiles.length.toString()
|
||||
};
|
||||
});
|
||||
exports.getRenamedFiles = getRenamedFiles;
|
||||
var ChangeTypeEnum;
|
||||
@@ -157,9 +163,15 @@ const getChangeTypeFiles = ({ inputs, changedFiles, changeTypes }) => __awaiter(
|
||||
...new Set(getChangeTypeFilesGenerator({ inputs, changedFiles, changeTypes }))
|
||||
];
|
||||
if (inputs.json) {
|
||||
return (0, utils_1.jsonOutput)({ value: files, shouldEscape: inputs.escapeJson });
|
||||
return {
|
||||
paths: (0, utils_1.jsonOutput)({ value: files, shouldEscape: inputs.escapeJson }),
|
||||
count: files.length.toString()
|
||||
};
|
||||
}
|
||||
return files.join(inputs.separator);
|
||||
return {
|
||||
paths: files.join(inputs.separator),
|
||||
count: files.length.toString()
|
||||
};
|
||||
});
|
||||
exports.getChangeTypeFiles = getChangeTypeFiles;
|
||||
function* getAllChangeTypeFilesGenerator({ inputs, changedFiles }) {
|
||||
@@ -181,9 +193,15 @@ const getAllChangeTypeFiles = ({ inputs, changedFiles }) => __awaiter(void 0, vo
|
||||
...new Set(getAllChangeTypeFilesGenerator({ inputs, changedFiles }))
|
||||
];
|
||||
if (inputs.json) {
|
||||
return (0, utils_1.jsonOutput)({ value: files, shouldEscape: inputs.escapeJson });
|
||||
return {
|
||||
paths: (0, utils_1.jsonOutput)({ value: files, shouldEscape: inputs.escapeJson }),
|
||||
count: files.length.toString()
|
||||
};
|
||||
}
|
||||
return files.join(inputs.separator);
|
||||
return {
|
||||
paths: files.join(inputs.separator),
|
||||
count: files.length.toString()
|
||||
};
|
||||
});
|
||||
exports.getAllChangeTypeFiles = getAllChangeTypeFiles;
|
||||
|
||||
@@ -235,12 +253,18 @@ const utils_1 = __nccwpck_require__(918);
|
||||
const getOutputKey = (key, outputPrefix) => {
|
||||
return outputPrefix ? `${outputPrefix}_${key}` : key;
|
||||
};
|
||||
const setChangedFilesOutput = ({ allDiffFiles, inputs, filePatterns = [], outputPrefix = '' }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffResult, filePatterns = [], outputPrefix = '' }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const allFilteredDiffFiles = yield (0, utils_1.getFilteredChangedFiles)({
|
||||
allDiffFiles,
|
||||
filePatterns
|
||||
});
|
||||
core.debug(`All filtered diff files: ${JSON.stringify(allFilteredDiffFiles)}`);
|
||||
yield (0, utils_1.recoverDeletedFiles)({
|
||||
inputs,
|
||||
workingDirectory,
|
||||
deletedFiles: allFilteredDiffFiles[changedFiles_1.ChangeTypeEnum.Deleted],
|
||||
sha: diffResult.previousSha
|
||||
});
|
||||
const addedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||
inputs,
|
||||
changedFiles: allFilteredDiffFiles,
|
||||
@@ -249,7 +273,12 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, filePatterns = [], output
|
||||
core.debug(`Added files: ${addedFiles}`);
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('added_files', outputPrefix),
|
||||
value: addedFiles,
|
||||
value: addedFiles.paths,
|
||||
inputs
|
||||
});
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('added_files_count', outputPrefix),
|
||||
value: addedFiles.count,
|
||||
inputs
|
||||
});
|
||||
const copiedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||
@@ -260,7 +289,12 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, filePatterns = [], output
|
||||
core.debug(`Copied files: ${copiedFiles}`);
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('copied_files', outputPrefix),
|
||||
value: copiedFiles,
|
||||
value: copiedFiles.paths,
|
||||
inputs
|
||||
});
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('copied_files_count', outputPrefix),
|
||||
value: copiedFiles.count,
|
||||
inputs
|
||||
});
|
||||
const modifiedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||
@@ -271,7 +305,12 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, filePatterns = [], output
|
||||
core.debug(`Modified files: ${modifiedFiles}`);
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('modified_files', outputPrefix),
|
||||
value: modifiedFiles,
|
||||
value: modifiedFiles.paths,
|
||||
inputs
|
||||
});
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('modified_files_count', outputPrefix),
|
||||
value: modifiedFiles.count,
|
||||
inputs
|
||||
});
|
||||
const renamedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||
@@ -282,7 +321,12 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, filePatterns = [], output
|
||||
core.debug(`Renamed files: ${renamedFiles}`);
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('renamed_files', outputPrefix),
|
||||
value: renamedFiles,
|
||||
value: renamedFiles.paths,
|
||||
inputs
|
||||
});
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('renamed_files_count', outputPrefix),
|
||||
value: renamedFiles.count,
|
||||
inputs
|
||||
});
|
||||
const typeChangedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||
@@ -293,7 +337,12 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, filePatterns = [], output
|
||||
core.debug(`Type changed files: ${typeChangedFiles}`);
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('type_changed_files', outputPrefix),
|
||||
value: typeChangedFiles,
|
||||
value: typeChangedFiles.paths,
|
||||
inputs
|
||||
});
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('type_changed_files_count', outputPrefix),
|
||||
value: typeChangedFiles.count,
|
||||
inputs
|
||||
});
|
||||
const unmergedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||
@@ -304,7 +353,12 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, filePatterns = [], output
|
||||
core.debug(`Unmerged files: ${unmergedFiles}`);
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('unmerged_files', outputPrefix),
|
||||
value: unmergedFiles,
|
||||
value: unmergedFiles.paths,
|
||||
inputs
|
||||
});
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('unmerged_files_count', outputPrefix),
|
||||
value: unmergedFiles.count,
|
||||
inputs
|
||||
});
|
||||
const unknownFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||
@@ -315,7 +369,12 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, filePatterns = [], output
|
||||
core.debug(`Unknown files: ${unknownFiles}`);
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('unknown_files', outputPrefix),
|
||||
value: unknownFiles,
|
||||
value: unknownFiles.paths,
|
||||
inputs
|
||||
});
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('unknown_files_count', outputPrefix),
|
||||
value: unknownFiles.count,
|
||||
inputs
|
||||
});
|
||||
const allChangedAndModifiedFiles = yield (0, changedFiles_1.getAllChangeTypeFiles)({
|
||||
@@ -325,7 +384,12 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, filePatterns = [], output
|
||||
core.debug(`All changed and modified files: ${allChangedAndModifiedFiles}`);
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('all_changed_and_modified_files', outputPrefix),
|
||||
value: allChangedAndModifiedFiles,
|
||||
value: allChangedAndModifiedFiles.paths,
|
||||
inputs
|
||||
});
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('all_changed_and_modified_files_count', outputPrefix),
|
||||
value: allChangedAndModifiedFiles.count,
|
||||
inputs
|
||||
});
|
||||
const allChangedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||
@@ -341,12 +405,17 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, filePatterns = [], output
|
||||
core.debug(`All changed files: ${allChangedFiles}`);
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('all_changed_files', outputPrefix),
|
||||
value: allChangedFiles,
|
||||
value: allChangedFiles.paths,
|
||||
inputs
|
||||
});
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('all_changed_files_count', outputPrefix),
|
||||
value: allChangedFiles.count,
|
||||
inputs
|
||||
});
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('any_changed', outputPrefix),
|
||||
value: allChangedFiles.length > 0 && filePatterns.length > 0,
|
||||
value: allChangedFiles.paths.length > 0 && filePatterns.length > 0,
|
||||
inputs
|
||||
});
|
||||
const allOtherChangedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||
@@ -360,11 +429,11 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, filePatterns = [], output
|
||||
]
|
||||
});
|
||||
core.debug(`All other changed files: ${allOtherChangedFiles}`);
|
||||
const otherChangedFiles = allOtherChangedFiles
|
||||
const otherChangedFiles = allOtherChangedFiles.paths
|
||||
.split(inputs.separator)
|
||||
.filter((filePath) => !allChangedFiles.split(inputs.separator).includes(filePath));
|
||||
.filter((filePath) => !allChangedFiles.paths.split(inputs.separator).includes(filePath));
|
||||
const onlyChanged = otherChangedFiles.length === 0 &&
|
||||
allChangedFiles.length > 0 &&
|
||||
allChangedFiles.paths.length > 0 &&
|
||||
filePatterns.length > 0;
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('only_changed', outputPrefix),
|
||||
@@ -376,6 +445,11 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, filePatterns = [], output
|
||||
value: otherChangedFiles.join(inputs.separator),
|
||||
inputs
|
||||
});
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('other_changed_files_count', outputPrefix),
|
||||
value: otherChangedFiles.length.toString(),
|
||||
inputs
|
||||
});
|
||||
const allModifiedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||
inputs,
|
||||
changedFiles: allFilteredDiffFiles,
|
||||
@@ -390,12 +464,17 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, filePatterns = [], output
|
||||
core.debug(`All modified files: ${allModifiedFiles}`);
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('all_modified_files', outputPrefix),
|
||||
value: allModifiedFiles,
|
||||
value: allModifiedFiles.paths,
|
||||
inputs
|
||||
});
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('all_modified_files_count', outputPrefix),
|
||||
value: allModifiedFiles.count,
|
||||
inputs
|
||||
});
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('any_modified', outputPrefix),
|
||||
value: allModifiedFiles.length > 0 && filePatterns.length > 0,
|
||||
value: allModifiedFiles.paths.length > 0 && filePatterns.length > 0,
|
||||
inputs
|
||||
});
|
||||
const allOtherModifiedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||
@@ -409,11 +488,11 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, filePatterns = [], output
|
||||
changedFiles_1.ChangeTypeEnum.Deleted
|
||||
]
|
||||
});
|
||||
const otherModifiedFiles = allOtherModifiedFiles
|
||||
const otherModifiedFiles = allOtherModifiedFiles.paths
|
||||
.split(inputs.separator)
|
||||
.filter((filePath) => !allModifiedFiles.split(inputs.separator).includes(filePath));
|
||||
.filter((filePath) => !allModifiedFiles.paths.split(inputs.separator).includes(filePath));
|
||||
const onlyModified = otherModifiedFiles.length === 0 &&
|
||||
allModifiedFiles.length > 0 &&
|
||||
allModifiedFiles.paths.length > 0 &&
|
||||
filePatterns.length > 0;
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('only_modified', outputPrefix),
|
||||
@@ -425,6 +504,11 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, filePatterns = [], output
|
||||
value: otherModifiedFiles.join(inputs.separator),
|
||||
inputs
|
||||
});
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('other_modified_files_count', outputPrefix),
|
||||
value: otherModifiedFiles.length.toString(),
|
||||
inputs
|
||||
});
|
||||
const deletedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||
inputs,
|
||||
changedFiles: allFilteredDiffFiles,
|
||||
@@ -433,12 +517,17 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, filePatterns = [], output
|
||||
core.debug(`Deleted files: ${deletedFiles}`);
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('deleted_files', outputPrefix),
|
||||
value: deletedFiles,
|
||||
value: deletedFiles.paths,
|
||||
inputs
|
||||
});
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('deleted_files_count', outputPrefix),
|
||||
value: deletedFiles.count,
|
||||
inputs
|
||||
});
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('any_deleted', outputPrefix),
|
||||
value: deletedFiles.length > 0 && filePatterns.length > 0,
|
||||
value: deletedFiles.paths.length > 0 && filePatterns.length > 0,
|
||||
inputs
|
||||
});
|
||||
const allOtherDeletedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||
@@ -446,11 +535,11 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, filePatterns = [], output
|
||||
changedFiles: allDiffFiles,
|
||||
changeTypes: [changedFiles_1.ChangeTypeEnum.Deleted]
|
||||
});
|
||||
const otherDeletedFiles = allOtherDeletedFiles
|
||||
const otherDeletedFiles = allOtherDeletedFiles.paths
|
||||
.split(inputs.separator)
|
||||
.filter(filePath => !deletedFiles.split(inputs.separator).includes(filePath));
|
||||
.filter(filePath => !deletedFiles.paths.split(inputs.separator).includes(filePath));
|
||||
const onlyDeleted = otherDeletedFiles.length === 0 &&
|
||||
deletedFiles.length > 0 &&
|
||||
deletedFiles.paths.length > 0 &&
|
||||
filePatterns.length > 0;
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('only_deleted', outputPrefix),
|
||||
@@ -462,6 +551,11 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, filePatterns = [], output
|
||||
value: otherDeletedFiles.join(inputs.separator),
|
||||
inputs
|
||||
});
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: getOutputKey('other_deleted_files_count', outputPrefix),
|
||||
value: otherDeletedFiles.length.toString(),
|
||||
inputs
|
||||
});
|
||||
});
|
||||
exports.setChangedFilesOutput = setChangedFilesOutput;
|
||||
|
||||
@@ -1073,6 +1167,10 @@ const getInputs = () => {
|
||||
});
|
||||
const outputDir = core.getInput('output_dir', { required: false });
|
||||
const outputRenamedFilesAsDeletedAndAdded = core.getBooleanInput('output_renamed_files_as_deleted_and_added', { required: false });
|
||||
const recoverDeletedFiles = core.getBooleanInput('recover_deleted_files', {
|
||||
required: false
|
||||
});
|
||||
const recoverDeletedFilesToDestination = core.getInput('recover_deleted_files_to_destination', { required: false });
|
||||
const inputs = {
|
||||
files,
|
||||
filesSeparator,
|
||||
@@ -1107,7 +1205,9 @@ const getInputs = () => {
|
||||
sinceLastRemoteCommit,
|
||||
writeOutputFiles,
|
||||
outputDir,
|
||||
outputRenamedFilesAsDeletedAndAdded
|
||||
outputRenamedFilesAsDeletedAndAdded,
|
||||
recoverDeletedFiles,
|
||||
recoverDeletedFilesToDestination
|
||||
};
|
||||
if (fetchDepth) {
|
||||
inputs.fetchDepth = Math.max(parseInt(fetchDepth, 10), 2);
|
||||
@@ -1243,7 +1343,9 @@ function run() {
|
||||
yield (0, changedFilesOutput_1.setChangedFilesOutput)({
|
||||
allDiffFiles,
|
||||
filePatterns,
|
||||
inputs
|
||||
inputs,
|
||||
workingDirectory,
|
||||
diffResult
|
||||
});
|
||||
core.info('All Done!');
|
||||
core.endGroup();
|
||||
@@ -1259,8 +1361,10 @@ function run() {
|
||||
yield (0, changedFilesOutput_1.setChangedFilesOutput)({
|
||||
allDiffFiles,
|
||||
filePatterns: yamlFilePatterns[key],
|
||||
outputPrefix: key,
|
||||
inputs,
|
||||
outputPrefix: key
|
||||
workingDirectory,
|
||||
diffResult
|
||||
});
|
||||
core.info('All Done!');
|
||||
core.endGroup();
|
||||
@@ -1270,7 +1374,9 @@ function run() {
|
||||
core.startGroup('changed-files-all');
|
||||
yield (0, changedFilesOutput_1.setChangedFilesOutput)({
|
||||
allDiffFiles,
|
||||
inputs
|
||||
inputs,
|
||||
workingDirectory,
|
||||
diffResult
|
||||
});
|
||||
core.info('All Done!');
|
||||
core.endGroup();
|
||||
@@ -1287,7 +1393,12 @@ function run() {
|
||||
core.debug(`All old new renamed files: ${allOldNewRenamedFiles}`);
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: 'all_old_new_renamed_files',
|
||||
value: allOldNewRenamedFiles,
|
||||
value: allOldNewRenamedFiles.paths,
|
||||
inputs
|
||||
});
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: 'all_old_new_renamed_files_count',
|
||||
value: allOldNewRenamedFiles.count,
|
||||
inputs
|
||||
});
|
||||
core.info('All Done!');
|
||||
@@ -1367,7 +1478,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.setOutput = exports.getYamlFilePatterns = exports.getFilePatterns = exports.jsonOutput = exports.getDirnameMaxDepth = exports.canDiffCommits = exports.getPreviousGitTag = exports.verifyCommitSha = exports.getParentSha = exports.getRemoteBranchHeadSha = exports.getHeadSha = exports.gitLog = exports.getFilteredChangedFiles = exports.getAllChangedFiles = exports.gitRenamedFiles = exports.gitSubmoduleDiffSHA = exports.getSubmodulePath = exports.gitFetchSubmodules = exports.gitFetch = exports.submoduleExists = exports.isRepoShallow = exports.updateGitGlobalConfig = exports.verifyMinimumGitVersion = void 0;
|
||||
exports.recoverDeletedFiles = exports.setOutput = exports.getYamlFilePatterns = exports.getFilePatterns = exports.jsonOutput = exports.getDirnameMaxDepth = exports.canDiffCommits = exports.getPreviousGitTag = exports.verifyCommitSha = exports.getParentSha = exports.getRemoteBranchHeadSha = exports.getHeadSha = exports.gitLog = exports.getFilteredChangedFiles = exports.getAllChangedFiles = exports.gitRenamedFiles = exports.gitSubmoduleDiffSHA = exports.getSubmodulePath = exports.gitFetchSubmodules = exports.gitFetch = exports.submoduleExists = exports.isRepoShallow = exports.updateGitGlobalConfig = exports.verifyMinimumGitVersion = void 0;
|
||||
/*global AsyncIterableIterator*/
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const exec = __importStar(__nccwpck_require__(1514));
|
||||
@@ -2039,6 +2150,37 @@ const setOutput = ({ key, value, inputs }) => __awaiter(void 0, void 0, void 0,
|
||||
}
|
||||
});
|
||||
exports.setOutput = setOutput;
|
||||
const getDeletedFileContents = ({ cwd, filePath, sha }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const { stdout, exitCode, stderr } = yield exec.getExecOutput('git', ['show', `${sha}:${filePath}`], {
|
||||
cwd,
|
||||
silent: process.env.RUNNER_DEBUG !== '1',
|
||||
ignoreReturnCode: true
|
||||
});
|
||||
if (exitCode !== 0) {
|
||||
throw new Error(`Error getting file content from git history "${filePath}": ${stderr}`);
|
||||
}
|
||||
return stdout;
|
||||
});
|
||||
const recoverDeletedFiles = ({ inputs, workingDirectory, deletedFiles, sha }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
if (inputs.recoverDeletedFiles) {
|
||||
for (const deletedFile of deletedFiles) {
|
||||
let target = path.join(workingDirectory, deletedFile);
|
||||
if (inputs.recoverDeletedFilesToDestination) {
|
||||
target = path.join(workingDirectory, inputs.recoverDeletedFilesToDestination, deletedFile);
|
||||
}
|
||||
const deletedFileContents = yield getDeletedFileContents({
|
||||
cwd: workingDirectory,
|
||||
filePath: deletedFile,
|
||||
sha
|
||||
});
|
||||
if (!(yield exists(path.dirname(target)))) {
|
||||
yield fs_1.promises.mkdir(path.dirname(target), { recursive: true });
|
||||
}
|
||||
yield fs_1.promises.writeFile(target, deletedFileContents);
|
||||
}
|
||||
}
|
||||
});
|
||||
exports.recoverDeletedFiles = recoverDeletedFiles;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
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
@@ -47,7 +47,7 @@
|
||||
"@typescript-eslint/eslint-plugin": "5.59.11",
|
||||
"@typescript-eslint/parser": "5.59.11",
|
||||
"@vercel/ncc": "0.36.1",
|
||||
"eslint": "8.42.0",
|
||||
"eslint": "8.43.0",
|
||||
"eslint-plugin-github": "4.8.0",
|
||||
"eslint-plugin-jest": "27.2.1",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
|
||||
@@ -23,7 +23,7 @@ export const getRenamedFiles = async ({
|
||||
hasSubmodule: boolean
|
||||
diffResult: DiffResult
|
||||
submodulePaths: string[]
|
||||
}): Promise<string> => {
|
||||
}): Promise<{paths: string; count: string}> => {
|
||||
const renamedFiles = await gitRenamedFiles({
|
||||
cwd: workingDirectory,
|
||||
sha1: diffResult.previousSha,
|
||||
@@ -63,10 +63,16 @@ export const getRenamedFiles = async ({
|
||||
}
|
||||
|
||||
if (inputs.json) {
|
||||
return jsonOutput({value: renamedFiles, shouldEscape: inputs.escapeJson})
|
||||
return {
|
||||
paths: jsonOutput({value: renamedFiles, shouldEscape: inputs.escapeJson}),
|
||||
count: renamedFiles.length.toString()
|
||||
}
|
||||
}
|
||||
|
||||
return renamedFiles.join(inputs.oldNewFilesSeparator)
|
||||
return {
|
||||
paths: renamedFiles.join(inputs.oldNewFilesSeparator),
|
||||
count: renamedFiles.length.toString()
|
||||
}
|
||||
}
|
||||
|
||||
export enum ChangeTypeEnum {
|
||||
@@ -180,16 +186,22 @@ export const getChangeTypeFiles = async ({
|
||||
inputs: Inputs
|
||||
changedFiles: ChangedFiles
|
||||
changeTypes: ChangeTypeEnum[]
|
||||
}): Promise<string> => {
|
||||
}): Promise<{paths: string; count: string}> => {
|
||||
const files = [
|
||||
...new Set(getChangeTypeFilesGenerator({inputs, changedFiles, changeTypes}))
|
||||
]
|
||||
|
||||
if (inputs.json) {
|
||||
return jsonOutput({value: files, shouldEscape: inputs.escapeJson})
|
||||
return {
|
||||
paths: jsonOutput({value: files, shouldEscape: inputs.escapeJson}),
|
||||
count: files.length.toString()
|
||||
}
|
||||
}
|
||||
|
||||
return files.join(inputs.separator)
|
||||
return {
|
||||
paths: files.join(inputs.separator),
|
||||
count: files.length.toString()
|
||||
}
|
||||
}
|
||||
|
||||
function* getAllChangeTypeFilesGenerator({
|
||||
@@ -219,14 +231,20 @@ export const getAllChangeTypeFiles = async ({
|
||||
}: {
|
||||
inputs: Inputs
|
||||
changedFiles: ChangedFiles
|
||||
}): Promise<string> => {
|
||||
}): Promise<{paths: string; count: string}> => {
|
||||
const files = [
|
||||
...new Set(getAllChangeTypeFilesGenerator({inputs, changedFiles}))
|
||||
]
|
||||
|
||||
if (inputs.json) {
|
||||
return jsonOutput({value: files, shouldEscape: inputs.escapeJson})
|
||||
return {
|
||||
paths: jsonOutput({value: files, shouldEscape: inputs.escapeJson}),
|
||||
count: files.length.toString()
|
||||
}
|
||||
}
|
||||
|
||||
return files.join(inputs.separator)
|
||||
return {
|
||||
paths: files.join(inputs.separator),
|
||||
count: files.length.toString()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,9 @@ import {
|
||||
getAllChangeTypeFiles,
|
||||
getChangeTypeFiles
|
||||
} from './changedFiles'
|
||||
import {DiffResult} from './commitSha'
|
||||
import {Inputs} from './inputs'
|
||||
import {getFilteredChangedFiles, setOutput} from './utils'
|
||||
import {getFilteredChangedFiles, recoverDeletedFiles, setOutput} from './utils'
|
||||
|
||||
const getOutputKey = (key: string, outputPrefix: string): string => {
|
||||
return outputPrefix ? `${outputPrefix}_${key}` : key
|
||||
@@ -15,12 +16,16 @@ const getOutputKey = (key: string, outputPrefix: string): string => {
|
||||
export const setChangedFilesOutput = async ({
|
||||
allDiffFiles,
|
||||
inputs,
|
||||
workingDirectory,
|
||||
diffResult,
|
||||
filePatterns = [],
|
||||
outputPrefix = ''
|
||||
}: {
|
||||
allDiffFiles: ChangedFiles
|
||||
filePatterns?: string[]
|
||||
inputs: Inputs
|
||||
workingDirectory: string
|
||||
diffResult: DiffResult
|
||||
outputPrefix?: string
|
||||
}): Promise<void> => {
|
||||
const allFilteredDiffFiles = await getFilteredChangedFiles({
|
||||
@@ -29,6 +34,13 @@ export const setChangedFilesOutput = async ({
|
||||
})
|
||||
core.debug(`All filtered diff files: ${JSON.stringify(allFilteredDiffFiles)}`)
|
||||
|
||||
await recoverDeletedFiles({
|
||||
inputs,
|
||||
workingDirectory,
|
||||
deletedFiles: allFilteredDiffFiles[ChangeTypeEnum.Deleted],
|
||||
sha: diffResult.previousSha
|
||||
})
|
||||
|
||||
const addedFiles = await getChangeTypeFiles({
|
||||
inputs,
|
||||
changedFiles: allFilteredDiffFiles,
|
||||
@@ -37,7 +49,12 @@ export const setChangedFilesOutput = async ({
|
||||
core.debug(`Added files: ${addedFiles}`)
|
||||
await setOutput({
|
||||
key: getOutputKey('added_files', outputPrefix),
|
||||
value: addedFiles,
|
||||
value: addedFiles.paths,
|
||||
inputs
|
||||
})
|
||||
await setOutput({
|
||||
key: getOutputKey('added_files_count', outputPrefix),
|
||||
value: addedFiles.count,
|
||||
inputs
|
||||
})
|
||||
|
||||
@@ -49,7 +66,13 @@ export const setChangedFilesOutput = async ({
|
||||
core.debug(`Copied files: ${copiedFiles}`)
|
||||
await setOutput({
|
||||
key: getOutputKey('copied_files', outputPrefix),
|
||||
value: copiedFiles,
|
||||
value: copiedFiles.paths,
|
||||
inputs
|
||||
})
|
||||
|
||||
await setOutput({
|
||||
key: getOutputKey('copied_files_count', outputPrefix),
|
||||
value: copiedFiles.count,
|
||||
inputs
|
||||
})
|
||||
|
||||
@@ -61,7 +84,13 @@ export const setChangedFilesOutput = async ({
|
||||
core.debug(`Modified files: ${modifiedFiles}`)
|
||||
await setOutput({
|
||||
key: getOutputKey('modified_files', outputPrefix),
|
||||
value: modifiedFiles,
|
||||
value: modifiedFiles.paths,
|
||||
inputs
|
||||
})
|
||||
|
||||
await setOutput({
|
||||
key: getOutputKey('modified_files_count', outputPrefix),
|
||||
value: modifiedFiles.count,
|
||||
inputs
|
||||
})
|
||||
|
||||
@@ -73,7 +102,13 @@ export const setChangedFilesOutput = async ({
|
||||
core.debug(`Renamed files: ${renamedFiles}`)
|
||||
await setOutput({
|
||||
key: getOutputKey('renamed_files', outputPrefix),
|
||||
value: renamedFiles,
|
||||
value: renamedFiles.paths,
|
||||
inputs
|
||||
})
|
||||
|
||||
await setOutput({
|
||||
key: getOutputKey('renamed_files_count', outputPrefix),
|
||||
value: renamedFiles.count,
|
||||
inputs
|
||||
})
|
||||
|
||||
@@ -85,7 +120,13 @@ export const setChangedFilesOutput = async ({
|
||||
core.debug(`Type changed files: ${typeChangedFiles}`)
|
||||
await setOutput({
|
||||
key: getOutputKey('type_changed_files', outputPrefix),
|
||||
value: typeChangedFiles,
|
||||
value: typeChangedFiles.paths,
|
||||
inputs
|
||||
})
|
||||
|
||||
await setOutput({
|
||||
key: getOutputKey('type_changed_files_count', outputPrefix),
|
||||
value: typeChangedFiles.count,
|
||||
inputs
|
||||
})
|
||||
|
||||
@@ -97,7 +138,13 @@ export const setChangedFilesOutput = async ({
|
||||
core.debug(`Unmerged files: ${unmergedFiles}`)
|
||||
await setOutput({
|
||||
key: getOutputKey('unmerged_files', outputPrefix),
|
||||
value: unmergedFiles,
|
||||
value: unmergedFiles.paths,
|
||||
inputs
|
||||
})
|
||||
|
||||
await setOutput({
|
||||
key: getOutputKey('unmerged_files_count', outputPrefix),
|
||||
value: unmergedFiles.count,
|
||||
inputs
|
||||
})
|
||||
|
||||
@@ -109,7 +156,13 @@ export const setChangedFilesOutput = async ({
|
||||
core.debug(`Unknown files: ${unknownFiles}`)
|
||||
await setOutput({
|
||||
key: getOutputKey('unknown_files', outputPrefix),
|
||||
value: unknownFiles,
|
||||
value: unknownFiles.paths,
|
||||
inputs
|
||||
})
|
||||
|
||||
await setOutput({
|
||||
key: getOutputKey('unknown_files_count', outputPrefix),
|
||||
value: unknownFiles.count,
|
||||
inputs
|
||||
})
|
||||
|
||||
@@ -120,7 +173,13 @@ export const setChangedFilesOutput = async ({
|
||||
core.debug(`All changed and modified files: ${allChangedAndModifiedFiles}`)
|
||||
await setOutput({
|
||||
key: getOutputKey('all_changed_and_modified_files', outputPrefix),
|
||||
value: allChangedAndModifiedFiles,
|
||||
value: allChangedAndModifiedFiles.paths,
|
||||
inputs
|
||||
})
|
||||
|
||||
await setOutput({
|
||||
key: getOutputKey('all_changed_and_modified_files_count', outputPrefix),
|
||||
value: allChangedAndModifiedFiles.count,
|
||||
inputs
|
||||
})
|
||||
|
||||
@@ -137,13 +196,19 @@ export const setChangedFilesOutput = async ({
|
||||
core.debug(`All changed files: ${allChangedFiles}`)
|
||||
await setOutput({
|
||||
key: getOutputKey('all_changed_files', outputPrefix),
|
||||
value: allChangedFiles,
|
||||
value: allChangedFiles.paths,
|
||||
inputs
|
||||
})
|
||||
|
||||
await setOutput({
|
||||
key: getOutputKey('all_changed_files_count', outputPrefix),
|
||||
value: allChangedFiles.count,
|
||||
inputs
|
||||
})
|
||||
|
||||
await setOutput({
|
||||
key: getOutputKey('any_changed', outputPrefix),
|
||||
value: allChangedFiles.length > 0 && filePatterns.length > 0,
|
||||
value: allChangedFiles.paths.length > 0 && filePatterns.length > 0,
|
||||
inputs
|
||||
})
|
||||
|
||||
@@ -159,16 +224,16 @@ export const setChangedFilesOutput = async ({
|
||||
})
|
||||
core.debug(`All other changed files: ${allOtherChangedFiles}`)
|
||||
|
||||
const otherChangedFiles = allOtherChangedFiles
|
||||
const otherChangedFiles = allOtherChangedFiles.paths
|
||||
.split(inputs.separator)
|
||||
.filter(
|
||||
(filePath: string) =>
|
||||
!allChangedFiles.split(inputs.separator).includes(filePath)
|
||||
!allChangedFiles.paths.split(inputs.separator).includes(filePath)
|
||||
)
|
||||
|
||||
const onlyChanged =
|
||||
otherChangedFiles.length === 0 &&
|
||||
allChangedFiles.length > 0 &&
|
||||
allChangedFiles.paths.length > 0 &&
|
||||
filePatterns.length > 0
|
||||
|
||||
await setOutput({
|
||||
@@ -183,6 +248,12 @@ export const setChangedFilesOutput = async ({
|
||||
inputs
|
||||
})
|
||||
|
||||
await setOutput({
|
||||
key: getOutputKey('other_changed_files_count', outputPrefix),
|
||||
value: otherChangedFiles.length.toString(),
|
||||
inputs
|
||||
})
|
||||
|
||||
const allModifiedFiles = await getChangeTypeFiles({
|
||||
inputs,
|
||||
changedFiles: allFilteredDiffFiles,
|
||||
@@ -197,13 +268,19 @@ export const setChangedFilesOutput = async ({
|
||||
core.debug(`All modified files: ${allModifiedFiles}`)
|
||||
await setOutput({
|
||||
key: getOutputKey('all_modified_files', outputPrefix),
|
||||
value: allModifiedFiles,
|
||||
value: allModifiedFiles.paths,
|
||||
inputs
|
||||
})
|
||||
|
||||
await setOutput({
|
||||
key: getOutputKey('all_modified_files_count', outputPrefix),
|
||||
value: allModifiedFiles.count,
|
||||
inputs
|
||||
})
|
||||
|
||||
await setOutput({
|
||||
key: getOutputKey('any_modified', outputPrefix),
|
||||
value: allModifiedFiles.length > 0 && filePatterns.length > 0,
|
||||
value: allModifiedFiles.paths.length > 0 && filePatterns.length > 0,
|
||||
inputs
|
||||
})
|
||||
|
||||
@@ -219,16 +296,16 @@ export const setChangedFilesOutput = async ({
|
||||
]
|
||||
})
|
||||
|
||||
const otherModifiedFiles = allOtherModifiedFiles
|
||||
const otherModifiedFiles = allOtherModifiedFiles.paths
|
||||
.split(inputs.separator)
|
||||
.filter(
|
||||
(filePath: string) =>
|
||||
!allModifiedFiles.split(inputs.separator).includes(filePath)
|
||||
!allModifiedFiles.paths.split(inputs.separator).includes(filePath)
|
||||
)
|
||||
|
||||
const onlyModified =
|
||||
otherModifiedFiles.length === 0 &&
|
||||
allModifiedFiles.length > 0 &&
|
||||
allModifiedFiles.paths.length > 0 &&
|
||||
filePatterns.length > 0
|
||||
|
||||
await setOutput({
|
||||
@@ -243,6 +320,12 @@ export const setChangedFilesOutput = async ({
|
||||
inputs
|
||||
})
|
||||
|
||||
await setOutput({
|
||||
key: getOutputKey('other_modified_files_count', outputPrefix),
|
||||
value: otherModifiedFiles.length.toString(),
|
||||
inputs
|
||||
})
|
||||
|
||||
const deletedFiles = await getChangeTypeFiles({
|
||||
inputs,
|
||||
changedFiles: allFilteredDiffFiles,
|
||||
@@ -251,13 +334,19 @@ export const setChangedFilesOutput = async ({
|
||||
core.debug(`Deleted files: ${deletedFiles}`)
|
||||
await setOutput({
|
||||
key: getOutputKey('deleted_files', outputPrefix),
|
||||
value: deletedFiles,
|
||||
value: deletedFiles.paths,
|
||||
inputs
|
||||
})
|
||||
|
||||
await setOutput({
|
||||
key: getOutputKey('deleted_files_count', outputPrefix),
|
||||
value: deletedFiles.count,
|
||||
inputs
|
||||
})
|
||||
|
||||
await setOutput({
|
||||
key: getOutputKey('any_deleted', outputPrefix),
|
||||
value: deletedFiles.length > 0 && filePatterns.length > 0,
|
||||
value: deletedFiles.paths.length > 0 && filePatterns.length > 0,
|
||||
inputs
|
||||
})
|
||||
|
||||
@@ -267,15 +356,15 @@ export const setChangedFilesOutput = async ({
|
||||
changeTypes: [ChangeTypeEnum.Deleted]
|
||||
})
|
||||
|
||||
const otherDeletedFiles = allOtherDeletedFiles
|
||||
const otherDeletedFiles = allOtherDeletedFiles.paths
|
||||
.split(inputs.separator)
|
||||
.filter(
|
||||
filePath => !deletedFiles.split(inputs.separator).includes(filePath)
|
||||
filePath => !deletedFiles.paths.split(inputs.separator).includes(filePath)
|
||||
)
|
||||
|
||||
const onlyDeleted =
|
||||
otherDeletedFiles.length === 0 &&
|
||||
deletedFiles.length > 0 &&
|
||||
deletedFiles.paths.length > 0 &&
|
||||
filePatterns.length > 0
|
||||
|
||||
await setOutput({
|
||||
@@ -289,4 +378,10 @@ export const setChangedFilesOutput = async ({
|
||||
value: otherDeletedFiles.join(inputs.separator),
|
||||
inputs
|
||||
})
|
||||
|
||||
await setOutput({
|
||||
key: getOutputKey('other_deleted_files_count', outputPrefix),
|
||||
value: otherDeletedFiles.length.toString(),
|
||||
inputs
|
||||
})
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ export type Inputs = {
|
||||
writeOutputFiles: boolean
|
||||
outputDir: string
|
||||
outputRenamedFilesAsDeletedAndAdded: boolean
|
||||
recoverDeletedFiles: boolean
|
||||
recoverDeletedFilesToDestination: string
|
||||
}
|
||||
|
||||
export const getInputs = (): Inputs => {
|
||||
@@ -145,6 +147,13 @@ export const getInputs = (): Inputs => {
|
||||
'output_renamed_files_as_deleted_and_added',
|
||||
{required: false}
|
||||
)
|
||||
const recoverDeletedFiles = core.getBooleanInput('recover_deleted_files', {
|
||||
required: false
|
||||
})
|
||||
const recoverDeletedFilesToDestination = core.getInput(
|
||||
'recover_deleted_files_to_destination',
|
||||
{required: false}
|
||||
)
|
||||
|
||||
const inputs: Inputs = {
|
||||
files,
|
||||
@@ -180,7 +189,9 @@ export const getInputs = (): Inputs => {
|
||||
sinceLastRemoteCommit,
|
||||
writeOutputFiles,
|
||||
outputDir,
|
||||
outputRenamedFilesAsDeletedAndAdded
|
||||
outputRenamedFilesAsDeletedAndAdded,
|
||||
recoverDeletedFiles,
|
||||
recoverDeletedFilesToDestination
|
||||
}
|
||||
|
||||
if (fetchDepth) {
|
||||
|
||||
19
src/main.ts
19
src/main.ts
@@ -129,7 +129,9 @@ export async function run(): Promise<void> {
|
||||
await setChangedFilesOutput({
|
||||
allDiffFiles,
|
||||
filePatterns,
|
||||
inputs
|
||||
inputs,
|
||||
workingDirectory,
|
||||
diffResult
|
||||
})
|
||||
core.info('All Done!')
|
||||
core.endGroup()
|
||||
@@ -147,8 +149,10 @@ export async function run(): Promise<void> {
|
||||
await setChangedFilesOutput({
|
||||
allDiffFiles,
|
||||
filePatterns: yamlFilePatterns[key],
|
||||
outputPrefix: key,
|
||||
inputs,
|
||||
outputPrefix: key
|
||||
workingDirectory,
|
||||
diffResult
|
||||
})
|
||||
core.info('All Done!')
|
||||
core.endGroup()
|
||||
@@ -159,7 +163,9 @@ export async function run(): Promise<void> {
|
||||
core.startGroup('changed-files-all')
|
||||
await setChangedFilesOutput({
|
||||
allDiffFiles,
|
||||
inputs
|
||||
inputs,
|
||||
workingDirectory,
|
||||
diffResult
|
||||
})
|
||||
core.info('All Done!')
|
||||
core.endGroup()
|
||||
@@ -177,7 +183,12 @@ export async function run(): Promise<void> {
|
||||
core.debug(`All old new renamed files: ${allOldNewRenamedFiles}`)
|
||||
await setOutput({
|
||||
key: 'all_old_new_renamed_files',
|
||||
value: allOldNewRenamedFiles,
|
||||
value: allOldNewRenamedFiles.paths,
|
||||
inputs
|
||||
})
|
||||
await setOutput({
|
||||
key: 'all_old_new_renamed_files_count',
|
||||
value: allOldNewRenamedFiles.count,
|
||||
inputs
|
||||
})
|
||||
core.info('All Done!')
|
||||
|
||||
65
src/utils.ts
65
src/utils.ts
@@ -1032,3 +1032,68 @@ export const setOutput = async ({
|
||||
await fs.writeFile(outputFilePath, cleanedValue.replace(/\\"/g, '"'))
|
||||
}
|
||||
}
|
||||
|
||||
const getDeletedFileContents = async ({
|
||||
cwd,
|
||||
filePath,
|
||||
sha
|
||||
}: {
|
||||
cwd: string
|
||||
filePath: string
|
||||
sha: string
|
||||
}): Promise<string> => {
|
||||
const {stdout, exitCode, stderr} = await exec.getExecOutput(
|
||||
'git',
|
||||
['show', `${sha}:${filePath}`],
|
||||
{
|
||||
cwd,
|
||||
silent: process.env.RUNNER_DEBUG !== '1',
|
||||
ignoreReturnCode: true
|
||||
}
|
||||
)
|
||||
|
||||
if (exitCode !== 0) {
|
||||
throw new Error(
|
||||
`Error getting file content from git history "${filePath}": ${stderr}`
|
||||
)
|
||||
}
|
||||
|
||||
return stdout
|
||||
}
|
||||
|
||||
export const recoverDeletedFiles = async ({
|
||||
inputs,
|
||||
workingDirectory,
|
||||
deletedFiles,
|
||||
sha
|
||||
}: {
|
||||
inputs: Inputs
|
||||
workingDirectory: string
|
||||
deletedFiles: string[]
|
||||
sha: string
|
||||
}): Promise<void> => {
|
||||
if (inputs.recoverDeletedFiles) {
|
||||
for (const deletedFile of deletedFiles) {
|
||||
let target = path.join(workingDirectory, deletedFile)
|
||||
|
||||
if (inputs.recoverDeletedFilesToDestination) {
|
||||
target = path.join(
|
||||
workingDirectory,
|
||||
inputs.recoverDeletedFilesToDestination,
|
||||
deletedFile
|
||||
)
|
||||
}
|
||||
|
||||
const deletedFileContents = await getDeletedFileContents({
|
||||
cwd: workingDirectory,
|
||||
filePath: deletedFile,
|
||||
sha
|
||||
})
|
||||
|
||||
if (!(await exists(path.dirname(target)))) {
|
||||
await fs.mkdir(path.dirname(target), {recursive: true})
|
||||
}
|
||||
await fs.writeFile(target, deletedFileContents)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
50
yarn.lock
50
yarn.lock
@@ -360,10 +360,10 @@
|
||||
minimatch "^3.1.2"
|
||||
strip-json-comments "^3.1.1"
|
||||
|
||||
"@eslint/js@8.42.0":
|
||||
version "8.42.0"
|
||||
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.42.0.tgz#484a1d638de2911e6f5a30c12f49c7e4a3270fb6"
|
||||
integrity sha512-6SWlXpWU5AvId8Ac7zjzmIOqMOba/JWY8XZ4A7q7Gn1Vlfg/SFFIlrtHXt9nPn4op9ZPAkl91Jao+QQv3r/ukw==
|
||||
"@eslint/js@8.43.0":
|
||||
version "8.43.0"
|
||||
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.43.0.tgz#559ca3d9ddbd6bf907ad524320a0d14b85586af0"
|
||||
integrity sha512-s2UHCoiXfxMvmfzqoN+vrQ84ahUSYde9qNO1MdxmoEhyHWsfmwOpFlwYV+ePJEVc7gFnATGUi376WowX1N7tFg==
|
||||
|
||||
"@github/browserslist-config@^1.0.0":
|
||||
version "1.0.0"
|
||||
@@ -905,9 +905,9 @@ acorn-jsx@^5.3.2:
|
||||
integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==
|
||||
|
||||
acorn@^8.8.0:
|
||||
version "8.8.2"
|
||||
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a"
|
||||
integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==
|
||||
version "8.9.0"
|
||||
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.9.0.tgz#78a16e3b2bcc198c10822786fa6679e245db5b59"
|
||||
integrity sha512-jaVNAFBHNLXspO543WnNNPZFRtavh3skAkITqD0/2aeMkKZTN+254PyhwxFYrk3vQ1xfY+2wbesJMs/JC8/PwQ==
|
||||
|
||||
ajv@^6.10.0, ajv@^6.12.4:
|
||||
version "6.12.6"
|
||||
@@ -1124,12 +1124,12 @@ braces@^3.0.2:
|
||||
fill-range "^7.0.1"
|
||||
|
||||
browserslist@^4.21.0, browserslist@^4.21.3:
|
||||
version "4.21.8"
|
||||
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.21.8.tgz#db2498e1f4b80ed199c076248a094935860b6017"
|
||||
integrity sha512-j+7xYe+v+q2Id9qbBeCI8WX5NmZSRe8es1+0xntD/+gaWXznP8tFEkv5IgSaHf5dS1YwVMbX/4W6m937mj+wQw==
|
||||
version "4.21.9"
|
||||
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.21.9.tgz#e11bdd3c313d7e2a9e87e8b4b0c7872b13897635"
|
||||
integrity sha512-M0MFoZzbUrRU4KNfCrDLnvyE7gub+peetoTid3TBIqtunaDJyXlwhakT+/VkvSXcfIzFfK/nkCs4nmyTmxdNSg==
|
||||
dependencies:
|
||||
caniuse-lite "^1.0.30001502"
|
||||
electron-to-chromium "^1.4.428"
|
||||
caniuse-lite "^1.0.30001503"
|
||||
electron-to-chromium "^1.4.431"
|
||||
node-releases "^2.0.12"
|
||||
update-browserslist-db "^1.0.11"
|
||||
|
||||
@@ -1175,7 +1175,7 @@ camelcase@^6.2.0:
|
||||
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a"
|
||||
integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==
|
||||
|
||||
caniuse-lite@^1.0.30001502:
|
||||
caniuse-lite@^1.0.30001503:
|
||||
version "1.0.30001503"
|
||||
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001503.tgz#88b6ff1b2cf735f1f3361dc1a15b59f0561aa398"
|
||||
integrity sha512-Sf9NiF+wZxPfzv8Z3iS0rXM1Do+iOy2Lxvib38glFX+08TCYYYGR5fRJXk4d77C4AYwhUjgYgMsMudbh2TqCKw==
|
||||
@@ -1357,10 +1357,10 @@ doctrine@^3.0.0:
|
||||
dependencies:
|
||||
esutils "^2.0.2"
|
||||
|
||||
electron-to-chromium@^1.4.428:
|
||||
version "1.4.430"
|
||||
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.430.tgz#52693c812a81800fafb5b312c1a850142e2fc9eb"
|
||||
integrity sha512-FytjTbGwz///F+ToZ5XSeXbbSaXalsVRXsz2mHityI5gfxft7ieW3HqFLkU5V1aIrY42aflICqbmFoDxW10etg==
|
||||
electron-to-chromium@^1.4.431:
|
||||
version "1.4.433"
|
||||
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.433.tgz#305ef5f8ea5fe65d252aae4b0e1088f9e4842533"
|
||||
integrity sha512-MGO1k0w1RgrfdbLVwmXcDhHHuxCn2qRgR7dYsJvWFKDttvYPx6FNzCGG0c/fBBvzK2LDh3UV7Tt9awnHnvAAUQ==
|
||||
|
||||
emittery@^0.13.1:
|
||||
version "0.13.1"
|
||||
@@ -1631,15 +1631,15 @@ eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1:
|
||||
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz#c22c48f48942d08ca824cc526211ae400478a994"
|
||||
integrity sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==
|
||||
|
||||
eslint@8.42.0:
|
||||
version "8.42.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.42.0.tgz#7bebdc3a55f9ed7167251fe7259f75219cade291"
|
||||
integrity sha512-ulg9Ms6E1WPf67PHaEY4/6E2tEn5/f7FXGzr3t9cBMugOmf1INYvuUwwh1aXQN4MfJ6a5K2iNwP3w4AColvI9A==
|
||||
eslint@8.43.0:
|
||||
version "8.43.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.43.0.tgz#3e8c6066a57097adfd9d390b8fc93075f257a094"
|
||||
integrity sha512-aaCpf2JqqKesMFGgmRPessmVKjcGXqdlAYLLC3THM8t5nBRZRQ+st5WM/hoJXkdioEXLLbXgclUpM0TXo5HX5Q==
|
||||
dependencies:
|
||||
"@eslint-community/eslint-utils" "^4.2.0"
|
||||
"@eslint-community/regexpp" "^4.4.0"
|
||||
"@eslint/eslintrc" "^2.0.3"
|
||||
"@eslint/js" "8.42.0"
|
||||
"@eslint/js" "8.43.0"
|
||||
"@humanwhocodes/config-array" "^0.11.10"
|
||||
"@humanwhocodes/module-importer" "^1.0.1"
|
||||
"@nodelib/fs.walk" "^1.2.8"
|
||||
@@ -3205,9 +3205,9 @@ safe-regex-test@^1.0.0:
|
||||
is-regex "^1.1.4"
|
||||
|
||||
semver@7.x, semver@^7.3.5, semver@^7.3.7:
|
||||
version "7.5.1"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.1.tgz#c90c4d631cf74720e46b21c1d37ea07edfab91ec"
|
||||
integrity sha512-Wvss5ivl8TMRZXXESstBA4uR5iXgEN/VC5/sOcuXdVLzcdkz4HWetIoRfG5gb5X+ij/G9rw9YoGn3QoQ8OCSpw==
|
||||
version "7.5.2"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.2.tgz#5b851e66d1be07c1cdaf37dfc856f543325a2beb"
|
||||
integrity sha512-SoftuTROv/cRjCze/scjGyiDtcUyxw1rgYQSZY7XTmtR5hX+dm76iDbTH8TkLPHCQmlbQVSSbNZCPM2hb0knnQ==
|
||||
dependencies:
|
||||
lru-cache "^6.0.0"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user