Skip to content

Commit

Permalink
fix/resolve bug fetching more history (#1176)
Browse files Browse the repository at this point in the history
Co-authored-by: GitHub Action <action@github.com>
  • Loading branch information
jackton1 and actions-user committed May 26, 2023
1 parent 77f872a commit 25eaddf
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 55 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Expand Up @@ -689,16 +689,16 @@ jobs:
echo '${{ toJSON(steps.changed-files-json.outputs.all_changed_files) }}'
shell:
bash
- name: Run changed-files with json raw format
id: changed-files-json-raw-format
- name: Run changed-files with json unescaped format
id: changed-files-json-unescaped
uses: ./
with:
json: true
json_raw_format: true
escape_json: false
- name: Show output
run: |
echo '${{ toJSON(steps.changed-files-json-raw-format.outputs) }}'
echo '${{ toJSON(steps.changed-files-json-raw-format.outputs.all_changed_files) }}'
echo '${{ toJSON(steps.changed-files-json-unescaped.outputs) }}'
echo '${{ toJSON(steps.changed-files-json-unescaped.outputs.all_changed_files) }}'
shell:
bash
- name: Run changed-files with comma separator
Expand Down
54 changes: 30 additions & 24 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

21 changes: 15 additions & 6 deletions src/commitSha.ts
Expand Up @@ -137,7 +137,7 @@ export const getSHAForPushEvent = async (
}

await verifyCommitSha({sha: previousSha, cwd: workingDirectory})
core.info(`Previous SHA: ${previousSha}`)
core.debug(`Previous SHA: ${previousSha}`)

return {
previousSha,
Expand Down Expand Up @@ -177,10 +177,6 @@ export const getSHAForPushEvent = async (
core.debug('Getting previous SHA for last remote commit...')
if (env.GITHUB_EVENT_FORCED === 'false' || !env.GITHUB_EVENT_FORCED) {
previousSha = env.GITHUB_EVENT_BEFORE
} else {
previousSha = await getParentSha({
cwd: workingDirectory
})
}

if (
Expand All @@ -190,6 +186,19 @@ export const getSHAForPushEvent = async (
previousSha = await getParentSha({
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) {
Expand Down Expand Up @@ -322,7 +331,7 @@ export const getSHAForPullRequestEvent = async (
}

await verifyCommitSha({sha: currentSha, cwd: workingDirectory})
core.info(`Previous SHA: ${previousSha}`)
core.debug(`Previous SHA: ${previousSha}`)

return {
previousSha,
Expand Down
1 change: 1 addition & 0 deletions src/env.ts
Expand Up @@ -41,6 +41,7 @@ export const getEnv = async (): Promise<Env> => {
if (eventPath) {
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)}`)

return {
Expand Down
2 changes: 1 addition & 1 deletion src/inputs.ts
Expand Up @@ -135,7 +135,7 @@ export const getInputs = (): Inputs => {
}

if (fetchDepth) {
inputs.fetchDepth = parseInt(fetchDepth, 10)
inputs.fetchDepth = Math.max(parseInt(fetchDepth, 10), 2)
}

if (dirNamesMaxDepth) {
Expand Down

0 comments on commit 25eaddf

Please sign in to comment.