fix: update test to include push event (#1173)

Co-authored-by: tj-actions[bot] <109116665+tj-actions-bot@users.noreply.github.com>
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
Tonye Jack
2023-05-25 17:39:26 -06:00
committed by GitHub
parent 30e1bb07d4
commit abef388dd9
6 changed files with 86 additions and 86 deletions

View File

@@ -5,7 +5,7 @@ import {Inputs} from './inputs'
import {
canDiffCommits,
getHeadSha,
getParentHeadSha,
getParentSha,
getPreviousGitTag,
gitFetch,
gitFetchSubmodules,
@@ -74,7 +74,7 @@ export const getSHAForPushEvent = async (
gitExtraArgs: string[],
isTag: boolean
): Promise<DiffResult> => {
let targetBranch = env.GITHUB_REFNAME
let targetBranch = env.GITHUB_REF_NAME
const currentBranch = targetBranch
let initialCommit = false
@@ -174,33 +174,33 @@ export const getSHAForPushEvent = async (
previousSha = sha
targetBranch = tag
} else {
if (inputs.sinceLastRemoteCommit) {
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 getParentHeadSha({cwd: workingDirectory})
}
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 {
core.debug('Getting previous SHA for last commit...')
previousSha = await getParentHeadSha({cwd: workingDirectory})
previousSha = await getParentSha({
cwd: workingDirectory
})
}
if (
!previousSha ||
previousSha === '0000000000000000000000000000000000000000'
) {
previousSha = await getParentHeadSha({cwd: workingDirectory})
previousSha = await getParentSha({
cwd: workingDirectory
})
}
if (previousSha === currentSha) {
if (!(await getParentHeadSha({cwd: workingDirectory}))) {
if (!(await getParentSha({cwd: workingDirectory}))) {
core.warning('Initial commit detected no previous commit found.')
initialCommit = true
previousSha = currentSha
} else {
previousSha = await getParentHeadSha({cwd: workingDirectory})
previousSha = await getParentSha({
cwd: workingDirectory
})
}
} else {
if (!previousSha) {