feat: add dir_names_exclude_current_dir input and cleaned up logic to retrieve the current sha (#1229)
Co-authored-by: GitHub Action <action@github.com> Co-authored-by: tj-actions[bot] <109116665+tj-actions-bot@users.noreply.github.com> Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
This commit is contained in:
@@ -15,9 +15,11 @@ import {
|
||||
} from './utils'
|
||||
|
||||
const getCurrentSHA = async ({
|
||||
env,
|
||||
inputs,
|
||||
workingDirectory
|
||||
}: {
|
||||
env: Env
|
||||
inputs: Inputs
|
||||
workingDirectory: string
|
||||
}): Promise<string> => {
|
||||
@@ -47,7 +49,18 @@ const getCurrentSHA = async ({
|
||||
}
|
||||
} else {
|
||||
if (!currentSha) {
|
||||
currentSha = await getHeadSha({cwd: workingDirectory})
|
||||
if (
|
||||
env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA &&
|
||||
(await verifyCommitSha({
|
||||
sha: env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA,
|
||||
cwd: workingDirectory,
|
||||
showAsErrorMessage: false
|
||||
})) === 0
|
||||
) {
|
||||
currentSha = env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA
|
||||
} else {
|
||||
currentSha = await getHeadSha({cwd: workingDirectory})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +137,7 @@ export const getSHAForPushEvent = async (
|
||||
}
|
||||
}
|
||||
|
||||
const currentSha = await getCurrentSHA({inputs, workingDirectory})
|
||||
const currentSha = await getCurrentSHA({env, inputs, workingDirectory})
|
||||
let previousSha = inputs.baseSha
|
||||
const diff = '..'
|
||||
|
||||
@@ -321,7 +334,7 @@ export const getSHAForPullRequestEvent = async (
|
||||
core.info('Completed fetching more history.')
|
||||
}
|
||||
|
||||
let currentSha = await getCurrentSHA({inputs, workingDirectory})
|
||||
const currentSha = await getCurrentSHA({env, inputs, workingDirectory})
|
||||
let previousSha = inputs.baseSha
|
||||
let diff = '...'
|
||||
|
||||
@@ -336,7 +349,7 @@ export const getSHAForPullRequestEvent = async (
|
||||
throw new Error('Similar commit hashes detected.')
|
||||
}
|
||||
|
||||
await verifyCommitSha({sha: currentSha, cwd: workingDirectory})
|
||||
await verifyCommitSha({sha: previousSha, cwd: workingDirectory})
|
||||
core.debug(`Previous SHA: ${previousSha}`)
|
||||
|
||||
return {
|
||||
@@ -425,10 +438,6 @@ export const getSHAForPullRequestEvent = async (
|
||||
}
|
||||
}
|
||||
|
||||
if (previousSha === currentSha && env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA) {
|
||||
currentSha = env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA
|
||||
}
|
||||
|
||||
if (
|
||||
!(await canDiffCommits({
|
||||
cwd: workingDirectory,
|
||||
|
||||
Reference in New Issue
Block a user