Compare commits

...

20 Commits

Author SHA1 Message Date
Tonye Jack
9454999946 fix: bug recovering deleted files for submodules (#1784)
Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2023-12-10 07:14:44 +00:00
tj-actions[bot]
7611ff348d Updated README.md (#1786)
Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
2023-12-09 23:59:37 -07:00
allcontributors[bot]
187cf1e88c docs: add rodrigorfk as a contributor for code, test, and bug (#1785)
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2023-12-09 23:55:41 -07:00
dependabot[bot]
e1e532cff0 chore(deps): bump tj-actions/branch-names from 7 to 8 (#1782)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-08 01:50:07 +00:00
renovate[bot]
dfecec4fb7 chore(deps): update dependency @types/node to v20.10.4 2023-12-07 10:15:47 +00:00
Tonye Jack
c116f52a15 Update README.md 2023-12-06 21:44:31 -07:00
tj-actions[bot]
0b0b6429e1 Updated README.md (#1779)
Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
2023-12-07 04:22:32 +00:00
Tonye Jack
f732c371a4 Update README.md 2023-12-06 21:14:34 -07:00
tj-actions[bot]
04c00459a2 Updated README.md (#1778)
Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
2023-12-07 03:56:05 +00:00
Tonye Jack
5cee511ba5 Update README.md 2023-12-06 20:39:16 -07:00
Tonye Jack
399525a994 Update README.md 2023-12-06 20:37:51 -07:00
Tonye Jack
c075bd2719 Update README.md 2023-12-06 20:37:03 -07:00
renovate[bot]
208b83f295 chore(deps): update dependency typescript to v5.3.3 2023-12-06 21:22:39 +00:00
dependabot[bot]
ccb109a584 chore(deps-dev): bump @types/jest from 29.5.10 to 29.5.11 (#1775)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-06 02:00:42 +00:00
Tonye Jack
2918913341 Update README.md 2023-12-05 12:58:01 -07:00
Tonye Jack
a66176714d Deleted .github/workflows/auto-approve.yml 2023-12-04 21:09:51 -07:00
Tonye Jack
95642a1ebb chore: Update package.json (#1774) 2023-12-05 04:09:37 +00:00
Tonye Jack
726e06f8ef chore: Create SECURITY.md (#1773) 2023-12-04 20:52:31 -07:00
renovate[bot]
d96fe5d997 chore(deps): update typescript-eslint monorepo to v6.13.2 2023-12-04 19:47:16 +00:00
tj-actions[bot]
4ae611e5c5 Upgraded to v40.2.1 (#1771)
Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
2023-12-04 03:46:41 +00:00
12 changed files with 310 additions and 123 deletions

View File

@@ -197,6 +197,17 @@
"bug",
"code"
]
},
{
"login": "rodrigorfk",
"name": "Rodrigo Fior Kuntzer",
"avatar_url": "https://avatars.githubusercontent.com/u/1995033?v=4",
"profile": "https://github.com/rodrigorfk",
"contributions": [
"code",
"test",
"bug"
]
}
],
"contributorsPerLine": 7,

View File

@@ -1,33 +0,0 @@
name: Auto approve
on:
pull_request_target
jobs:
auto-approve:
runs-on: ubuntu-latest
steps:
- uses: hmarr/auto-approve-action@v3
if: |
(
github.event.pull_request.user.login == 'dependabot[bot]' ||
github.event.pull_request.user.login == 'dependabot' ||
github.event.pull_request.user.login == 'dependabot-preview[bot]' ||
github.event.pull_request.user.login == 'dependabot-preview' ||
github.event.pull_request.user.login == 'renovate[bot]' ||
github.event.pull_request.user.login == 'renovate' ||
github.event.pull_request.user.login == 'github-actions[bot]'
)
&&
(
github.actor == 'dependabot[bot]' ||
github.actor == 'dependabot' ||
github.actor == 'dependabot-preview[bot]' ||
github.actor == 'dependabot-preview' ||
github.actor == 'renovate[bot]' ||
github.actor == 'renovate' ||
github.actor == 'github-actions[bot]'
)
with:
github-token: ${{ secrets.PAT_TOKEN }}

View File

@@ -24,7 +24,7 @@ on:
- auto_merge_enabled
- auto_merge_disabled
branches:
- main
- "**"
jobs:
build:
@@ -824,6 +824,36 @@ jobs:
cat "deleted_files/test/test deleted.txt"
fi
- name: Run changed-files with recover_deleted_files for an expected git submodule file
id: changed-files-recover-deleted-files-within-submodule
uses: ./
with:
base_sha: "3be651e99d3d4eae395694f6c6f3b9d18457f6c8"
sha: "d90c240f2ad4ec04d8f0f48e5ac290ad96ebe850"
recover_deleted_files: true
fetch_depth: 60000
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files-recover-deleted-files-within-submodule.outputs) }}"
shell:
bash
- name: Verify deleted files
if: steps.changed-files-recover-deleted-files-within-submodule.outputs.deleted_files != 'test/demo/.github/FUNDING.yml'
run: |
echo "Expected: (test/demo/.github/FUNDING.yml) got ${{ steps.changed-files-recover-deleted-files-within-submodule.outputs.deleted_files }}"
exit 1
- name: Verify that test/demo/.github/FUNDING.yml is restored
run: |
if [ ! -f "test/demo/.github/FUNDING.yml" ]; then
echo "Expected: (test/demo/.github/FUNDING.yml) to exist"
exit 1
else
cat "test/demo/.github/FUNDING.yml"
rm "test/demo/.github/FUNDING.yml"
fi
test-dir-names-deleted-files-include-only-deleted-dirs-single-file:
name: Test dir names deleted files include only deleted dirs single file
runs-on: ubuntu-latest
@@ -1953,7 +1983,7 @@ jobs:
bash
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v7
uses: tj-actions/branch-names@v8
if: github.event_name == 'pull_request' && matrix.fetch-depth == 0
- uses: nrwl/nx-set-shas@v4
id: last_successful_commit

View File

@@ -1,5 +1,66 @@
# Changelog
# [40.2.1](https://github.com/tj-actions/changed-files/compare/v40.2.0...v40.2.1) - (2023-12-04)
## <!-- 16 --> Add
- Added missing changes and modified dist assets.
([1c93849](https://github.com/tj-actions/changed-files/commit/1c938490c880156b746568a518594309cfb3f66b)) - (GitHub Action)
- Added missing changes and modified dist assets.
([ee5ef75](https://github.com/tj-actions/changed-files/commit/ee5ef758aa548d365981b0889bab497dd108a785)) - (GitHub Action)
## <!-- 17 --> Remove
- Deleted .github/workflows/greetings.yml ([f91c9fe](https://github.com/tj-actions/changed-files/commit/f91c9fe8b1f4719a8e3901b4878b31105efcb66e)) - (Tonye Jack)
## <!-- 26 -->🔄 Update
- Updated README.md ([#1769](https://github.com/tj-actions/changed-files/issues/1769))
Co-authored-by: jackton1 <jackton1@users.noreply.github.com> ([66b77cb](https://github.com/tj-actions/changed-files/commit/66b77cbd0c866511f45c4f624e61034699bc70c2)) - (tj-actions[bot])
- Update README.md ([10bfa98](https://github.com/tj-actions/changed-files/commit/10bfa980b7876a94d460f54bd1b46d5c54b025d3)) - (Tonye Jack)
- Updated README.md ([#1767](https://github.com/tj-actions/changed-files/issues/1767))
Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
Co-authored-by: Tonye Jack <jtonye@ymail.com> ([9e46b4f](https://github.com/tj-actions/changed-files/commit/9e46b4f7f7dce12301b893ec0484694ae579108d)) - (tj-actions[bot])
- Update README.md ([3bf6172](https://github.com/tj-actions/changed-files/commit/3bf61725348c8cd85dcf9ce468c35a8e15a5c77e)) - (Tonye Jack)
- Updated README.md ([#1755](https://github.com/tj-actions/changed-files/issues/1755))
Co-authored-by: jackton1 <jackton1@users.noreply.github.com> ([48427af](https://github.com/tj-actions/changed-files/commit/48427afe26457522a3f0f4a5afae46a8bb6261b1)) - (tj-actions[bot])
- Update README.md ([742ed36](https://github.com/tj-actions/changed-files/commit/742ed362b6c6415493f2dd3a2e86ccbb60e1035a)) - (Tonye Jack)
- Updated README.md ([#1750](https://github.com/tj-actions/changed-files/issues/1750))
Co-authored-by: repo-ranger[bot] <repo-ranger[bot]@users.noreply.github.com> ([86cabf5](https://github.com/tj-actions/changed-files/commit/86cabf5ea23ece4cc5468211fbab9fb76f2b1d91)) - (tj-actions[bot])
## <!-- 30 -->📝 Other
- Update test.yml removing pull_request_review event ([#1763](https://github.com/tj-actions/changed-files/issues/1763)) ([af6bdde](https://github.com/tj-actions/changed-files/commit/af6bdde59acc56af0e0a6c6a8acff0d3562162ba)) - (Tonye Jack)
- Remove usage of pull_request_target event from test.yml ([#1758](https://github.com/tj-actions/changed-files/issues/1758)) ([3ca6b80](https://github.com/tj-actions/changed-files/commit/3ca6b800138b4c660c4b99b76bb064cdf3f31e59)) - (Tonye Jack)
## <!-- 6 -->🧪 Testing
- Verify bug writing outputs when files_yaml is used ([#1762](https://github.com/tj-actions/changed-files/issues/1762)) ([fc1fb2b](https://github.com/tj-actions/changed-files/commit/fc1fb2b582f5e701390f9f6200dddd7425a3cc70)) - (Tonye Jack)
## <!-- 7 -->⚙️ Miscellaneous Tasks
- **deps:** Lock file maintenance ([ba558db](https://github.com/tj-actions/changed-files/commit/ba558db9775398895ee078c784a5ddef602bb754)) - (renovate[bot])
- **deps:** Update dependency @types/node to v20.10.3 ([bf19fa2](https://github.com/tj-actions/changed-files/commit/bf19fa23a6b30fb87fe85abdb237154c4573c08c)) - (renovate[bot])
- **deps:** Update dependency eslint-config-prettier to v9.1.0 ([45581f0](https://github.com/tj-actions/changed-files/commit/45581f0044c213a3f45e5036d921892484eb7a0d)) - (renovate[bot])
- **deps:** Update dependency eslint to v8.55.0 ([9ebb48b](https://github.com/tj-actions/changed-files/commit/9ebb48b57af1c93015957959d7d9ffe546df3ccd)) - (renovate[bot])
- **deps:** Update dependency @types/node to v20.10.2 ([4e2dca3](https://github.com/tj-actions/changed-files/commit/4e2dca3ba527858faa57966af9baff3c9bbbb5d6)) - (renovate[bot])
- **deps:** Update dependency @types/node to v20.10.1 ([883b4cc](https://github.com/tj-actions/changed-files/commit/883b4ccbdb2f56448769f275a0d599bb9eb942c6)) - (renovate[bot])
- **deps:** Lock file maintenance ([42fe158](https://github.com/tj-actions/changed-files/commit/42fe158594392b80e30260bbb489eae0ed872e23)) - (renovate[bot])
- Remove unused job ([#1754](https://github.com/tj-actions/changed-files/issues/1754)) ([5c74583](https://github.com/tj-actions/changed-files/commit/5c74583cb3f4bb017cad62c02cf599b60d088a3d)) - (Tonye Jack)
- **deps:** Update typescript-eslint monorepo to v6.13.1 ([44d340e](https://github.com/tj-actions/changed-files/commit/44d340e48cef9bee9d0bd468f0f9a8ccf3219200)) - (renovate[bot])
- **deps:** Update typescript-eslint monorepo to v6.13.0 ([2561448](https://github.com/tj-actions/changed-files/commit/2561448da0579d80e1916a83b9c0d3622add8fc5)) - (renovate[bot])
- Update README.md ([#1749](https://github.com/tj-actions/changed-files/issues/1749)) ([b5fc67a](https://github.com/tj-actions/changed-files/commit/b5fc67a4f5e5dafd4d564eefde1958a4ae7974ac)) - (Tonye Jack)
## <!-- 9 -->⬆️ Upgrades
- Upgraded to v40.2.0 ([#1746](https://github.com/tj-actions/changed-files/issues/1746))
Co-authored-by: jackton1 <jackton1@users.noreply.github.com> ([0b22a52](https://github.com/tj-actions/changed-files/commit/0b22a52bff23bee090e1e07f70f9e7fab8384387)) - (tj-actions[bot])
# [40.2.0](https://github.com/tj-actions/changed-files/compare/v40.1.1...v40.2.0) - (2023-11-27)
## <!-- 0 -->🚀 Features

View File

@@ -9,7 +9,7 @@
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-21-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-22-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
@@ -19,7 +19,7 @@ Effortlessly track all changed files and directories relative to a target branch
> \[!NOTE]
>
> * This action solely identifies files that have undergone changes within the context of events such as `pull_request*`, `push`, and more. However, it doesn't detect pending uncommitted changes created during the workflow execution.
> * This action solely identifies files that have changed within the context of events such as `pull_request*`, `push`, and more. However, it doesn't detect pending uncommitted changes created during the workflow execution.
>
> See: https://github.com/tj-actions/verify-changed-files instead
@@ -139,11 +139,12 @@ jobs:
id: changed-markdown-files
uses: tj-actions/changed-files@v40
with:
# Avoid using single or double quotes for multiline patterns
files: |
**.md
# Avoid using single or double quotes for multiline patterns
- name: List all changed files markdown files
if: steps.changed-markdown-files.outputs.any_changed == 'true'
run: |
for file in ${{ steps.changed-markdown-files.outputs.all_changed_files }}; do
echo "$file was changed"
@@ -296,13 +297,6 @@ Support this project with a :star:
[buymeacoffee-shield]: https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png
> \[!WARNING]
>
> * When using `files_yaml*` inputs ensure all outputs are prefixed by the key `test_{...}` e.g. `test_added_files`, `test_any_changed`
> * All keys must start with a letter or \_ and contain only alphanumeric characters, -, or \_.
<!-- AUTO-DOC-OUTPUT:END -->
## Inputs ⚙️
<!-- AUTO-DOC-INPUT:START - Do not remove or modify this section -->
@@ -609,6 +603,16 @@ Support this project with a :star:
| U | Unmerged |
| X | Unknown |
> \[!IMPORTANT]
>
> * When using `files_yaml*` inputs:
> * All keys must start with a letter or `_` and contain only alphanumeric characters, `-`, or `_`.
> For example, `test` or `test_key` or `tesT-key` are all valid.
>
> * it's important to prefix all outputs with the key to ensure that the correct outputs are accessible.
>
> For example, if you use `test` as the key, you can access outputs like `added_files`, `any_changed`, and so on by prefixing them with the key `test_added_files` or `test_any_changed` etc.
## Outputs 📤
<!-- AUTO-DOC-OUTPUT:START - Do not remove or modify this section -->
@@ -1261,6 +1265,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center" valign="top" width="14.28%"><a href="https://github.com/albertoperdomo2"><img src="https://avatars.githubusercontent.com/u/62241095?v=4?s=100" width="100px;" alt="Alberto Perdomo"/><br /><sub><b>Alberto Perdomo</b></sub></a><br /><a href="https://github.com/tj-actions/changed-files/commits?author=albertoperdomo2" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://arthurvolant.com"><img src="https://avatars.githubusercontent.com/u/37664438?v=4?s=100" width="100px;" alt="Arthur"/><br /><sub><b>Arthur</b></sub></a><br /><a href="https://github.com/tj-actions/changed-files/issues?q=author%3AV0lantis" title="Bug reports">🐛</a> <a href="https://github.com/tj-actions/changed-files/commits?author=V0lantis" title="Code">💻</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/rodrigorfk"><img src="https://avatars.githubusercontent.com/u/1995033?v=4?s=100" width="100px;" alt="Rodrigo Fior Kuntzer"/><br /><sub><b>Rodrigo Fior Kuntzer</b></sub></a><br /><a href="https://github.com/tj-actions/changed-files/commits?author=rodrigorfk" title="Code">💻</a> <a href="https://github.com/tj-actions/changed-files/commits?author=rodrigorfk" title="Tests">⚠️</a> <a href="https://github.com/tj-actions/changed-files/issues?q=author%3Arodrigorfk" title="Bug reports">🐛</a></td>
</tr>
</tbody>
</table>

32
SECURITY.md Normal file
View File

@@ -0,0 +1,32 @@
# Security Policy
## Proactive Security Measures
To proactively detect and address security vulnerabilities, we utilize several robust tools and processes:
- **Dependency Updates:** We use [Renovate](https://renovatebot.com) and [Dependabot](https://docs.github.com/en/code-security/dependabot/dependabot-security-updates/about-dependabot-security-updates) to keep our dependencies updated and promptly patch detected vulnerabilities through automated PRs.
- **[GitHub's Security Features](https://github.com/features/security):** Our repository and dependencies are continuously monitored via GitHub's security features, which include:
- **Code Scanning:** Using GitHub's CodeQL, all pull requests are scanned to identify potential vulnerabilities in our source code.
- **Automated Alerts:** Dependabot identifies vulnerabilities based on the GitHub Advisory Database and opens PRs with patches, while automated [secret scanning](https://docs.github.com/en/enterprise-cloud@latest/code-security/secret-scanning/about-secret-scanning#about-secret-scanning-for-partner-patterns) provides alerts for detected secrets.
- **[GitGuardian Security Checks](https://www.gitguardian.com/):** We employ GitGuardian to ensure security checks are performed on the codebase, enhancing the overall security of our project.
- **Code Analysis and Security Scanning:** With the help of [Codacy Static Code Analysis](https://www.codacy.com/) and [Codacy Security Scan](https://security.codacy.com/), we conduct thorough analyses and scans of our code for potential security risks.
## Reporting Security Vulnerabilities
Despite our best efforts to deliver secure software, we acknowledge the invaluable role of the community in identifying security breaches.
### Private Vulnerability Disclosures
We request all suspected vulnerabilities to be responsibly and privately disclosed by sending an email to [support@tj-actions.online](mailto:support@tj-actions.online).
### Public Vulnerability Disclosures
For publicly disclosed security vulnerabilities, please **IMMEDIATELY** email [support@tj-actions.online](mailto:support@tj-actions.online) with the details for prompt action.
Upon confirmation of a breach, reporters will receive full credit and recognition for their contribution. Please note, that we do not offer monetary compensation for reporting vulnerabilities.
## Communication of Security Breaches
We will utilize the [GitHub Security Advisory](https://github.com/tj-actions/changed-files/security/advisories) to communicate any security breaches. The advisory will be made public once a patch has been released to rectify the issue.
We appreciate your cooperation and contribution to maintaining the security of our software. Remember, a secure community is a strong community.

47
dist/index.js generated vendored
View File

@@ -1725,7 +1725,9 @@ const getChangedFilesFromLocalGitHistory = ({ inputs, env, workingDirectory, fil
workingDirectory,
deletedFiles: allDiffFiles[changedFiles_1.ChangeTypeEnum.Deleted],
recoverPatterns,
sha: diffResult.previousSha
diffResult,
hasSubmodule,
submodulePaths
});
}
yield (0, changedFiles_1.processChangedFiles)({
@@ -2832,7 +2834,7 @@ const getDeletedFileContents = ({ cwd, filePath, sha }) => __awaiter(void 0, voi
}
return stdout;
});
const recoverDeletedFiles = ({ inputs, workingDirectory, deletedFiles, recoverPatterns, sha }) => __awaiter(void 0, void 0, void 0, function* () {
const recoverDeletedFiles = ({ inputs, workingDirectory, deletedFiles, recoverPatterns, diffResult, hasSubmodule, submodulePaths }) => __awaiter(void 0, void 0, void 0, function* () {
let recoverableDeletedFiles = deletedFiles;
core.debug(`recoverable deleted files: ${recoverableDeletedFiles}`);
if (recoverPatterns.length > 0) {
@@ -2848,15 +2850,46 @@ const recoverDeletedFiles = ({ inputs, workingDirectory, deletedFiles, recoverPa
if (inputs.recoverDeletedFilesToDestination) {
target = path.join(workingDirectory, inputs.recoverDeletedFilesToDestination, deletedFile);
}
const deletedFileContents = yield getDeletedFileContents({
cwd: workingDirectory,
filePath: deletedFile,
sha
});
let deletedFileContents;
const submodulePath = submodulePaths.find(p => deletedFile.startsWith(p));
if (hasSubmodule && submodulePath) {
const submoduleShaResult = yield (0, exports.gitSubmoduleDiffSHA)({
cwd: workingDirectory,
parentSha1: diffResult.previousSha,
parentSha2: diffResult.currentSha,
submodulePath,
diff: diffResult.diff
});
if (submoduleShaResult.previousSha) {
core.debug(`recovering deleted file "${deletedFile}" from submodule ${submodulePath} from ${submoduleShaResult.previousSha}`);
deletedFileContents = yield getDeletedFileContents({
cwd: path.join(workingDirectory, submodulePath),
// E.g. submodulePath = test/demo and deletedFile = test/demo/.github/README.md => filePath => .github/README.md
filePath: deletedFile.replace(submodulePath, '').substring(1),
sha: submoduleShaResult.previousSha
});
}
else {
core.warning(`Unable to recover deleted file "${deletedFile}" from submodule ${submodulePath} from ${submoduleShaResult.previousSha}`);
continue;
}
}
else {
core.debug(`recovering deleted file "${deletedFile}" from ${diffResult.previousSha}`);
deletedFileContents = yield getDeletedFileContents({
cwd: workingDirectory,
filePath: deletedFile,
sha: diffResult.previousSha
});
}
core.debug(`recovered deleted file "${deletedFile}"`);
if (!(yield (0, exports.exists)(path.dirname(target)))) {
core.debug(`creating directory "${path.dirname(target)}"`);
yield fs_1.promises.mkdir(path.dirname(target), { recursive: true });
}
core.debug(`writing file "${target}"`);
yield fs_1.promises.writeFile(target, deletedFileContents);
core.debug(`wrote file "${target}"`);
}
});
exports.recoverDeletedFiles = recoverDeletedFiles;

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{
"name": "@tj-actions/changed-files",
"version": "40.2.0",
"version": "40.2.1",
"description": "Github action to retrieve all (added, copied, modified, deleted, renamed, type changed, unmerged, unknown) files and directories.",
"main": "lib/main.js",
"publishConfig": {
@@ -8,10 +8,10 @@
},
"scripts": {
"build": "tsc",
"format": "prettier --write **/*.ts",
"format-check": "prettier --check **/*.ts",
"lint": "eslint **/*.ts --max-warnings 0",
"lint:fix": "eslint --fix src/**/*.ts",
"format": "prettier --write src/*.ts src/**/*.ts",
"format-check": "prettier --check src/*.ts src/**/*.ts",
"lint": "eslint src/*.ts src/**/*.ts --max-warnings 0",
"lint:fix": "eslint --fix src/*.ts src/**/*.ts",
"package": "ncc build lib/main.js --source-map --license licenses.txt",
"test": "jest --coverage",
"all": "yarn build && yarn format && yarn lint && yarn package && yarn test"

View File

@@ -144,7 +144,9 @@ const getChangedFilesFromLocalGitHistory = async ({
workingDirectory,
deletedFiles: allDiffFiles[ChangeTypeEnum.Deleted],
recoverPatterns,
sha: diffResult.previousSha
diffResult,
hasSubmodule,
submodulePaths
})
}

View File

@@ -10,6 +10,7 @@ import * as path from 'path'
import {createInterface} from 'readline'
import {parseDocument} from 'yaml'
import {ChangedFiles, ChangeTypeEnum} from './changedFiles'
import {DiffResult} from './commitSha'
import {Inputs} from './inputs'
const MINIMUM_GIT_VERSION = '2.18.0'
@@ -1395,13 +1396,17 @@ export const recoverDeletedFiles = async ({
workingDirectory,
deletedFiles,
recoverPatterns,
sha
diffResult,
hasSubmodule,
submodulePaths
}: {
inputs: Inputs
workingDirectory: string
deletedFiles: string[]
recoverPatterns: string[]
sha: string
diffResult: DiffResult
hasSubmodule: boolean
submodulePaths: string[]
}): Promise<void> => {
let recoverableDeletedFiles = deletedFiles
core.debug(`recoverable deleted files: ${recoverableDeletedFiles}`)
@@ -1426,16 +1431,55 @@ export const recoverDeletedFiles = async ({
)
}
const deletedFileContents = await getDeletedFileContents({
cwd: workingDirectory,
filePath: deletedFile,
sha
})
let deletedFileContents: string
const submodulePath = submodulePaths.find(p => deletedFile.startsWith(p))
if (hasSubmodule && submodulePath) {
const submoduleShaResult = await gitSubmoduleDiffSHA({
cwd: workingDirectory,
parentSha1: diffResult.previousSha,
parentSha2: diffResult.currentSha,
submodulePath,
diff: diffResult.diff
})
if (submoduleShaResult.previousSha) {
core.debug(
`recovering deleted file "${deletedFile}" from submodule ${submodulePath} from ${submoduleShaResult.previousSha}`
)
deletedFileContents = await getDeletedFileContents({
cwd: path.join(workingDirectory, submodulePath),
// E.g. submodulePath = test/demo and deletedFile = test/demo/.github/README.md => filePath => .github/README.md
filePath: deletedFile.replace(submodulePath, '').substring(1),
sha: submoduleShaResult.previousSha
})
} else {
core.warning(
`Unable to recover deleted file "${deletedFile}" from submodule ${submodulePath} from ${submoduleShaResult.previousSha}`
)
continue
}
} else {
core.debug(
`recovering deleted file "${deletedFile}" from ${diffResult.previousSha}`
)
deletedFileContents = await getDeletedFileContents({
cwd: workingDirectory,
filePath: deletedFile,
sha: diffResult.previousSha
})
}
core.debug(`recovered deleted file "${deletedFile}"`)
if (!(await exists(path.dirname(target)))) {
core.debug(`creating directory "${path.dirname(target)}"`)
await fs.mkdir(path.dirname(target), {recursive: true})
}
core.debug(`writing file "${target}"`)
await fs.writeFile(target, deletedFileContents)
core.debug(`wrote file "${target}"`)
}
}

114
yarn.lock
View File

@@ -860,9 +860,9 @@
"@types/istanbul-lib-report" "*"
"@types/jest@^29.5.2":
version "29.5.10"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-29.5.10.tgz#a10fc5bab9e426081c12b2ef73d24d4f0c9b7f50"
integrity sha512-tE4yxKEphEyxj9s4inideLHktW/x6DwesIwWZ9NN1FKf9zbJYsnhBoA9vrHA/IuIOKwPa5PcFBNV4lpMIOEzyQ==
version "29.5.11"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-29.5.11.tgz#0c13aa0da7d0929f078ab080ae5d4ced80fa2f2c"
integrity sha512-S2mHmYIVe13vrm6q4kN6fLYYAka15ALQki/vgDC3mIukEOx8WJlv0kQPM+d4w8Gp6u0uSdKND04IlTXBv0rwnQ==
dependencies:
expect "^29.0.0"
pretty-format "^29.0.0"
@@ -890,9 +890,9 @@
"@types/braces" "*"
"@types/node@*", "@types/node@^20.3.2":
version "20.10.3"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.10.3.tgz#4900adcc7fc189d5af5bb41da8f543cea6962030"
integrity sha512-XJavIpZqiXID5Yxnxv3RUDKTN5b81ddNC3ecsA0SoFXz/QU8OGBwZGMomiq0zw+uuqbL/krztv/DINAQ/EV4gg==
version "20.10.4"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.10.4.tgz#b246fd84d55d5b1b71bf51f964bd514409347198"
integrity sha512-D08YG6rr8X90YB56tSIuBaddy/UXAA9RKJoFvrsnogAum/0pmjkgi4+2nx96A330FmioegBWmEYQ+syqCFaveg==
dependencies:
undici-types "~5.26.4"
@@ -924,15 +924,15 @@
"@types/yargs-parser" "*"
"@typescript-eslint/eslint-plugin@^6.0.0":
version "6.13.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.13.1.tgz#f98bd887bf95551203c917e734d113bf8d527a0c"
integrity sha512-5bQDGkXaxD46bPvQt08BUz9YSaO4S0fB1LB5JHQuXTfkGPI3+UUeS387C/e9jRie5GqT8u5kFTrMvAjtX4O5kA==
version "6.13.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.13.2.tgz#2e03506c5362a65e43cb132c37c9ce2d3cb51470"
integrity sha512-3+9OGAWHhk4O1LlcwLBONbdXsAhLjyCFogJY/cWy2lxdVJ2JrcTF2pTGMaLl2AE7U1l31n8Py4a8bx5DLf/0dQ==
dependencies:
"@eslint-community/regexpp" "^4.5.1"
"@typescript-eslint/scope-manager" "6.13.1"
"@typescript-eslint/type-utils" "6.13.1"
"@typescript-eslint/utils" "6.13.1"
"@typescript-eslint/visitor-keys" "6.13.1"
"@typescript-eslint/scope-manager" "6.13.2"
"@typescript-eslint/type-utils" "6.13.2"
"@typescript-eslint/utils" "6.13.2"
"@typescript-eslint/visitor-keys" "6.13.2"
debug "^4.3.4"
graphemer "^1.4.0"
ignore "^5.2.4"
@@ -941,14 +941,14 @@
ts-api-utils "^1.0.1"
"@typescript-eslint/parser@^6.0.0":
version "6.13.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-6.13.1.tgz#29d6d4e5fab4669e58bc15f6904b67da65567487"
integrity sha512-fs2XOhWCzRhqMmQf0eicLa/CWSaYss2feXsy7xBD/pLyWke/jCIVc2s1ikEAtSW7ina1HNhv7kONoEfVNEcdDQ==
version "6.13.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-6.13.2.tgz#390b79cc9a57a5f904d197a201cc4b6bc4f9afb9"
integrity sha512-MUkcC+7Wt/QOGeVlM8aGGJZy1XV5YKjTpq9jK6r6/iLsGXhBVaGP5N0UYvFsu9BFlSpwY9kMretzdBH01rkRXg==
dependencies:
"@typescript-eslint/scope-manager" "6.13.1"
"@typescript-eslint/types" "6.13.1"
"@typescript-eslint/typescript-estree" "6.13.1"
"@typescript-eslint/visitor-keys" "6.13.1"
"@typescript-eslint/scope-manager" "6.13.2"
"@typescript-eslint/types" "6.13.2"
"@typescript-eslint/typescript-estree" "6.13.2"
"@typescript-eslint/visitor-keys" "6.13.2"
debug "^4.3.4"
"@typescript-eslint/scope-manager@5.62.0":
@@ -959,21 +959,21 @@
"@typescript-eslint/types" "5.62.0"
"@typescript-eslint/visitor-keys" "5.62.0"
"@typescript-eslint/scope-manager@6.13.1":
version "6.13.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-6.13.1.tgz#58c7c37c6a957d3d9f59bc4f64c2888e0cac1d70"
integrity sha512-BW0kJ7ceiKi56GbT2KKzZzN+nDxzQK2DS6x0PiSMPjciPgd/JRQGMibyaN2cPt2cAvuoH0oNvn2fwonHI+4QUQ==
"@typescript-eslint/scope-manager@6.13.2":
version "6.13.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-6.13.2.tgz#5fa4e4adace028dafac212c770640b94e7b61052"
integrity sha512-CXQA0xo7z6x13FeDYCgBkjWzNqzBn8RXaE3QVQVIUm74fWJLkJkaHmHdKStrxQllGh6Q4eUGyNpMe0b1hMkXFA==
dependencies:
"@typescript-eslint/types" "6.13.1"
"@typescript-eslint/visitor-keys" "6.13.1"
"@typescript-eslint/types" "6.13.2"
"@typescript-eslint/visitor-keys" "6.13.2"
"@typescript-eslint/type-utils@6.13.1":
version "6.13.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-6.13.1.tgz#e6e5885e387841cae9c38fc0638fd8b7561973d6"
integrity sha512-A2qPlgpxx2v//3meMqQyB1qqTg1h1dJvzca7TugM3Yc2USDY+fsRBiojAEo92HO7f5hW5mjAUF6qobOPzlBCBQ==
"@typescript-eslint/type-utils@6.13.2":
version "6.13.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-6.13.2.tgz#ebec2da14a6bb7122e0fd31eea72a382c39c6102"
integrity sha512-Qr6ssS1GFongzH2qfnWKkAQmMUyZSyOr0W54nZNU1MDfo+U4Mv3XveeLZzadc/yq8iYhQZHYT+eoXJqnACM1tw==
dependencies:
"@typescript-eslint/typescript-estree" "6.13.1"
"@typescript-eslint/utils" "6.13.1"
"@typescript-eslint/typescript-estree" "6.13.2"
"@typescript-eslint/utils" "6.13.2"
debug "^4.3.4"
ts-api-utils "^1.0.1"
@@ -982,10 +982,10 @@
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.62.0.tgz#258607e60effa309f067608931c3df6fed41fd2f"
integrity sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ==
"@typescript-eslint/types@6.13.1":
version "6.13.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.13.1.tgz#b56f26130e7eb8fa1e429c75fb969cae6ad7bb5c"
integrity sha512-gjeEskSmiEKKFIbnhDXUyiqVma1gRCQNbVZ1C8q7Zjcxh3WZMbzWVfGE9rHfWd1msQtPS0BVD9Jz9jded44eKg==
"@typescript-eslint/types@6.13.2":
version "6.13.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.13.2.tgz#c044aac24c2f6cefb8e921e397acad5417dd0ae6"
integrity sha512-7sxbQ+EMRubQc3wTfTsycgYpSujyVbI1xw+3UMRUcrhSy+pN09y/lWzeKDbvhoqcRbHdc+APLs/PWYi/cisLPg==
"@typescript-eslint/typescript-estree@5.62.0":
version "5.62.0"
@@ -1000,30 +1000,30 @@
semver "^7.3.7"
tsutils "^3.21.0"
"@typescript-eslint/typescript-estree@6.13.1":
version "6.13.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-6.13.1.tgz#d01dda78d2487434d1c503853fa00291c566efa4"
integrity sha512-sBLQsvOC0Q7LGcUHO5qpG1HxRgePbT6wwqOiGLpR8uOJvPJbfs0mW3jPA3ujsDvfiVwVlWUDESNXv44KtINkUQ==
"@typescript-eslint/typescript-estree@6.13.2":
version "6.13.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-6.13.2.tgz#ae556ee154c1acf025b48d37c3ef95a1d55da258"
integrity sha512-SuD8YLQv6WHnOEtKv8D6HZUzOub855cfPnPMKvdM/Bh1plv1f7Q/0iFUDLKKlxHcEstQnaUU4QZskgQq74t+3w==
dependencies:
"@typescript-eslint/types" "6.13.1"
"@typescript-eslint/visitor-keys" "6.13.1"
"@typescript-eslint/types" "6.13.2"
"@typescript-eslint/visitor-keys" "6.13.2"
debug "^4.3.4"
globby "^11.1.0"
is-glob "^4.0.3"
semver "^7.5.4"
ts-api-utils "^1.0.1"
"@typescript-eslint/utils@6.13.1":
version "6.13.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-6.13.1.tgz#925b3a2453a71ada914ae329b7bb7e7d96634b2f"
integrity sha512-ouPn/zVoan92JgAegesTXDB/oUp6BP1v8WpfYcqh649ejNc9Qv+B4FF2Ff626kO1xg0wWwwG48lAJ4JuesgdOw==
"@typescript-eslint/utils@6.13.2":
version "6.13.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-6.13.2.tgz#8eb89e53adc6d703a879b131e528807245486f89"
integrity sha512-b9Ptq4eAZUym4idijCRzl61oPCwwREcfDI8xGk751Vhzig5fFZR9CyzDz4Sp/nxSLBYxUPyh4QdIDqWykFhNmQ==
dependencies:
"@eslint-community/eslint-utils" "^4.4.0"
"@types/json-schema" "^7.0.12"
"@types/semver" "^7.5.0"
"@typescript-eslint/scope-manager" "6.13.1"
"@typescript-eslint/types" "6.13.1"
"@typescript-eslint/typescript-estree" "6.13.1"
"@typescript-eslint/scope-manager" "6.13.2"
"@typescript-eslint/types" "6.13.2"
"@typescript-eslint/typescript-estree" "6.13.2"
semver "^7.5.4"
"@typescript-eslint/utils@^5.10.0":
@@ -1048,12 +1048,12 @@
"@typescript-eslint/types" "5.62.0"
eslint-visitor-keys "^3.3.0"
"@typescript-eslint/visitor-keys@6.13.1":
version "6.13.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-6.13.1.tgz#c4b692dcc23a4fc60685b718f10fde789d65a540"
integrity sha512-NDhQUy2tg6XGNBGDRm1XybOHSia8mcXmlbKWoQP+nm1BIIMxa55shyJfZkHpEBN62KNPLrocSM2PdPcaLgDKMQ==
"@typescript-eslint/visitor-keys@6.13.2":
version "6.13.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-6.13.2.tgz#e0a4a80cf842bb08e6127b903284166ac4a5594c"
integrity sha512-OGznFs0eAQXJsp+xSd6k/O1UbFi/K/L7WjqeRoFE7vadjAF9y0uppXhYNQNEqygjou782maGClOoZwPqF0Drlw==
dependencies:
"@typescript-eslint/types" "6.13.1"
"@typescript-eslint/types" "6.13.2"
eslint-visitor-keys "^3.4.1"
"@ungap/structured-clone@^1.2.0":
@@ -4047,9 +4047,9 @@ typed-array-length@^1.0.4:
is-typed-array "^1.1.9"
typescript@^5.1.3:
version "5.3.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.3.2.tgz#00d1c7c1c46928c5845c1ee8d0cc2791031d4c43"
integrity sha512-6l+RyNy7oAHDfxC4FzSJcz9vnjTKxrLpDG5M2Vu4SHRVNg6xzqZp6LYSR9zjqQTu8DU/f5xwxUdADOkbrIX2gQ==
version "5.3.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.3.3.tgz#b3ce6ba258e72e6305ba66f5c9b452aaee3ffe37"
integrity sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==
unbox-primitive@^1.0.2:
version "1.0.2"