Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/resolve bug fetching more history #1176

Merged
merged 16 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading