fix/resolve bug fetching more history (#1176)
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
		
							parent
							
								
									77f872a759
								
							
						
					
					
						commit
						25eaddf37a
					
				
							
								
								
									
										10
									
								
								.github/workflows/test.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								.github/workflows/test.yml
									
									
									
									
										vendored
									
									
								
							| @ -689,16 +689,16 @@ jobs: | |||||||
|           echo '${{ toJSON(steps.changed-files-json.outputs.all_changed_files) }}' |           echo '${{ toJSON(steps.changed-files-json.outputs.all_changed_files) }}' | ||||||
|         shell: |         shell: | ||||||
|           bash |           bash | ||||||
|       - name: Run changed-files with json raw format |       - name: Run changed-files with json unescaped format | ||||||
|         id: changed-files-json-raw-format |         id: changed-files-json-unescaped | ||||||
|         uses: ./ |         uses: ./ | ||||||
|         with: |         with: | ||||||
|           json: true |           json: true | ||||||
|           json_raw_format: true |           escape_json: false | ||||||
|       - name: Show output |       - name: Show output | ||||||
|         run: | |         run: | | ||||||
|           echo '${{ toJSON(steps.changed-files-json-raw-format.outputs) }}' |           echo '${{ toJSON(steps.changed-files-json-unescaped.outputs) }}' | ||||||
|           echo '${{ toJSON(steps.changed-files-json-raw-format.outputs.all_changed_files) }}' |           echo '${{ toJSON(steps.changed-files-json-unescaped.outputs.all_changed_files) }}' | ||||||
|         shell: |         shell: | ||||||
|           bash |           bash | ||||||
|       - name: Run changed-files with comma separator |       - name: Run changed-files with comma separator | ||||||
|  | |||||||
							
								
								
									
										54
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										54
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -260,7 +260,7 @@ const getSHAForPushEvent = (inputs, env, workingDirectory, isShallow, hasSubmodu | |||||||
|             throw new Error('Similar commit hashes detected.'); |             throw new Error('Similar commit hashes detected.'); | ||||||
|         } |         } | ||||||
|         yield (0, utils_1.verifyCommitSha)({ sha: previousSha, cwd: workingDirectory }); |         yield (0, utils_1.verifyCommitSha)({ sha: previousSha, cwd: workingDirectory }); | ||||||
|         core.info(`Previous SHA: ${previousSha}`); |         core.debug(`Previous SHA: ${previousSha}`); | ||||||
|         return { |         return { | ||||||
|             previousSha, |             previousSha, | ||||||
|             currentSha, |             currentSha, | ||||||
| @ -299,13 +299,18 @@ const getSHAForPushEvent = (inputs, env, workingDirectory, isShallow, hasSubmodu | |||||||
|             if (env.GITHUB_EVENT_FORCED === 'false' || !env.GITHUB_EVENT_FORCED) { |             if (env.GITHUB_EVENT_FORCED === 'false' || !env.GITHUB_EVENT_FORCED) { | ||||||
|                 previousSha = env.GITHUB_EVENT_BEFORE; |                 previousSha = env.GITHUB_EVENT_BEFORE; | ||||||
|             } |             } | ||||||
|             else { |             if (!previousSha || | ||||||
|  |                 previousSha === '0000000000000000000000000000000000000000') { | ||||||
|                 previousSha = yield (0, utils_1.getParentSha)({ |                 previousSha = yield (0, utils_1.getParentSha)({ | ||||||
|                     cwd: workingDirectory |                     cwd: workingDirectory | ||||||
|                 }); |                 }); | ||||||
|             } |             } | ||||||
|             if (!previousSha || |             else if ((yield (0, utils_1.verifyCommitSha)({ | ||||||
|                 previousSha === '0000000000000000000000000000000000000000') { |                 sha: previousSha, | ||||||
|  |                 cwd: workingDirectory, | ||||||
|  |                 showAsErrorMessage: false | ||||||
|  |             })) !== 0) { | ||||||
|  |                 core.warning(`Previous commit ${previousSha} is not valid. Using parent commit.`); | ||||||
|                 previousSha = yield (0, utils_1.getParentSha)({ |                 previousSha = yield (0, utils_1.getParentSha)({ | ||||||
|                     cwd: workingDirectory |                     cwd: workingDirectory | ||||||
|                 }); |                 }); | ||||||
| @ -415,7 +420,7 @@ const getSHAForPullRequestEvent = (inputs, env, workingDirectory, isShallow, has | |||||||
|             throw new Error('Similar commit hashes detected.'); |             throw new Error('Similar commit hashes detected.'); | ||||||
|         } |         } | ||||||
|         yield (0, utils_1.verifyCommitSha)({ sha: currentSha, cwd: workingDirectory }); |         yield (0, utils_1.verifyCommitSha)({ sha: currentSha, cwd: workingDirectory }); | ||||||
|         core.info(`Previous SHA: ${previousSha}`); |         core.debug(`Previous SHA: ${previousSha}`); | ||||||
|         return { |         return { | ||||||
|             previousSha, |             previousSha, | ||||||
|             currentSha, |             currentSha, | ||||||
| @ -575,6 +580,7 @@ const getEnv = () => __awaiter(void 0, void 0, void 0, function* () { | |||||||
|     if (eventPath) { |     if (eventPath) { | ||||||
|         eventJson = JSON.parse(yield fs_1.promises.readFile(eventPath, { encoding: 'utf8' })); |         eventJson = JSON.parse(yield fs_1.promises.readFile(eventPath, { encoding: 'utf8' })); | ||||||
|     } |     } | ||||||
|  |     core.debug(`Env: ${JSON.stringify(process.env, null, 2)}`); | ||||||
|     core.debug(`Event: ${JSON.stringify(eventJson, null, 2)}`); |     core.debug(`Event: ${JSON.stringify(eventJson, null, 2)}`); | ||||||
|     return { |     return { | ||||||
|         GITHUB_EVENT_PULL_REQUEST_HEAD_REF: ((_b = (_a = eventJson.pull_request) === null || _a === void 0 ? void 0 : _a.head) === null || _b === void 0 ? void 0 : _b.ref) || '', |         GITHUB_EVENT_PULL_REQUEST_HEAD_REF: ((_b = (_a = eventJson.pull_request) === null || _a === void 0 ? void 0 : _a.head) === null || _b === void 0 ? void 0 : _b.ref) || '', | ||||||
| @ -713,7 +719,7 @@ const getInputs = () => { | |||||||
|         outputDir |         outputDir | ||||||
|     }; |     }; | ||||||
|     if (fetchDepth) { |     if (fetchDepth) { | ||||||
|         inputs.fetchDepth = parseInt(fetchDepth, 10); |         inputs.fetchDepth = Math.max(parseInt(fetchDepth, 10), 2); | ||||||
|     } |     } | ||||||
|     if (dirNamesMaxDepth) { |     if (dirNamesMaxDepth) { | ||||||
|         inputs.dirNamesMaxDepth = parseInt(dirNamesMaxDepth, 10); |         inputs.dirNamesMaxDepth = parseInt(dirNamesMaxDepth, 10); | ||||||
| @ -1234,7 +1240,7 @@ const versionToNumber = (version) => { | |||||||
|     return major * 1000000 + minor * 1000 + patch; |     return major * 1000000 + minor * 1000 + patch; | ||||||
| }; | }; | ||||||
| const verifyMinimumGitVersion = () => __awaiter(void 0, void 0, void 0, function* () { | const verifyMinimumGitVersion = () => __awaiter(void 0, void 0, void 0, function* () { | ||||||
|     const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['--version'], { silent: process.env.ACTION_DEBUG === 'false' }); |     const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['--version'], { silent: process.env.RUNNER_DEBUG !== '1' }); | ||||||
|     if (exitCode !== 0) { |     if (exitCode !== 0) { | ||||||
|         throw new Error(stderr || 'An unexpected error occurred'); |         throw new Error(stderr || 'An unexpected error occurred'); | ||||||
|     } |     } | ||||||
| @ -1329,7 +1335,7 @@ const getFilesFromSourceFile = ({ filePaths, excludedFiles = false }) => __await | |||||||
| const updateGitGlobalConfig = ({ name, value }) => __awaiter(void 0, void 0, void 0, function* () { | const updateGitGlobalConfig = ({ name, value }) => __awaiter(void 0, void 0, void 0, function* () { | ||||||
|     const { exitCode, stderr } = yield exec.getExecOutput('git', ['config', '--global', name, value], { |     const { exitCode, stderr } = yield exec.getExecOutput('git', ['config', '--global', name, value], { | ||||||
|         ignoreReturnCode: true, |         ignoreReturnCode: true, | ||||||
|         silent: process.env.ACTION_DEBUG === 'false' |         silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     }); |     }); | ||||||
|     /* istanbul ignore if */ |     /* istanbul ignore if */ | ||||||
|     if (exitCode !== 0 || stderr) { |     if (exitCode !== 0 || stderr) { | ||||||
| @ -1340,7 +1346,7 @@ exports.updateGitGlobalConfig = updateGitGlobalConfig; | |||||||
| const isRepoShallow = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () { | const isRepoShallow = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () { | ||||||
|     const { stdout } = yield exec.getExecOutput('git', ['rev-parse', '--is-shallow-repository'], { |     const { stdout } = yield exec.getExecOutput('git', ['rev-parse', '--is-shallow-repository'], { | ||||||
|         cwd, |         cwd, | ||||||
|         silent: process.env.ACTION_DEBUG === 'false' |         silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     }); |     }); | ||||||
|     return stdout.trim() === 'true'; |     return stdout.trim() === 'true'; | ||||||
| }); | }); | ||||||
| @ -1349,7 +1355,7 @@ const submoduleExists = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* | |||||||
|     const { stdout, exitCode } = yield exec.getExecOutput('git', ['submodule', 'status'], { |     const { stdout, exitCode } = yield exec.getExecOutput('git', ['submodule', 'status'], { | ||||||
|         cwd, |         cwd, | ||||||
|         ignoreReturnCode: true, |         ignoreReturnCode: true, | ||||||
|         silent: process.env.ACTION_DEBUG === 'false' |         silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     }); |     }); | ||||||
|     if (exitCode !== 0) { |     if (exitCode !== 0) { | ||||||
|         return false; |         return false; | ||||||
| @ -1361,7 +1367,7 @@ const gitFetch = ({ args, cwd }) => __awaiter(void 0, void 0, void 0, function* | |||||||
|     const { exitCode } = yield exec.getExecOutput('git', ['fetch', '-q', ...args], { |     const { exitCode } = yield exec.getExecOutput('git', ['fetch', '-q', ...args], { | ||||||
|         cwd, |         cwd, | ||||||
|         ignoreReturnCode: true, |         ignoreReturnCode: true, | ||||||
|         silent: process.env.ACTION_DEBUG === 'false' |         silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     }); |     }); | ||||||
|     return exitCode; |     return exitCode; | ||||||
| }); | }); | ||||||
| @ -1370,7 +1376,7 @@ const gitFetchSubmodules = ({ args, cwd }) => __awaiter(void 0, void 0, void 0, | |||||||
|     const { exitCode, stderr } = yield exec.getExecOutput('git', ['submodule', 'foreach', 'git', 'fetch', '-q', ...args], { |     const { exitCode, stderr } = yield exec.getExecOutput('git', ['submodule', 'foreach', 'git', 'fetch', '-q', ...args], { | ||||||
|         cwd, |         cwd, | ||||||
|         ignoreReturnCode: true, |         ignoreReturnCode: true, | ||||||
|         silent: process.env.ACTION_DEBUG === 'false' |         silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     }); |     }); | ||||||
|     /* istanbul ignore if */ |     /* istanbul ignore if */ | ||||||
|     if (exitCode !== 0) { |     if (exitCode !== 0) { | ||||||
| @ -1385,7 +1391,7 @@ const getSubmodulePath = ({ cwd }) => __awaiter(void 0, void 0, void 0, function | |||||||
|     const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['submodule', 'status'], { |     const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['submodule', 'status'], { | ||||||
|         cwd, |         cwd, | ||||||
|         ignoreReturnCode: true, |         ignoreReturnCode: true, | ||||||
|         silent: process.env.ACTION_DEBUG === 'false' |         silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     }); |     }); | ||||||
|     if (exitCode !== 0) { |     if (exitCode !== 0) { | ||||||
|         core.warning(stderr || "Couldn't get submodule names"); |         core.warning(stderr || "Couldn't get submodule names"); | ||||||
| @ -1401,7 +1407,7 @@ const gitSubmoduleDiffSHA = ({ cwd, parentSha1, parentSha2, submodulePath, diff | |||||||
|     var _h, _j, _k, _l; |     var _h, _j, _k, _l; | ||||||
|     const { stdout } = yield exec.getExecOutput('git', ['diff', parentSha1, parentSha2, '--', submodulePath], { |     const { stdout } = yield exec.getExecOutput('git', ['diff', parentSha1, parentSha2, '--', submodulePath], { | ||||||
|         cwd, |         cwd, | ||||||
|         silent: process.env.ACTION_DEBUG === 'false' |         silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     }); |     }); | ||||||
|     const subprojectCommitPreRegex = /^(?<preCommit>-)Subproject commit (?<commitHash>.+)$/m; |     const subprojectCommitPreRegex = /^(?<preCommit>-)Subproject commit (?<commitHash>.+)$/m; | ||||||
|     const subprojectCommitCurRegex = /^(?<curCommit>\+)Subproject commit (?<commitHash>.+)$/m; |     const subprojectCommitCurRegex = /^(?<curCommit>\+)Subproject commit (?<commitHash>.+)$/m; | ||||||
| @ -1425,7 +1431,7 @@ const gitRenamedFiles = ({ cwd, sha1, sha2, diff, oldNewSeparator, isSubmodule = | |||||||
|     ], { |     ], { | ||||||
|         cwd, |         cwd, | ||||||
|         ignoreReturnCode: true, |         ignoreReturnCode: true, | ||||||
|         silent: process.env.ACTION_DEBUG === 'false' |         silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     }); |     }); | ||||||
|     if (exitCode !== 0) { |     if (exitCode !== 0) { | ||||||
|         if (isSubmodule) { |         if (isSubmodule) { | ||||||
| @ -1463,7 +1469,7 @@ const gitDiff = ({ cwd, sha1, sha2, diff, diffFilter, filePatterns = [], isSubmo | |||||||
|     ], { |     ], { | ||||||
|         cwd, |         cwd, | ||||||
|         ignoreReturnCode: true, |         ignoreReturnCode: true, | ||||||
|         silent: process.env.ACTION_DEBUG === 'false' |         silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     }); |     }); | ||||||
|     if (exitCode !== 0) { |     if (exitCode !== 0) { | ||||||
|         if (isSubmodule) { |         if (isSubmodule) { | ||||||
| @ -1498,7 +1504,7 @@ exports.gitDiff = gitDiff; | |||||||
| const gitLog = ({ args, cwd }) => __awaiter(void 0, void 0, void 0, function* () { | const gitLog = ({ args, cwd }) => __awaiter(void 0, void 0, void 0, function* () { | ||||||
|     const { stdout } = yield exec.getExecOutput('git', ['log', ...args], { |     const { stdout } = yield exec.getExecOutput('git', ['log', ...args], { | ||||||
|         cwd, |         cwd, | ||||||
|         silent: process.env.ACTION_DEBUG === 'false' |         silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     }); |     }); | ||||||
|     return stdout.trim(); |     return stdout.trim(); | ||||||
| }); | }); | ||||||
| @ -1506,7 +1512,7 @@ exports.gitLog = gitLog; | |||||||
| const getHeadSha = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () { | const getHeadSha = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () { | ||||||
|     const { stdout } = yield exec.getExecOutput('git', ['rev-parse', 'HEAD'], { |     const { stdout } = yield exec.getExecOutput('git', ['rev-parse', 'HEAD'], { | ||||||
|         cwd, |         cwd, | ||||||
|         silent: process.env.ACTION_DEBUG === 'false' |         silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     }); |     }); | ||||||
|     return stdout.trim(); |     return stdout.trim(); | ||||||
| }); | }); | ||||||
| @ -1514,7 +1520,7 @@ exports.getHeadSha = getHeadSha; | |||||||
| const gitLsRemote = ({ cwd, args }) => __awaiter(void 0, void 0, void 0, function* () { | const gitLsRemote = ({ cwd, args }) => __awaiter(void 0, void 0, void 0, function* () { | ||||||
|     const { stdout } = yield exec.getExecOutput('git', ['ls-remote', 'origin', ...args], { |     const { stdout } = yield exec.getExecOutput('git', ['ls-remote', 'origin', ...args], { | ||||||
|         cwd, |         cwd, | ||||||
|         silent: process.env.ACTION_DEBUG === 'false' |         silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     }); |     }); | ||||||
|     const output = stdout.trim().split('\t'); |     const output = stdout.trim().split('\t'); | ||||||
|     if (output.length === 0) { |     if (output.length === 0) { | ||||||
| @ -1526,7 +1532,7 @@ exports.gitLsRemote = gitLsRemote; | |||||||
| const getParentSha = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () { | const getParentSha = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () { | ||||||
|     const { stdout } = yield exec.getExecOutput('git', ['rev-list', '-n', '1', 'HEAD^'], { |     const { stdout } = yield exec.getExecOutput('git', ['rev-list', '-n', '1', 'HEAD^'], { | ||||||
|         cwd, |         cwd, | ||||||
|         silent: process.env.ACTION_DEBUG === 'false' |         silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     }); |     }); | ||||||
|     return stdout.trim(); |     return stdout.trim(); | ||||||
| }); | }); | ||||||
| @ -1535,7 +1541,7 @@ const verifyCommitSha = ({ sha, cwd, showAsErrorMessage = true }) => __awaiter(v | |||||||
|     const { exitCode, stderr } = yield exec.getExecOutput('git', ['rev-parse', '--verify', `${sha}^{commit}`], { |     const { exitCode, stderr } = yield exec.getExecOutput('git', ['rev-parse', '--verify', `${sha}^{commit}`], { | ||||||
|         cwd, |         cwd, | ||||||
|         ignoreReturnCode: true, |         ignoreReturnCode: true, | ||||||
|         silent: process.env.ACTION_DEBUG === 'false' |         silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     }); |     }); | ||||||
|     if (exitCode !== 0) { |     if (exitCode !== 0) { | ||||||
|         if (showAsErrorMessage) { |         if (showAsErrorMessage) { | ||||||
| @ -1554,7 +1560,7 @@ exports.verifyCommitSha = verifyCommitSha; | |||||||
| const getPreviousGitTag = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () { | const getPreviousGitTag = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () { | ||||||
|     const { stdout } = yield exec.getExecOutput('git', ['tag', '--sort=-version:refname'], { |     const { stdout } = yield exec.getExecOutput('git', ['tag', '--sort=-version:refname'], { | ||||||
|         cwd, |         cwd, | ||||||
|         silent: process.env.ACTION_DEBUG === 'false' |         silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     }); |     }); | ||||||
|     const tags = stdout.trim().split('\n'); |     const tags = stdout.trim().split('\n'); | ||||||
|     if (tags.length < 2) { |     if (tags.length < 2) { | ||||||
| @ -1564,7 +1570,7 @@ const getPreviousGitTag = ({ cwd }) => __awaiter(void 0, void 0, void 0, functio | |||||||
|     const previousTag = tags[1]; |     const previousTag = tags[1]; | ||||||
|     const { stdout: stdout2 } = yield exec.getExecOutput('git', ['rev-parse', previousTag], { |     const { stdout: stdout2 } = yield exec.getExecOutput('git', ['rev-parse', previousTag], { | ||||||
|         cwd, |         cwd, | ||||||
|         silent: process.env.ACTION_DEBUG === 'false' |         silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     }); |     }); | ||||||
|     const sha = stdout2.trim(); |     const sha = stdout2.trim(); | ||||||
|     return { tag: previousTag, sha }; |     return { tag: previousTag, sha }; | ||||||
| @ -1574,7 +1580,7 @@ const canDiffCommits = ({ cwd, sha1, sha2, diff }) => __awaiter(void 0, void 0, | |||||||
|     const { exitCode, stderr } = yield exec.getExecOutput('git', ['diff', '--name-only', '--ignore-submodules=all', `${sha1}${diff}${sha2}`], { |     const { exitCode, stderr } = yield exec.getExecOutput('git', ['diff', '--name-only', '--ignore-submodules=all', `${sha1}${diff}${sha2}`], { | ||||||
|         cwd, |         cwd, | ||||||
|         ignoreReturnCode: true, |         ignoreReturnCode: true, | ||||||
|         silent: process.env.ACTION_DEBUG === 'false' |         silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     }); |     }); | ||||||
|     if (exitCode !== 0) { |     if (exitCode !== 0) { | ||||||
|         core.warning(stderr || `Unable find merge base between ${sha1} and ${sha2}`); |         core.warning(stderr || `Unable find merge base between ${sha1} and ${sha2}`); | ||||||
|  | |||||||
							
								
								
									
										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
											
										
									
								
							| @ -137,7 +137,7 @@ export const getSHAForPushEvent = async ( | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     await verifyCommitSha({sha: previousSha, cwd: workingDirectory}) |     await verifyCommitSha({sha: previousSha, cwd: workingDirectory}) | ||||||
|     core.info(`Previous SHA: ${previousSha}`) |     core.debug(`Previous SHA: ${previousSha}`) | ||||||
| 
 | 
 | ||||||
|     return { |     return { | ||||||
|       previousSha, |       previousSha, | ||||||
| @ -177,10 +177,6 @@ export const getSHAForPushEvent = async ( | |||||||
|       core.debug('Getting previous SHA for last remote commit...') |       core.debug('Getting previous SHA for last remote commit...') | ||||||
|       if (env.GITHUB_EVENT_FORCED === 'false' || !env.GITHUB_EVENT_FORCED) { |       if (env.GITHUB_EVENT_FORCED === 'false' || !env.GITHUB_EVENT_FORCED) { | ||||||
|         previousSha = env.GITHUB_EVENT_BEFORE |         previousSha = env.GITHUB_EVENT_BEFORE | ||||||
|       } else { |  | ||||||
|         previousSha = await getParentSha({ |  | ||||||
|           cwd: workingDirectory |  | ||||||
|         }) |  | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|       if ( |       if ( | ||||||
| @ -190,6 +186,19 @@ export const getSHAForPushEvent = async ( | |||||||
|         previousSha = await getParentSha({ |         previousSha = await getParentSha({ | ||||||
|           cwd: workingDirectory |           cwd: workingDirectory | ||||||
|         }) |         }) | ||||||
|  |       } else if ( | ||||||
|  |         (await verifyCommitSha({ | ||||||
|  |           sha: previousSha, | ||||||
|  |           cwd: workingDirectory, | ||||||
|  |           showAsErrorMessage: false | ||||||
|  |         })) !== 0 | ||||||
|  |       ) { | ||||||
|  |         core.warning( | ||||||
|  |           `Previous commit ${previousSha} is not valid. Using parent commit.` | ||||||
|  |         ) | ||||||
|  |         previousSha = await getParentSha({ | ||||||
|  |           cwd: workingDirectory | ||||||
|  |         }) | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|       if (previousSha === currentSha) { |       if (previousSha === currentSha) { | ||||||
| @ -322,7 +331,7 @@ export const getSHAForPullRequestEvent = async ( | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     await verifyCommitSha({sha: currentSha, cwd: workingDirectory}) |     await verifyCommitSha({sha: currentSha, cwd: workingDirectory}) | ||||||
|     core.info(`Previous SHA: ${previousSha}`) |     core.debug(`Previous SHA: ${previousSha}`) | ||||||
| 
 | 
 | ||||||
|     return { |     return { | ||||||
|       previousSha, |       previousSha, | ||||||
|  | |||||||
| @ -41,6 +41,7 @@ export const getEnv = async (): Promise<Env> => { | |||||||
|   if (eventPath) { |   if (eventPath) { | ||||||
|     eventJson = JSON.parse(await fs.readFile(eventPath, {encoding: 'utf8'})) |     eventJson = JSON.parse(await fs.readFile(eventPath, {encoding: 'utf8'})) | ||||||
|   } |   } | ||||||
|  |   core.debug(`Env: ${JSON.stringify(process.env, null, 2)}`) | ||||||
|   core.debug(`Event: ${JSON.stringify(eventJson, null, 2)}`) |   core.debug(`Event: ${JSON.stringify(eventJson, null, 2)}`) | ||||||
| 
 | 
 | ||||||
|   return { |   return { | ||||||
|  | |||||||
| @ -135,7 +135,7 @@ export const getInputs = (): Inputs => { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   if (fetchDepth) { |   if (fetchDepth) { | ||||||
|     inputs.fetchDepth = parseInt(fetchDepth, 10) |     inputs.fetchDepth = Math.max(parseInt(fetchDepth, 10), 2) | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   if (dirNamesMaxDepth) { |   if (dirNamesMaxDepth) { | ||||||
|  | |||||||
							
								
								
									
										36
									
								
								src/utils.ts
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								src/utils.ts
									
									
									
									
									
								
							| @ -93,7 +93,7 @@ export const verifyMinimumGitVersion = async (): Promise<void> => { | |||||||
|   const {exitCode, stdout, stderr} = await exec.getExecOutput( |   const {exitCode, stdout, stderr} = await exec.getExecOutput( | ||||||
|     'git', |     'git', | ||||||
|     ['--version'], |     ['--version'], | ||||||
|     {silent: process.env.ACTION_DEBUG === 'false'} |     {silent: process.env.RUNNER_DEBUG !== '1'} | ||||||
|   ) |   ) | ||||||
| 
 | 
 | ||||||
|   if (exitCode !== 0) { |   if (exitCode !== 0) { | ||||||
| @ -177,7 +177,7 @@ export const updateGitGlobalConfig = async ({ | |||||||
|     ['config', '--global', name, value], |     ['config', '--global', name, value], | ||||||
|     { |     { | ||||||
|       ignoreReturnCode: true, |       ignoreReturnCode: true, | ||||||
|       silent: process.env.ACTION_DEBUG === 'false' |       silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     } |     } | ||||||
|   ) |   ) | ||||||
| 
 | 
 | ||||||
| @ -193,7 +193,7 @@ export const isRepoShallow = async ({cwd}: {cwd: string}): Promise<boolean> => { | |||||||
|     ['rev-parse', '--is-shallow-repository'], |     ['rev-parse', '--is-shallow-repository'], | ||||||
|     { |     { | ||||||
|       cwd, |       cwd, | ||||||
|       silent: process.env.ACTION_DEBUG === 'false' |       silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     } |     } | ||||||
|   ) |   ) | ||||||
| 
 | 
 | ||||||
| @ -211,7 +211,7 @@ export const submoduleExists = async ({ | |||||||
|     { |     { | ||||||
|       cwd, |       cwd, | ||||||
|       ignoreReturnCode: true, |       ignoreReturnCode: true, | ||||||
|       silent: process.env.ACTION_DEBUG === 'false' |       silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     } |     } | ||||||
|   ) |   ) | ||||||
| 
 | 
 | ||||||
| @ -232,7 +232,7 @@ export const gitFetch = async ({ | |||||||
|   const {exitCode} = await exec.getExecOutput('git', ['fetch', '-q', ...args], { |   const {exitCode} = await exec.getExecOutput('git', ['fetch', '-q', ...args], { | ||||||
|     cwd, |     cwd, | ||||||
|     ignoreReturnCode: true, |     ignoreReturnCode: true, | ||||||
|     silent: process.env.ACTION_DEBUG === 'false' |     silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|   }) |   }) | ||||||
| 
 | 
 | ||||||
|   return exitCode |   return exitCode | ||||||
| @ -251,7 +251,7 @@ export const gitFetchSubmodules = async ({ | |||||||
|     { |     { | ||||||
|       cwd, |       cwd, | ||||||
|       ignoreReturnCode: true, |       ignoreReturnCode: true, | ||||||
|       silent: process.env.ACTION_DEBUG === 'false' |       silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     } |     } | ||||||
|   ) |   ) | ||||||
| 
 | 
 | ||||||
| @ -276,7 +276,7 @@ export const getSubmodulePath = async ({ | |||||||
|     { |     { | ||||||
|       cwd, |       cwd, | ||||||
|       ignoreReturnCode: true, |       ignoreReturnCode: true, | ||||||
|       silent: process.env.ACTION_DEBUG === 'false' |       silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     } |     } | ||||||
|   ) |   ) | ||||||
| 
 | 
 | ||||||
| @ -309,7 +309,7 @@ export const gitSubmoduleDiffSHA = async ({ | |||||||
|     ['diff', parentSha1, parentSha2, '--', submodulePath], |     ['diff', parentSha1, parentSha2, '--', submodulePath], | ||||||
|     { |     { | ||||||
|       cwd, |       cwd, | ||||||
|       silent: process.env.ACTION_DEBUG === 'false' |       silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     } |     } | ||||||
|   ) |   ) | ||||||
| 
 | 
 | ||||||
| @ -362,7 +362,7 @@ export const gitRenamedFiles = async ({ | |||||||
|     { |     { | ||||||
|       cwd, |       cwd, | ||||||
|       ignoreReturnCode: true, |       ignoreReturnCode: true, | ||||||
|       silent: process.env.ACTION_DEBUG === 'false' |       silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     } |     } | ||||||
|   ) |   ) | ||||||
| 
 | 
 | ||||||
| @ -434,7 +434,7 @@ export const gitDiff = async ({ | |||||||
|     { |     { | ||||||
|       cwd, |       cwd, | ||||||
|       ignoreReturnCode: true, |       ignoreReturnCode: true, | ||||||
|       silent: process.env.ACTION_DEBUG === 'false' |       silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     } |     } | ||||||
|   ) |   ) | ||||||
| 
 | 
 | ||||||
| @ -486,7 +486,7 @@ export const gitLog = async ({ | |||||||
| }): Promise<string> => { | }): Promise<string> => { | ||||||
|   const {stdout} = await exec.getExecOutput('git', ['log', ...args], { |   const {stdout} = await exec.getExecOutput('git', ['log', ...args], { | ||||||
|     cwd, |     cwd, | ||||||
|     silent: process.env.ACTION_DEBUG === 'false' |     silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|   }) |   }) | ||||||
| 
 | 
 | ||||||
|   return stdout.trim() |   return stdout.trim() | ||||||
| @ -495,7 +495,7 @@ export const gitLog = async ({ | |||||||
| export const getHeadSha = async ({cwd}: {cwd: string}): Promise<string> => { | export const getHeadSha = async ({cwd}: {cwd: string}): Promise<string> => { | ||||||
|   const {stdout} = await exec.getExecOutput('git', ['rev-parse', 'HEAD'], { |   const {stdout} = await exec.getExecOutput('git', ['rev-parse', 'HEAD'], { | ||||||
|     cwd, |     cwd, | ||||||
|     silent: process.env.ACTION_DEBUG === 'false' |     silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|   }) |   }) | ||||||
| 
 | 
 | ||||||
|   return stdout.trim() |   return stdout.trim() | ||||||
| @ -513,7 +513,7 @@ export const gitLsRemote = async ({ | |||||||
|     ['ls-remote', 'origin', ...args], |     ['ls-remote', 'origin', ...args], | ||||||
|     { |     { | ||||||
|       cwd, |       cwd, | ||||||
|       silent: process.env.ACTION_DEBUG === 'false' |       silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     } |     } | ||||||
|   ) |   ) | ||||||
|   const output = stdout.trim().split('\t') |   const output = stdout.trim().split('\t') | ||||||
| @ -531,7 +531,7 @@ export const getParentSha = async ({cwd}: {cwd: string}): Promise<string> => { | |||||||
|     ['rev-list', '-n', '1', 'HEAD^'], |     ['rev-list', '-n', '1', 'HEAD^'], | ||||||
|     { |     { | ||||||
|       cwd, |       cwd, | ||||||
|       silent: process.env.ACTION_DEBUG === 'false' |       silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     } |     } | ||||||
|   ) |   ) | ||||||
| 
 | 
 | ||||||
| @ -553,7 +553,7 @@ export const verifyCommitSha = async ({ | |||||||
|     { |     { | ||||||
|       cwd, |       cwd, | ||||||
|       ignoreReturnCode: true, |       ignoreReturnCode: true, | ||||||
|       silent: process.env.ACTION_DEBUG === 'false' |       silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     } |     } | ||||||
|   ) |   ) | ||||||
| 
 | 
 | ||||||
| @ -583,7 +583,7 @@ export const getPreviousGitTag = async ({ | |||||||
|     ['tag', '--sort=-version:refname'], |     ['tag', '--sort=-version:refname'], | ||||||
|     { |     { | ||||||
|       cwd, |       cwd, | ||||||
|       silent: process.env.ACTION_DEBUG === 'false' |       silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     } |     } | ||||||
|   ) |   ) | ||||||
| 
 | 
 | ||||||
| @ -601,7 +601,7 @@ export const getPreviousGitTag = async ({ | |||||||
|     ['rev-parse', previousTag], |     ['rev-parse', previousTag], | ||||||
|     { |     { | ||||||
|       cwd, |       cwd, | ||||||
|       silent: process.env.ACTION_DEBUG === 'false' |       silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     } |     } | ||||||
|   ) |   ) | ||||||
| 
 | 
 | ||||||
| @ -627,7 +627,7 @@ export const canDiffCommits = async ({ | |||||||
|     { |     { | ||||||
|       cwd, |       cwd, | ||||||
|       ignoreReturnCode: true, |       ignoreReturnCode: true, | ||||||
|       silent: process.env.ACTION_DEBUG === 'false' |       silent: process.env.RUNNER_DEBUG !== '1' | ||||||
|     } |     } | ||||||
|   ) |   ) | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tonye Jack
						Tonye Jack