Skip to content

Commit cc3bbb0

Browse files
jackton1tj-actions-botactions-user
authored
fix: error using since_last_remote_commit with the first PR commit (#2163)
Co-authored-by: tj-actions[bot] <[email protected]> Co-authored-by: GitHub Action <[email protected]>
1 parent 373db58 commit cc3bbb0

File tree

3 files changed

+35
-40
lines changed

3 files changed

+35
-40
lines changed

dist/index.js

Lines changed: 19 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/commitSha.ts

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -380,32 +380,29 @@ export const getSHAForPullRequestEvent = async ({
380380
'Failed to fetch pull request branch. Please ensure "persist-credentials" is set to "true" when checking out the repository. See: https://github.com/actions/checkout#usage'
381381
)
382382
}
383+
core.debug('Fetching target branch...')
384+
await gitFetch({
385+
cwd: workingDirectory,
386+
args: [
387+
...gitFetchExtraArgs,
388+
'-u',
389+
'--progress',
390+
`--deepen=${inputs.fetchDepth}`,
391+
remoteName,
392+
`+refs/heads/${github.context.payload.pull_request?.base?.ref}:refs/remotes/${remoteName}/${github.context.payload.pull_request?.base?.ref}`
393+
]
394+
})
383395

384-
if (!inputs.sinceLastRemoteCommit) {
385-
core.debug('Fetching target branch...')
386-
await gitFetch({
396+
if (diffSubmodule) {
397+
await gitFetchSubmodules({
387398
cwd: workingDirectory,
388399
args: [
389400
...gitFetchExtraArgs,
390401
'-u',
391402
'--progress',
392-
`--deepen=${inputs.fetchDepth}`,
393-
remoteName,
394-
`+refs/heads/${targetBranch}:refs/remotes/${remoteName}/${targetBranch}`
403+
`--deepen=${inputs.fetchDepth}`
395404
]
396405
})
397-
398-
if (diffSubmodule) {
399-
await gitFetchSubmodules({
400-
cwd: workingDirectory,
401-
args: [
402-
...gitFetchExtraArgs,
403-
'-u',
404-
'--progress',
405-
`--deepen=${inputs.fetchDepth}`
406-
]
407-
})
408-
}
409406
}
410407
} else {
411408
if (diffSubmodule && inputs.fetchAdditionalSubmoduleHistory) {

0 commit comments

Comments
 (0)