feat: add option to exclude submodules when detecting changes (#2047)
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
parent
23a449039c
commit
e052d30e1c
21
.github/workflows/test.yml
vendored
21
.github/workflows/test.yml
vendored
@ -682,6 +682,27 @@ jobs:
|
|||||||
echo "${{ toJSON(steps.changed-files.outputs) }}"
|
echo "${{ toJSON(steps.changed-files.outputs) }}"
|
||||||
shell:
|
shell:
|
||||||
bash
|
bash
|
||||||
|
|
||||||
|
- name: Run changed-files excluding submodule
|
||||||
|
id: changed-files-exclude-submodule
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
base_sha: "85bd869"
|
||||||
|
sha: "adde7bb"
|
||||||
|
fetch_depth: 60000
|
||||||
|
exclude_submodules: true
|
||||||
|
|
||||||
|
- name: Verify no added files
|
||||||
|
if: steps.changed-files-exclude-submodule.outputs.added_files != ''
|
||||||
|
run: |
|
||||||
|
echo "Expected: ('') got ${{ steps.changed-files-exclude-submodule.outputs.added_files }}"
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
- name: Show output
|
||||||
|
run: |
|
||||||
|
echo "${{ toJSON(steps.changed-files-exclude-submodule.outputs) }}"
|
||||||
|
shell:
|
||||||
|
bash
|
||||||
test-yaml:
|
test-yaml:
|
||||||
name: Test changed-files with yaml
|
name: Test changed-files with yaml
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -223,6 +223,10 @@ inputs:
|
|||||||
description: "Output changed files in a format that can be used for matrix jobs. Alias for setting inputs `json` to `true` and `escape_json` to `false`."
|
description: "Output changed files in a format that can be used for matrix jobs. Alias for setting inputs `json` to `true` and `escape_json` to `false`."
|
||||||
required: false
|
required: false
|
||||||
default: "false"
|
default: "false"
|
||||||
|
exclude_submodules:
|
||||||
|
description: "Exclude changes to submodules."
|
||||||
|
required: false
|
||||||
|
default: "false"
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
added_files:
|
added_files:
|
||||||
|
53
dist/index.js
generated
vendored
53
dist/index.js
generated
vendored
@ -130,7 +130,7 @@ const processChangedFiles = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
exports.processChangedFiles = processChangedFiles;
|
exports.processChangedFiles = processChangedFiles;
|
||||||
const getRenamedFiles = (_b) => __awaiter(void 0, [_b], void 0, function* ({ inputs, workingDirectory, hasSubmodule, diffResult, submodulePaths }) {
|
const getRenamedFiles = (_b) => __awaiter(void 0, [_b], void 0, function* ({ inputs, workingDirectory, diffSubmodule, diffResult, submodulePaths }) {
|
||||||
const renamedFiles = yield (0, utils_1.gitRenamedFiles)({
|
const renamedFiles = yield (0, utils_1.gitRenamedFiles)({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
sha1: diffResult.previousSha,
|
sha1: diffResult.previousSha,
|
||||||
@ -138,7 +138,7 @@ const getRenamedFiles = (_b) => __awaiter(void 0, [_b], void 0, function* ({ inp
|
|||||||
diff: diffResult.diff,
|
diff: diffResult.diff,
|
||||||
oldNewSeparator: inputs.oldNewSeparator
|
oldNewSeparator: inputs.oldNewSeparator
|
||||||
});
|
});
|
||||||
if (hasSubmodule) {
|
if (diffSubmodule) {
|
||||||
for (const submodulePath of submodulePaths) {
|
for (const submodulePath of submodulePaths) {
|
||||||
const submoduleShaResult = yield (0, utils_1.gitSubmoduleDiffSHA)({
|
const submoduleShaResult = yield (0, utils_1.gitSubmoduleDiffSHA)({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
@ -199,7 +199,7 @@ var ChangeTypeEnum;
|
|||||||
ChangeTypeEnum["Unmerged"] = "U";
|
ChangeTypeEnum["Unmerged"] = "U";
|
||||||
ChangeTypeEnum["Unknown"] = "X";
|
ChangeTypeEnum["Unknown"] = "X";
|
||||||
})(ChangeTypeEnum || (exports.ChangeTypeEnum = ChangeTypeEnum = {}));
|
})(ChangeTypeEnum || (exports.ChangeTypeEnum = ChangeTypeEnum = {}));
|
||||||
const getAllDiffFiles = (_c) => __awaiter(void 0, [_c], void 0, function* ({ workingDirectory, hasSubmodule, diffResult, submodulePaths, outputRenamedFilesAsDeletedAndAdded, fetchAdditionalSubmoduleHistory, failOnInitialDiffError, failOnSubmoduleDiffError }) {
|
const getAllDiffFiles = (_c) => __awaiter(void 0, [_c], void 0, function* ({ workingDirectory, diffSubmodule, diffResult, submodulePaths, outputRenamedFilesAsDeletedAndAdded, fetchAdditionalSubmoduleHistory, failOnInitialDiffError, failOnSubmoduleDiffError }) {
|
||||||
const files = yield (0, utils_1.getAllChangedFiles)({
|
const files = yield (0, utils_1.getAllChangedFiles)({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
sha1: diffResult.previousSha,
|
sha1: diffResult.previousSha,
|
||||||
@ -208,7 +208,7 @@ const getAllDiffFiles = (_c) => __awaiter(void 0, [_c], void 0, function* ({ wor
|
|||||||
outputRenamedFilesAsDeletedAndAdded,
|
outputRenamedFilesAsDeletedAndAdded,
|
||||||
failOnInitialDiffError
|
failOnInitialDiffError
|
||||||
});
|
});
|
||||||
if (hasSubmodule) {
|
if (diffSubmodule) {
|
||||||
for (const submodulePath of submodulePaths) {
|
for (const submodulePath of submodulePaths) {
|
||||||
const submoduleShaResult = yield (0, utils_1.gitSubmoduleDiffSHA)({
|
const submoduleShaResult = yield (0, utils_1.gitSubmoduleDiffSHA)({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
@ -927,7 +927,7 @@ const getCurrentSHA = (_a) => __awaiter(void 0, [_a], void 0, function* ({ input
|
|||||||
core.debug(`Current SHA: ${currentSha}`);
|
core.debug(`Current SHA: ${currentSha}`);
|
||||||
return currentSha;
|
return currentSha;
|
||||||
});
|
});
|
||||||
const getSHAForNonPullRequestEvent = (_j) => __awaiter(void 0, [_j], void 0, function* ({ inputs, env, workingDirectory, isShallow, hasSubmodule, gitFetchExtraArgs, isTag, remoteName }) {
|
const getSHAForNonPullRequestEvent = (_j) => __awaiter(void 0, [_j], void 0, function* ({ inputs, env, workingDirectory, isShallow, diffSubmodule, gitFetchExtraArgs, isTag, remoteName }) {
|
||||||
var _k, _l, _m;
|
var _k, _l, _m;
|
||||||
let targetBranch = env.GITHUB_REF_NAME;
|
let targetBranch = env.GITHUB_REF_NAME;
|
||||||
let currentBranch = targetBranch;
|
let currentBranch = targetBranch;
|
||||||
@ -968,7 +968,7 @@ const getSHAForNonPullRequestEvent = (_j) => __awaiter(void 0, [_j], void 0, fun
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (hasSubmodule) {
|
if (diffSubmodule) {
|
||||||
yield (0, utils_1.gitFetchSubmodules)({
|
yield (0, utils_1.gitFetchSubmodules)({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
args: [
|
args: [
|
||||||
@ -981,7 +981,7 @@ const getSHAForNonPullRequestEvent = (_j) => __awaiter(void 0, [_j], void 0, fun
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (hasSubmodule && inputs.fetchAdditionalSubmoduleHistory) {
|
if (diffSubmodule && inputs.fetchAdditionalSubmoduleHistory) {
|
||||||
yield (0, utils_1.gitFetchSubmodules)({
|
yield (0, utils_1.gitFetchSubmodules)({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
args: [
|
args: [
|
||||||
@ -1107,7 +1107,7 @@ const getSHAForNonPullRequestEvent = (_j) => __awaiter(void 0, [_j], void 0, fun
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
exports.getSHAForNonPullRequestEvent = getSHAForNonPullRequestEvent;
|
exports.getSHAForNonPullRequestEvent = getSHAForNonPullRequestEvent;
|
||||||
const getSHAForPullRequestEvent = (_o) => __awaiter(void 0, [_o], void 0, function* ({ inputs, workingDirectory, isShallow, hasSubmodule, gitFetchExtraArgs, remoteName }) {
|
const getSHAForPullRequestEvent = (_o) => __awaiter(void 0, [_o], void 0, function* ({ inputs, workingDirectory, isShallow, diffSubmodule, gitFetchExtraArgs, remoteName }) {
|
||||||
var _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
var _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
||||||
let targetBranch = (_q = (_p = github.context.payload.pull_request) === null || _p === void 0 ? void 0 : _p.base) === null || _q === void 0 ? void 0 : _q.ref;
|
let targetBranch = (_q = (_p = github.context.payload.pull_request) === null || _p === void 0 ? void 0 : _p.base) === null || _q === void 0 ? void 0 : _q.ref;
|
||||||
const currentBranch = (_s = (_r = github.context.payload.pull_request) === null || _r === void 0 ? void 0 : _r.head) === null || _s === void 0 ? void 0 : _s.ref;
|
const currentBranch = (_s = (_r = github.context.payload.pull_request) === null || _r === void 0 ? void 0 : _r.head) === null || _s === void 0 ? void 0 : _s.ref;
|
||||||
@ -1156,7 +1156,7 @@ const getSHAForPullRequestEvent = (_o) => __awaiter(void 0, [_o], void 0, functi
|
|||||||
`+refs/heads/${targetBranch}:refs/remotes/${remoteName}/${targetBranch}`
|
`+refs/heads/${targetBranch}:refs/remotes/${remoteName}/${targetBranch}`
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
if (hasSubmodule) {
|
if (diffSubmodule) {
|
||||||
yield (0, utils_1.gitFetchSubmodules)({
|
yield (0, utils_1.gitFetchSubmodules)({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
args: [
|
args: [
|
||||||
@ -1170,7 +1170,7 @@ const getSHAForPullRequestEvent = (_o) => __awaiter(void 0, [_o], void 0, functi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (hasSubmodule && inputs.fetchAdditionalSubmoduleHistory) {
|
if (diffSubmodule && inputs.fetchAdditionalSubmoduleHistory) {
|
||||||
yield (0, utils_1.gitFetchSubmodules)({
|
yield (0, utils_1.gitFetchSubmodules)({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
args: [
|
args: [
|
||||||
@ -1374,7 +1374,8 @@ exports.DEFAULT_VALUES_OF_UNSUPPORTED_API_INPUTS = {
|
|||||||
oldNewFilesSeparator: ' ',
|
oldNewFilesSeparator: ' ',
|
||||||
skipInitialFetch: false,
|
skipInitialFetch: false,
|
||||||
fetchAdditionalSubmoduleHistory: false,
|
fetchAdditionalSubmoduleHistory: false,
|
||||||
dirNamesDeletedFilesIncludeOnlyDeletedDirs: false
|
dirNamesDeletedFilesIncludeOnlyDeletedDirs: false,
|
||||||
|
excludeSubmodules: false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -1589,6 +1590,9 @@ const getInputs = () => {
|
|||||||
const useRestApi = core.getBooleanInput('use_rest_api', {
|
const useRestApi = core.getBooleanInput('use_rest_api', {
|
||||||
required: false
|
required: false
|
||||||
});
|
});
|
||||||
|
const excludeSubmodules = core.getBooleanInput('exclude_submodules', {
|
||||||
|
required: false
|
||||||
|
});
|
||||||
const inputs = {
|
const inputs = {
|
||||||
files,
|
files,
|
||||||
filesSeparator,
|
filesSeparator,
|
||||||
@ -1628,6 +1632,7 @@ const getInputs = () => {
|
|||||||
skipInitialFetch,
|
skipInitialFetch,
|
||||||
fetchAdditionalSubmoduleHistory,
|
fetchAdditionalSubmoduleHistory,
|
||||||
dirNamesDeletedFilesIncludeOnlyDeletedDirs,
|
dirNamesDeletedFilesIncludeOnlyDeletedDirs,
|
||||||
|
excludeSubmodules,
|
||||||
// End Not Supported via REST API
|
// End Not Supported via REST API
|
||||||
dirNames,
|
dirNames,
|
||||||
dirNamesExcludeCurrentDir,
|
dirNamesExcludeCurrentDir,
|
||||||
@ -1726,16 +1731,22 @@ const getChangedFilesFromLocalGitHistory = (_a) => __awaiter(void 0, [_a], void
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
const isShallow = yield (0, utils_1.isRepoShallow)({ cwd: workingDirectory });
|
const isShallow = yield (0, utils_1.isRepoShallow)({ cwd: workingDirectory });
|
||||||
const hasSubmodule = yield (0, utils_1.submoduleExists)({ cwd: workingDirectory });
|
let diffSubmodule = false;
|
||||||
let gitFetchExtraArgs = ['--no-tags', '--prune'];
|
let gitFetchExtraArgs = ['--no-tags', '--prune'];
|
||||||
if (hasSubmodule) {
|
if (inputs.excludeSubmodules) {
|
||||||
|
core.info('Excluding submodules from the diff');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
diffSubmodule = yield (0, utils_1.submoduleExists)({ cwd: workingDirectory });
|
||||||
|
}
|
||||||
|
if (diffSubmodule) {
|
||||||
gitFetchExtraArgs.push('--recurse-submodules');
|
gitFetchExtraArgs.push('--recurse-submodules');
|
||||||
}
|
}
|
||||||
const isTag = (_b = env.GITHUB_REF) === null || _b === void 0 ? void 0 : _b.startsWith('refs/tags/');
|
const isTag = (_b = env.GITHUB_REF) === null || _b === void 0 ? void 0 : _b.startsWith('refs/tags/');
|
||||||
const remoteName = 'origin';
|
const remoteName = 'origin';
|
||||||
const outputRenamedFilesAsDeletedAndAdded = inputs.outputRenamedFilesAsDeletedAndAdded;
|
const outputRenamedFilesAsDeletedAndAdded = inputs.outputRenamedFilesAsDeletedAndAdded;
|
||||||
let submodulePaths = [];
|
let submodulePaths = [];
|
||||||
if (hasSubmodule) {
|
if (diffSubmodule) {
|
||||||
submodulePaths = yield (0, utils_1.getSubmodulePath)({ cwd: workingDirectory });
|
submodulePaths = yield (0, utils_1.getSubmodulePath)({ cwd: workingDirectory });
|
||||||
}
|
}
|
||||||
if (isTag) {
|
if (isTag) {
|
||||||
@ -1749,7 +1760,7 @@ const getChangedFilesFromLocalGitHistory = (_a) => __awaiter(void 0, [_a], void
|
|||||||
env,
|
env,
|
||||||
workingDirectory,
|
workingDirectory,
|
||||||
isShallow,
|
isShallow,
|
||||||
hasSubmodule,
|
diffSubmodule,
|
||||||
gitFetchExtraArgs,
|
gitFetchExtraArgs,
|
||||||
isTag,
|
isTag,
|
||||||
remoteName
|
remoteName
|
||||||
@ -1761,7 +1772,7 @@ const getChangedFilesFromLocalGitHistory = (_a) => __awaiter(void 0, [_a], void
|
|||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
workingDirectory,
|
||||||
isShallow,
|
isShallow,
|
||||||
hasSubmodule,
|
diffSubmodule,
|
||||||
gitFetchExtraArgs,
|
gitFetchExtraArgs,
|
||||||
remoteName
|
remoteName
|
||||||
});
|
});
|
||||||
@ -1774,7 +1785,7 @@ const getChangedFilesFromLocalGitHistory = (_a) => __awaiter(void 0, [_a], void
|
|||||||
core.info(`Retrieving changes between ${diffResult.previousSha} (${diffResult.targetBranch}) → ${diffResult.currentSha} (${diffResult.currentBranch})`);
|
core.info(`Retrieving changes between ${diffResult.previousSha} (${diffResult.targetBranch}) → ${diffResult.currentSha} (${diffResult.currentBranch})`);
|
||||||
const allDiffFiles = yield (0, changedFiles_1.getAllDiffFiles)({
|
const allDiffFiles = yield (0, changedFiles_1.getAllDiffFiles)({
|
||||||
workingDirectory,
|
workingDirectory,
|
||||||
hasSubmodule,
|
diffSubmodule,
|
||||||
diffResult,
|
diffResult,
|
||||||
submodulePaths,
|
submodulePaths,
|
||||||
outputRenamedFilesAsDeletedAndAdded,
|
outputRenamedFilesAsDeletedAndAdded,
|
||||||
@ -1797,7 +1808,7 @@ const getChangedFilesFromLocalGitHistory = (_a) => __awaiter(void 0, [_a], void
|
|||||||
deletedFiles: allDiffFiles[changedFiles_1.ChangeTypeEnum.Deleted],
|
deletedFiles: allDiffFiles[changedFiles_1.ChangeTypeEnum.Deleted],
|
||||||
recoverPatterns,
|
recoverPatterns,
|
||||||
diffResult,
|
diffResult,
|
||||||
hasSubmodule,
|
diffSubmodule,
|
||||||
submodulePaths
|
submodulePaths
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1813,7 +1824,7 @@ const getChangedFilesFromLocalGitHistory = (_a) => __awaiter(void 0, [_a], void
|
|||||||
const allOldNewRenamedFiles = yield (0, changedFiles_1.getRenamedFiles)({
|
const allOldNewRenamedFiles = yield (0, changedFiles_1.getRenamedFiles)({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
workingDirectory,
|
||||||
hasSubmodule,
|
diffSubmodule,
|
||||||
diffResult,
|
diffResult,
|
||||||
submodulePaths
|
submodulePaths
|
||||||
});
|
});
|
||||||
@ -2900,7 +2911,7 @@ const getDeletedFileContents = (_13) => __awaiter(void 0, [_13], void 0, functio
|
|||||||
}
|
}
|
||||||
return stdout;
|
return stdout;
|
||||||
});
|
});
|
||||||
const recoverDeletedFiles = (_14) => __awaiter(void 0, [_14], void 0, function* ({ inputs, workingDirectory, deletedFiles, recoverPatterns, diffResult, hasSubmodule, submodulePaths }) {
|
const recoverDeletedFiles = (_14) => __awaiter(void 0, [_14], void 0, function* ({ inputs, workingDirectory, deletedFiles, recoverPatterns, diffResult, diffSubmodule, submodulePaths }) {
|
||||||
let recoverableDeletedFiles = deletedFiles;
|
let recoverableDeletedFiles = deletedFiles;
|
||||||
core.debug(`recoverable deleted files: ${recoverableDeletedFiles}`);
|
core.debug(`recoverable deleted files: ${recoverableDeletedFiles}`);
|
||||||
if (recoverPatterns.length > 0) {
|
if (recoverPatterns.length > 0) {
|
||||||
@ -2918,7 +2929,7 @@ const recoverDeletedFiles = (_14) => __awaiter(void 0, [_14], void 0, function*
|
|||||||
}
|
}
|
||||||
let deletedFileContents;
|
let deletedFileContents;
|
||||||
const submodulePath = submodulePaths.find(p => deletedFile.startsWith(p));
|
const submodulePath = submodulePaths.find(p => deletedFile.startsWith(p));
|
||||||
if (hasSubmodule && submodulePath) {
|
if (diffSubmodule && submodulePath) {
|
||||||
const submoduleShaResult = yield (0, exports.gitSubmoduleDiffSHA)({
|
const submoduleShaResult = yield (0, exports.gitSubmoduleDiffSHA)({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
parentSha1: diffResult.previousSha,
|
parentSha1: diffResult.previousSha,
|
||||||
|
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
@ -14,6 +14,7 @@
|
|||||||
"lint:fix": "eslint --fix src/*.ts src/**/*.ts",
|
"lint:fix": "eslint --fix src/*.ts src/**/*.ts",
|
||||||
"package": "ncc build lib/main.js --source-map --license licenses.txt",
|
"package": "ncc build lib/main.js --source-map --license licenses.txt",
|
||||||
"test": "jest --coverage",
|
"test": "jest --coverage",
|
||||||
|
"update-snapshot": "jest -u",
|
||||||
"all": "yarn build && yarn format && yarn lint && yarn package && yarn test"
|
"all": "yarn build && yarn format && yarn lint && yarn package && yarn test"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -2,55 +2,58 @@
|
|||||||
|
|
||||||
exports[`getInputs should correctly parse boolean inputs 1`] = `
|
exports[`getInputs should correctly parse boolean inputs 1`] = `
|
||||||
{
|
{
|
||||||
"apiUrl": undefined,
|
"apiUrl": "",
|
||||||
"baseSha": undefined,
|
"baseSha": "",
|
||||||
"diffRelative": "false",
|
"diffRelative": "false",
|
||||||
"dirNames": "false",
|
"dirNames": "false",
|
||||||
"dirNamesDeletedFilesIncludeOnlyDeletedDirs": "false",
|
"dirNamesDeletedFilesIncludeOnlyDeletedDirs": "false",
|
||||||
"dirNamesExcludeCurrentDir": "false",
|
"dirNamesExcludeCurrentDir": "false",
|
||||||
"dirNamesIncludeFiles": undefined,
|
"dirNamesIncludeFiles": "",
|
||||||
"dirNamesIncludeFilesSeparator": undefined,
|
"dirNamesIncludeFilesSeparator": "",
|
||||||
"escapeJson": false,
|
"escapeJson": false,
|
||||||
|
"excludeSubmodules": "false",
|
||||||
"failOnInitialDiffError": "false",
|
"failOnInitialDiffError": "false",
|
||||||
"failOnSubmoduleDiffError": "false",
|
"failOnSubmoduleDiffError": "false",
|
||||||
"fetchAdditionalSubmoduleHistory": "false",
|
"fetchAdditionalSubmoduleHistory": "false",
|
||||||
"files": undefined,
|
"files": "",
|
||||||
"filesFromSourceFile": undefined,
|
"filesFromSourceFile": "",
|
||||||
"filesFromSourceFileSeparator": undefined,
|
"filesFromSourceFileSeparator": "",
|
||||||
"filesIgnore": undefined,
|
"filesIgnore": "",
|
||||||
"filesIgnoreFromSourceFile": undefined,
|
"filesIgnoreFromSourceFile": "",
|
||||||
"filesIgnoreFromSourceFileSeparator": undefined,
|
"filesIgnoreFromSourceFileSeparator": "",
|
||||||
"filesIgnoreSeparator": undefined,
|
"filesIgnoreSeparator": "",
|
||||||
"filesIgnoreYaml": undefined,
|
"filesIgnoreYaml": "",
|
||||||
"filesIgnoreYamlFromSourceFile": undefined,
|
"filesIgnoreYamlFromSourceFile": "",
|
||||||
"filesIgnoreYamlFromSourceFileSeparator": undefined,
|
"filesIgnoreYamlFromSourceFileSeparator": "",
|
||||||
"filesSeparator": undefined,
|
"filesSeparator": "",
|
||||||
"filesYaml": undefined,
|
"filesYaml": "",
|
||||||
"filesYamlFromSourceFile": undefined,
|
"filesYamlFromSourceFile": "",
|
||||||
"filesYamlFromSourceFileSeparator": undefined,
|
"filesYamlFromSourceFileSeparator": "",
|
||||||
"includeAllOldNewRenamedFiles": "false",
|
"includeAllOldNewRenamedFiles": "false",
|
||||||
"json": true,
|
"json": true,
|
||||||
"negationPatternsFirst": "false",
|
"negationPatternsFirst": "false",
|
||||||
"oldNewFilesSeparator": undefined,
|
"oldNewFilesSeparator": " ",
|
||||||
"oldNewSeparator": undefined,
|
"oldNewSeparator": ",",
|
||||||
"outputDir": undefined,
|
"outputDir": "",
|
||||||
"outputRenamedFilesAsDeletedAndAdded": "false",
|
"outputRenamedFilesAsDeletedAndAdded": "false",
|
||||||
"path": undefined,
|
"path": ".",
|
||||||
"quotepath": "false",
|
"quotepath": "false",
|
||||||
"recoverDeletedFiles": "false",
|
"recoverDeletedFiles": "false",
|
||||||
"recoverDeletedFilesToDestination": undefined,
|
"recoverDeletedFilesToDestination": "",
|
||||||
"recoverFiles": undefined,
|
"recoverFiles": "",
|
||||||
"recoverFilesIgnore": undefined,
|
"recoverFilesIgnore": "",
|
||||||
"recoverFilesIgnoreSeparator": undefined,
|
"recoverFilesIgnoreSeparator": "
|
||||||
"recoverFilesSeparator": undefined,
|
",
|
||||||
|
"recoverFilesSeparator": "
|
||||||
|
",
|
||||||
"safeOutput": "false",
|
"safeOutput": "false",
|
||||||
"separator": undefined,
|
"separator": "",
|
||||||
"sha": undefined,
|
"sha": "",
|
||||||
"since": undefined,
|
"since": "",
|
||||||
"sinceLastRemoteCommit": "false",
|
"sinceLastRemoteCommit": "false",
|
||||||
"skipInitialFetch": "true",
|
"skipInitialFetch": "true",
|
||||||
"token": undefined,
|
"token": "",
|
||||||
"until": undefined,
|
"until": "",
|
||||||
"useRestApi": "false",
|
"useRestApi": "false",
|
||||||
"writeOutputFiles": "false",
|
"writeOutputFiles": "false",
|
||||||
}
|
}
|
||||||
@ -68,6 +71,7 @@ exports[`getInputs should correctly parse numeric inputs 1`] = `
|
|||||||
"dirNamesIncludeFilesSeparator": "",
|
"dirNamesIncludeFilesSeparator": "",
|
||||||
"dirNamesMaxDepth": 2,
|
"dirNamesMaxDepth": 2,
|
||||||
"escapeJson": false,
|
"escapeJson": false,
|
||||||
|
"excludeSubmodules": false,
|
||||||
"failOnInitialDiffError": false,
|
"failOnInitialDiffError": false,
|
||||||
"failOnSubmoduleDiffError": false,
|
"failOnSubmoduleDiffError": false,
|
||||||
"fetchAdditionalSubmoduleHistory": false,
|
"fetchAdditionalSubmoduleHistory": false,
|
||||||
@ -125,6 +129,7 @@ exports[`getInputs should correctly parse string inputs 1`] = `
|
|||||||
"dirNamesIncludeFiles": "",
|
"dirNamesIncludeFiles": "",
|
||||||
"dirNamesIncludeFilesSeparator": "",
|
"dirNamesIncludeFilesSeparator": "",
|
||||||
"escapeJson": false,
|
"escapeJson": false,
|
||||||
|
"excludeSubmodules": false,
|
||||||
"failOnInitialDiffError": false,
|
"failOnInitialDiffError": false,
|
||||||
"failOnSubmoduleDiffError": false,
|
"failOnSubmoduleDiffError": false,
|
||||||
"fetchAdditionalSubmoduleHistory": false,
|
"fetchAdditionalSubmoduleHistory": false,
|
||||||
@ -182,6 +187,7 @@ exports[`getInputs should handle invalid numeric inputs correctly 1`] = `
|
|||||||
"dirNamesIncludeFilesSeparator": "",
|
"dirNamesIncludeFilesSeparator": "",
|
||||||
"dirNamesMaxDepth": 2,
|
"dirNamesMaxDepth": 2,
|
||||||
"escapeJson": false,
|
"escapeJson": false,
|
||||||
|
"excludeSubmodules": false,
|
||||||
"failOnInitialDiffError": false,
|
"failOnInitialDiffError": false,
|
||||||
"failOnSubmoduleDiffError": false,
|
"failOnSubmoduleDiffError": false,
|
||||||
"fetchAdditionalSubmoduleHistory": false,
|
"fetchAdditionalSubmoduleHistory": false,
|
||||||
@ -240,6 +246,7 @@ exports[`getInputs should handle negative numeric inputs correctly 1`] = `
|
|||||||
"dirNamesIncludeFilesSeparator": "",
|
"dirNamesIncludeFilesSeparator": "",
|
||||||
"dirNamesMaxDepth": -2,
|
"dirNamesMaxDepth": -2,
|
||||||
"escapeJson": false,
|
"escapeJson": false,
|
||||||
|
"excludeSubmodules": false,
|
||||||
"failOnInitialDiffError": false,
|
"failOnInitialDiffError": false,
|
||||||
"failOnSubmoduleDiffError": false,
|
"failOnSubmoduleDiffError": false,
|
||||||
"fetchAdditionalSubmoduleHistory": false,
|
"fetchAdditionalSubmoduleHistory": false,
|
||||||
@ -288,55 +295,58 @@ exports[`getInputs should handle negative numeric inputs correctly 1`] = `
|
|||||||
|
|
||||||
exports[`getInputs should return default values when no inputs are provided 1`] = `
|
exports[`getInputs should return default values when no inputs are provided 1`] = `
|
||||||
{
|
{
|
||||||
"apiUrl": undefined,
|
"apiUrl": "",
|
||||||
"baseSha": undefined,
|
"baseSha": "",
|
||||||
"diffRelative": true,
|
"diffRelative": true,
|
||||||
"dirNames": false,
|
"dirNames": false,
|
||||||
"dirNamesDeletedFilesIncludeOnlyDeletedDirs": false,
|
"dirNamesDeletedFilesIncludeOnlyDeletedDirs": false,
|
||||||
"dirNamesExcludeCurrentDir": false,
|
"dirNamesExcludeCurrentDir": false,
|
||||||
"dirNamesIncludeFiles": undefined,
|
"dirNamesIncludeFiles": "",
|
||||||
"dirNamesIncludeFilesSeparator": undefined,
|
"dirNamesIncludeFilesSeparator": "",
|
||||||
"escapeJson": false,
|
"escapeJson": false,
|
||||||
|
"excludeSubmodules": false,
|
||||||
"failOnInitialDiffError": false,
|
"failOnInitialDiffError": false,
|
||||||
"failOnSubmoduleDiffError": false,
|
"failOnSubmoduleDiffError": false,
|
||||||
"fetchAdditionalSubmoduleHistory": false,
|
"fetchAdditionalSubmoduleHistory": false,
|
||||||
"files": undefined,
|
"files": "",
|
||||||
"filesFromSourceFile": undefined,
|
"filesFromSourceFile": "",
|
||||||
"filesFromSourceFileSeparator": undefined,
|
"filesFromSourceFileSeparator": "",
|
||||||
"filesIgnore": undefined,
|
"filesIgnore": "",
|
||||||
"filesIgnoreFromSourceFile": undefined,
|
"filesIgnoreFromSourceFile": "",
|
||||||
"filesIgnoreFromSourceFileSeparator": undefined,
|
"filesIgnoreFromSourceFileSeparator": "",
|
||||||
"filesIgnoreSeparator": undefined,
|
"filesIgnoreSeparator": "",
|
||||||
"filesIgnoreYaml": undefined,
|
"filesIgnoreYaml": "",
|
||||||
"filesIgnoreYamlFromSourceFile": undefined,
|
"filesIgnoreYamlFromSourceFile": "",
|
||||||
"filesIgnoreYamlFromSourceFileSeparator": undefined,
|
"filesIgnoreYamlFromSourceFileSeparator": "",
|
||||||
"filesSeparator": undefined,
|
"filesSeparator": "",
|
||||||
"filesYaml": undefined,
|
"filesYaml": "",
|
||||||
"filesYamlFromSourceFile": undefined,
|
"filesYamlFromSourceFile": "",
|
||||||
"filesYamlFromSourceFileSeparator": undefined,
|
"filesYamlFromSourceFileSeparator": "",
|
||||||
"includeAllOldNewRenamedFiles": false,
|
"includeAllOldNewRenamedFiles": false,
|
||||||
"json": false,
|
"json": false,
|
||||||
"negationPatternsFirst": false,
|
"negationPatternsFirst": false,
|
||||||
"oldNewFilesSeparator": undefined,
|
"oldNewFilesSeparator": " ",
|
||||||
"oldNewSeparator": undefined,
|
"oldNewSeparator": ",",
|
||||||
"outputDir": undefined,
|
"outputDir": "",
|
||||||
"outputRenamedFilesAsDeletedAndAdded": false,
|
"outputRenamedFilesAsDeletedAndAdded": false,
|
||||||
"path": undefined,
|
"path": ".",
|
||||||
"quotepath": true,
|
"quotepath": true,
|
||||||
"recoverDeletedFiles": false,
|
"recoverDeletedFiles": false,
|
||||||
"recoverDeletedFilesToDestination": undefined,
|
"recoverDeletedFilesToDestination": "",
|
||||||
"recoverFiles": undefined,
|
"recoverFiles": "",
|
||||||
"recoverFilesIgnore": undefined,
|
"recoverFilesIgnore": "",
|
||||||
"recoverFilesIgnoreSeparator": undefined,
|
"recoverFilesIgnoreSeparator": "
|
||||||
"recoverFilesSeparator": undefined,
|
",
|
||||||
|
"recoverFilesSeparator": "
|
||||||
|
",
|
||||||
"safeOutput": false,
|
"safeOutput": false,
|
||||||
"separator": undefined,
|
"separator": "",
|
||||||
"sha": undefined,
|
"sha": "",
|
||||||
"since": undefined,
|
"since": "",
|
||||||
"sinceLastRemoteCommit": false,
|
"sinceLastRemoteCommit": false,
|
||||||
"skipInitialFetch": false,
|
"skipInitialFetch": false,
|
||||||
"token": undefined,
|
"token": "",
|
||||||
"until": undefined,
|
"until": "",
|
||||||
"useRestApi": false,
|
"useRestApi": false,
|
||||||
"writeOutputFiles": false,
|
"writeOutputFiles": false,
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ describe('getInputs', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('should return default values when no inputs are provided', () => {
|
test('should return default values when no inputs are provided', () => {
|
||||||
;(core.getBooleanInput as jest.Mock).mockImplementation(name => {
|
;(core.getInput as jest.Mock).mockImplementation(name => {
|
||||||
const camelCaseName = name.replace(/_([a-z])/g, (g: string[]) => {
|
const camelCaseName = name.replace(/_([a-z])/g, (g: string[]) => {
|
||||||
return g[1].toUpperCase()
|
return g[1].toUpperCase()
|
||||||
}) as keyof Inputs
|
}) as keyof Inputs
|
||||||
@ -30,7 +30,7 @@ describe('getInputs', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('should correctly parse boolean inputs', () => {
|
test('should correctly parse boolean inputs', () => {
|
||||||
;(core.getBooleanInput as jest.Mock).mockImplementation(name => {
|
;(core.getInput as jest.Mock).mockImplementation(name => {
|
||||||
const camelCaseName = name.replace(/_([a-z])/g, (g: string[]) => {
|
const camelCaseName = name.replace(/_([a-z])/g, (g: string[]) => {
|
||||||
return g[1].toUpperCase()
|
return g[1].toUpperCase()
|
||||||
}) as keyof Inputs
|
}) as keyof Inputs
|
||||||
|
@ -635,7 +635,8 @@ describe('utils test', () => {
|
|||||||
failOnInitialDiffError: false,
|
failOnInitialDiffError: false,
|
||||||
failOnSubmoduleDiffError: false,
|
failOnSubmoduleDiffError: false,
|
||||||
negationPatternsFirst: false,
|
negationPatternsFirst: false,
|
||||||
useRestApi: false
|
useRestApi: false,
|
||||||
|
excludeSubmodules: false
|
||||||
}
|
}
|
||||||
|
|
||||||
const coreWarningSpy = jest.spyOn(core, 'warning')
|
const coreWarningSpy = jest.spyOn(core, 'warning')
|
||||||
|
@ -121,13 +121,13 @@ export const processChangedFiles = async ({
|
|||||||
export const getRenamedFiles = async ({
|
export const getRenamedFiles = async ({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
workingDirectory,
|
||||||
hasSubmodule,
|
diffSubmodule,
|
||||||
diffResult,
|
diffResult,
|
||||||
submodulePaths
|
submodulePaths
|
||||||
}: {
|
}: {
|
||||||
inputs: Inputs
|
inputs: Inputs
|
||||||
workingDirectory: string
|
workingDirectory: string
|
||||||
hasSubmodule: boolean
|
diffSubmodule: boolean
|
||||||
diffResult: DiffResult
|
diffResult: DiffResult
|
||||||
submodulePaths: string[]
|
submodulePaths: string[]
|
||||||
}): Promise<{paths: string; count: string}> => {
|
}): Promise<{paths: string; count: string}> => {
|
||||||
@ -139,7 +139,7 @@ export const getRenamedFiles = async ({
|
|||||||
oldNewSeparator: inputs.oldNewSeparator
|
oldNewSeparator: inputs.oldNewSeparator
|
||||||
})
|
})
|
||||||
|
|
||||||
if (hasSubmodule) {
|
if (diffSubmodule) {
|
||||||
for (const submodulePath of submodulePaths) {
|
for (const submodulePath of submodulePaths) {
|
||||||
const submoduleShaResult = await gitSubmoduleDiffSHA({
|
const submoduleShaResult = await gitSubmoduleDiffSHA({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
@ -217,7 +217,7 @@ export type ChangedFiles = {
|
|||||||
|
|
||||||
export const getAllDiffFiles = async ({
|
export const getAllDiffFiles = async ({
|
||||||
workingDirectory,
|
workingDirectory,
|
||||||
hasSubmodule,
|
diffSubmodule,
|
||||||
diffResult,
|
diffResult,
|
||||||
submodulePaths,
|
submodulePaths,
|
||||||
outputRenamedFilesAsDeletedAndAdded,
|
outputRenamedFilesAsDeletedAndAdded,
|
||||||
@ -226,7 +226,7 @@ export const getAllDiffFiles = async ({
|
|||||||
failOnSubmoduleDiffError
|
failOnSubmoduleDiffError
|
||||||
}: {
|
}: {
|
||||||
workingDirectory: string
|
workingDirectory: string
|
||||||
hasSubmodule: boolean
|
diffSubmodule: boolean
|
||||||
diffResult: DiffResult
|
diffResult: DiffResult
|
||||||
submodulePaths: string[]
|
submodulePaths: string[]
|
||||||
outputRenamedFilesAsDeletedAndAdded: boolean
|
outputRenamedFilesAsDeletedAndAdded: boolean
|
||||||
@ -243,7 +243,7 @@ export const getAllDiffFiles = async ({
|
|||||||
failOnInitialDiffError
|
failOnInitialDiffError
|
||||||
})
|
})
|
||||||
|
|
||||||
if (hasSubmodule) {
|
if (diffSubmodule) {
|
||||||
for (const submodulePath of submodulePaths) {
|
for (const submodulePath of submodulePaths) {
|
||||||
const submoduleShaResult = await gitSubmoduleDiffSHA({
|
const submoduleShaResult = await gitSubmoduleDiffSHA({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
|
@ -91,7 +91,7 @@ interface SHAForNonPullRequestEvent {
|
|||||||
env: Env
|
env: Env
|
||||||
workingDirectory: string
|
workingDirectory: string
|
||||||
isShallow: boolean
|
isShallow: boolean
|
||||||
hasSubmodule: boolean
|
diffSubmodule: boolean
|
||||||
gitFetchExtraArgs: string[]
|
gitFetchExtraArgs: string[]
|
||||||
isTag: boolean
|
isTag: boolean
|
||||||
remoteName: string
|
remoteName: string
|
||||||
@ -102,7 +102,7 @@ export const getSHAForNonPullRequestEvent = async ({
|
|||||||
env,
|
env,
|
||||||
workingDirectory,
|
workingDirectory,
|
||||||
isShallow,
|
isShallow,
|
||||||
hasSubmodule,
|
diffSubmodule,
|
||||||
gitFetchExtraArgs,
|
gitFetchExtraArgs,
|
||||||
isTag,
|
isTag,
|
||||||
remoteName
|
remoteName
|
||||||
@ -152,7 +152,7 @@ export const getSHAForNonPullRequestEvent = async ({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasSubmodule) {
|
if (diffSubmodule) {
|
||||||
await gitFetchSubmodules({
|
await gitFetchSubmodules({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
args: [
|
args: [
|
||||||
@ -164,7 +164,7 @@ export const getSHAForNonPullRequestEvent = async ({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (hasSubmodule && inputs.fetchAdditionalSubmoduleHistory) {
|
if (diffSubmodule && inputs.fetchAdditionalSubmoduleHistory) {
|
||||||
await gitFetchSubmodules({
|
await gitFetchSubmodules({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
args: [
|
args: [
|
||||||
@ -323,7 +323,7 @@ interface SHAForPullRequestEvent {
|
|||||||
inputs: Inputs
|
inputs: Inputs
|
||||||
workingDirectory: string
|
workingDirectory: string
|
||||||
isShallow: boolean
|
isShallow: boolean
|
||||||
hasSubmodule: boolean
|
diffSubmodule: boolean
|
||||||
gitFetchExtraArgs: string[]
|
gitFetchExtraArgs: string[]
|
||||||
remoteName: string
|
remoteName: string
|
||||||
}
|
}
|
||||||
@ -332,7 +332,7 @@ export const getSHAForPullRequestEvent = async ({
|
|||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
workingDirectory,
|
||||||
isShallow,
|
isShallow,
|
||||||
hasSubmodule,
|
diffSubmodule,
|
||||||
gitFetchExtraArgs,
|
gitFetchExtraArgs,
|
||||||
remoteName
|
remoteName
|
||||||
}: SHAForPullRequestEvent): Promise<DiffResult> => {
|
}: SHAForPullRequestEvent): Promise<DiffResult> => {
|
||||||
@ -390,7 +390,7 @@ export const getSHAForPullRequestEvent = async ({
|
|||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
if (hasSubmodule) {
|
if (diffSubmodule) {
|
||||||
await gitFetchSubmodules({
|
await gitFetchSubmodules({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
args: [
|
args: [
|
||||||
@ -403,7 +403,7 @@ export const getSHAForPullRequestEvent = async ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (hasSubmodule && inputs.fetchAdditionalSubmoduleHistory) {
|
if (diffSubmodule && inputs.fetchAdditionalSubmoduleHistory) {
|
||||||
await gitFetchSubmodules({
|
await gitFetchSubmodules({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
args: [
|
args: [
|
||||||
|
@ -20,5 +20,6 @@ export const DEFAULT_VALUES_OF_UNSUPPORTED_API_INPUTS: Partial<Inputs> = {
|
|||||||
oldNewFilesSeparator: ' ',
|
oldNewFilesSeparator: ' ',
|
||||||
skipInitialFetch: false,
|
skipInitialFetch: false,
|
||||||
fetchAdditionalSubmoduleHistory: false,
|
fetchAdditionalSubmoduleHistory: false,
|
||||||
dirNamesDeletedFilesIncludeOnlyDeletedDirs: false
|
dirNamesDeletedFilesIncludeOnlyDeletedDirs: false,
|
||||||
|
excludeSubmodules: false
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,7 @@ export type Inputs = {
|
|||||||
failOnSubmoduleDiffError: boolean
|
failOnSubmoduleDiffError: boolean
|
||||||
negationPatternsFirst: boolean
|
negationPatternsFirst: boolean
|
||||||
useRestApi: boolean
|
useRestApi: boolean
|
||||||
|
excludeSubmodules: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getInputs = (): Inputs => {
|
export const getInputs = (): Inputs => {
|
||||||
@ -240,6 +241,10 @@ export const getInputs = (): Inputs => {
|
|||||||
required: false
|
required: false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const excludeSubmodules = core.getBooleanInput('exclude_submodules', {
|
||||||
|
required: false
|
||||||
|
})
|
||||||
|
|
||||||
const inputs: Inputs = {
|
const inputs: Inputs = {
|
||||||
files,
|
files,
|
||||||
filesSeparator,
|
filesSeparator,
|
||||||
@ -279,6 +284,7 @@ export const getInputs = (): Inputs => {
|
|||||||
skipInitialFetch,
|
skipInitialFetch,
|
||||||
fetchAdditionalSubmoduleHistory,
|
fetchAdditionalSubmoduleHistory,
|
||||||
dirNamesDeletedFilesIncludeOnlyDeletedDirs,
|
dirNamesDeletedFilesIncludeOnlyDeletedDirs,
|
||||||
|
excludeSubmodules,
|
||||||
// End Not Supported via REST API
|
// End Not Supported via REST API
|
||||||
dirNames,
|
dirNames,
|
||||||
dirNamesExcludeCurrentDir,
|
dirNamesExcludeCurrentDir,
|
||||||
|
22
src/main.ts
22
src/main.ts
@ -64,10 +64,16 @@ const getChangedFilesFromLocalGitHistory = async ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const isShallow = await isRepoShallow({cwd: workingDirectory})
|
const isShallow = await isRepoShallow({cwd: workingDirectory})
|
||||||
const hasSubmodule = await submoduleExists({cwd: workingDirectory})
|
let diffSubmodule = false
|
||||||
let gitFetchExtraArgs = ['--no-tags', '--prune']
|
let gitFetchExtraArgs = ['--no-tags', '--prune']
|
||||||
|
|
||||||
if (hasSubmodule) {
|
if (inputs.excludeSubmodules) {
|
||||||
|
core.info('Excluding submodules from the diff')
|
||||||
|
} else {
|
||||||
|
diffSubmodule = await submoduleExists({cwd: workingDirectory})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (diffSubmodule) {
|
||||||
gitFetchExtraArgs.push('--recurse-submodules')
|
gitFetchExtraArgs.push('--recurse-submodules')
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +83,7 @@ const getChangedFilesFromLocalGitHistory = async ({
|
|||||||
inputs.outputRenamedFilesAsDeletedAndAdded
|
inputs.outputRenamedFilesAsDeletedAndAdded
|
||||||
let submodulePaths: string[] = []
|
let submodulePaths: string[] = []
|
||||||
|
|
||||||
if (hasSubmodule) {
|
if (diffSubmodule) {
|
||||||
submodulePaths = await getSubmodulePath({cwd: workingDirectory})
|
submodulePaths = await getSubmodulePath({cwd: workingDirectory})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +100,7 @@ const getChangedFilesFromLocalGitHistory = async ({
|
|||||||
env,
|
env,
|
||||||
workingDirectory,
|
workingDirectory,
|
||||||
isShallow,
|
isShallow,
|
||||||
hasSubmodule,
|
diffSubmodule,
|
||||||
gitFetchExtraArgs,
|
gitFetchExtraArgs,
|
||||||
isTag,
|
isTag,
|
||||||
remoteName
|
remoteName
|
||||||
@ -109,7 +115,7 @@ const getChangedFilesFromLocalGitHistory = async ({
|
|||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
workingDirectory,
|
||||||
isShallow,
|
isShallow,
|
||||||
hasSubmodule,
|
diffSubmodule,
|
||||||
gitFetchExtraArgs,
|
gitFetchExtraArgs,
|
||||||
remoteName
|
remoteName
|
||||||
})
|
})
|
||||||
@ -127,7 +133,7 @@ const getChangedFilesFromLocalGitHistory = async ({
|
|||||||
|
|
||||||
const allDiffFiles = await getAllDiffFiles({
|
const allDiffFiles = await getAllDiffFiles({
|
||||||
workingDirectory,
|
workingDirectory,
|
||||||
hasSubmodule,
|
diffSubmodule,
|
||||||
diffResult,
|
diffResult,
|
||||||
submodulePaths,
|
submodulePaths,
|
||||||
outputRenamedFilesAsDeletedAndAdded,
|
outputRenamedFilesAsDeletedAndAdded,
|
||||||
@ -153,7 +159,7 @@ const getChangedFilesFromLocalGitHistory = async ({
|
|||||||
deletedFiles: allDiffFiles[ChangeTypeEnum.Deleted],
|
deletedFiles: allDiffFiles[ChangeTypeEnum.Deleted],
|
||||||
recoverPatterns,
|
recoverPatterns,
|
||||||
diffResult,
|
diffResult,
|
||||||
hasSubmodule,
|
diffSubmodule,
|
||||||
submodulePaths
|
submodulePaths
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -171,7 +177,7 @@ const getChangedFilesFromLocalGitHistory = async ({
|
|||||||
const allOldNewRenamedFiles = await getRenamedFiles({
|
const allOldNewRenamedFiles = await getRenamedFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
workingDirectory,
|
||||||
hasSubmodule,
|
diffSubmodule,
|
||||||
diffResult,
|
diffResult,
|
||||||
submodulePaths
|
submodulePaths
|
||||||
})
|
})
|
||||||
|
@ -1413,7 +1413,7 @@ export const recoverDeletedFiles = async ({
|
|||||||
deletedFiles,
|
deletedFiles,
|
||||||
recoverPatterns,
|
recoverPatterns,
|
||||||
diffResult,
|
diffResult,
|
||||||
hasSubmodule,
|
diffSubmodule,
|
||||||
submodulePaths
|
submodulePaths
|
||||||
}: {
|
}: {
|
||||||
inputs: Inputs
|
inputs: Inputs
|
||||||
@ -1421,7 +1421,7 @@ export const recoverDeletedFiles = async ({
|
|||||||
deletedFiles: string[]
|
deletedFiles: string[]
|
||||||
recoverPatterns: string[]
|
recoverPatterns: string[]
|
||||||
diffResult: DiffResult
|
diffResult: DiffResult
|
||||||
hasSubmodule: boolean
|
diffSubmodule: boolean
|
||||||
submodulePaths: string[]
|
submodulePaths: string[]
|
||||||
}): Promise<void> => {
|
}): Promise<void> => {
|
||||||
let recoverableDeletedFiles = deletedFiles
|
let recoverableDeletedFiles = deletedFiles
|
||||||
@ -1451,7 +1451,7 @@ export const recoverDeletedFiles = async ({
|
|||||||
|
|
||||||
const submodulePath = submodulePaths.find(p => deletedFile.startsWith(p))
|
const submodulePath = submodulePaths.find(p => deletedFile.startsWith(p))
|
||||||
|
|
||||||
if (hasSubmodule && submodulePath) {
|
if (diffSubmodule && submodulePath) {
|
||||||
const submoduleShaResult = await gitSubmoduleDiffSHA({
|
const submoduleShaResult = await gitSubmoduleDiffSHA({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
parentSha1: diffResult.previousSha,
|
parentSha1: diffResult.previousSha,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user