From 6b186257ec2428087646f6a7868f48a70cc367a0 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 26 Mar 2024 16:42:33 -0600 Subject: [PATCH] remove: unused code --- src/commitSha.ts | 18 ++++++------------ src/main.ts | 11 ++--------- src/utils.ts | 41 ----------------------------------------- 3 files changed, 8 insertions(+), 62 deletions(-) diff --git a/src/commitSha.ts b/src/commitSha.ts index c05b1fbe2d9..e3e23c2ca2b 100644 --- a/src/commitSha.ts +++ b/src/commitSha.ts @@ -326,7 +326,6 @@ interface SHAForPullRequestEvent { hasSubmodule: boolean gitFetchExtraArgs: string[] remoteName: string - isFork: boolean } export const getSHAForPullRequestEvent = async ({ @@ -335,8 +334,7 @@ export const getSHAForPullRequestEvent = async ({ isShallow, hasSubmodule, gitFetchExtraArgs, - remoteName, - isFork + remoteName }: SHAForPullRequestEvent): Promise => { let targetBranch = github.context.payload.pull_request?.base?.ref const currentBranch = github.context.payload.pull_request?.head?.ref @@ -507,18 +505,14 @@ export const getSHAForPullRequestEvent = async ({ } } } else { - if (github.context.payload.action === 'closed' || isFork) { - previousSha = github.context.payload.pull_request?.base?.sha - } else { + previousSha = github.context.payload.pull_request?.base?.sha + + if (!previousSha) { previousSha = await getRemoteBranchHeadSha({ cwd: workingDirectory, - branch: targetBranch, - remoteName + remoteName, + branch: targetBranch }) - - if (!previousSha) { - previousSha = github.context.payload.pull_request?.base?.sha - } } if (isShallow) { diff --git a/src/main.ts b/src/main.ts index 8a82a55818e..4159b4f1a37 100644 --- a/src/main.ts +++ b/src/main.ts @@ -23,7 +23,6 @@ import { hasLocalGitDirectory, isRepoShallow, recoverDeletedFiles, - setForkRemote, setOutput, submoduleExists, updateGitGlobalConfig, @@ -73,8 +72,7 @@ const getChangedFilesFromLocalGitHistory = async ({ } const isTag = env.GITHUB_REF?.startsWith('refs/tags/') - const isFork = github.context.payload.pull_request?.head.repo.fork || false - let remoteName = 'origin' + const remoteName = 'origin' const outputRenamedFilesAsDeletedAndAdded = inputs.outputRenamedFilesAsDeletedAndAdded let submodulePaths: string[] = [] @@ -87,10 +85,6 @@ const getChangedFilesFromLocalGitHistory = async ({ gitFetchExtraArgs = ['--prune', '--no-recurse-submodules'] } - if (isFork) { - remoteName = await setForkRemote({cwd: workingDirectory}) - } - let diffResult: DiffResult if (!github.context.payload.pull_request?.base?.ref) { @@ -117,8 +111,7 @@ const getChangedFilesFromLocalGitHistory = async ({ isShallow, hasSubmodule, gitFetchExtraArgs, - remoteName, - isFork + remoteName }) } diff --git a/src/utils.ts b/src/utils.ts index b1ff224b0bc..a73efaf17e3 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -744,47 +744,6 @@ export const getParentSha = async ({cwd}: {cwd: string}): Promise => { return stdout.trim() } -const remoteExists = async ( - cwd: string, - remoteName: string -): Promise => { - const {exitCode} = await exec.getExecOutput( - 'git', - ['remote', 'get-url', remoteName], - { - cwd, - ignoreReturnCode: true, - silent: !core.isDebug() - } - ) - - return exitCode === 0 -} - -export const setForkRemote = async ({cwd}: {cwd: string}): Promise => { - const remoteName = 'changed-files-fork' - - const remoteFound = await remoteExists(cwd, remoteName) - - if (!remoteFound) { - await exec.getExecOutput( - 'git', - [ - 'remote', - 'add', - remoteName, - github.context.payload.repository?.clone_url - ], - { - cwd, - silent: !core.isDebug() - } - ) - } - - return remoteName -} - export const verifyCommitSha = async ({ sha, cwd,