3
0
Fork 0
mirror of https://github.com/tj-actions/changed-files synced 2025-01-18 13:57:39 +00:00

remove: unused code (#2014)

This commit is contained in:
Tonye Jack 2024-03-26 16:49:39 -06:00 committed by GitHub
parent 2ca8dc42f6
commit 90941b398f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 8 additions and 62 deletions

BIN
dist/index.js generated vendored

Binary file not shown.

BIN
dist/index.js.map generated vendored

Binary file not shown.

View file

@ -326,7 +326,6 @@ interface SHAForPullRequestEvent {
hasSubmodule: boolean hasSubmodule: boolean
gitFetchExtraArgs: string[] gitFetchExtraArgs: string[]
remoteName: string remoteName: string
isFork: boolean
} }
export const getSHAForPullRequestEvent = async ({ export const getSHAForPullRequestEvent = async ({
@ -335,8 +334,7 @@ export const getSHAForPullRequestEvent = async ({
isShallow, isShallow,
hasSubmodule, hasSubmodule,
gitFetchExtraArgs, gitFetchExtraArgs,
remoteName, remoteName
isFork
}: SHAForPullRequestEvent): Promise<DiffResult> => { }: SHAForPullRequestEvent): Promise<DiffResult> => {
let targetBranch = github.context.payload.pull_request?.base?.ref let targetBranch = github.context.payload.pull_request?.base?.ref
const currentBranch = github.context.payload.pull_request?.head?.ref const currentBranch = github.context.payload.pull_request?.head?.ref
@ -507,18 +505,14 @@ export const getSHAForPullRequestEvent = async ({
} }
} }
} else { } else {
if (github.context.payload.action === 'closed' || isFork) {
previousSha = github.context.payload.pull_request?.base?.sha previousSha = github.context.payload.pull_request?.base?.sha
} else {
previousSha = await getRemoteBranchHeadSha({
cwd: workingDirectory,
branch: targetBranch,
remoteName
})
if (!previousSha) { if (!previousSha) {
previousSha = github.context.payload.pull_request?.base?.sha previousSha = await getRemoteBranchHeadSha({
} cwd: workingDirectory,
remoteName,
branch: targetBranch
})
} }
if (isShallow) { if (isShallow) {

View file

@ -23,7 +23,6 @@ import {
hasLocalGitDirectory, hasLocalGitDirectory,
isRepoShallow, isRepoShallow,
recoverDeletedFiles, recoverDeletedFiles,
setForkRemote,
setOutput, setOutput,
submoduleExists, submoduleExists,
updateGitGlobalConfig, updateGitGlobalConfig,
@ -73,8 +72,7 @@ const getChangedFilesFromLocalGitHistory = async ({
} }
const isTag = env.GITHUB_REF?.startsWith('refs/tags/') const isTag = env.GITHUB_REF?.startsWith('refs/tags/')
const isFork = github.context.payload.pull_request?.head.repo.fork || false const remoteName = 'origin'
let remoteName = 'origin'
const outputRenamedFilesAsDeletedAndAdded = const outputRenamedFilesAsDeletedAndAdded =
inputs.outputRenamedFilesAsDeletedAndAdded inputs.outputRenamedFilesAsDeletedAndAdded
let submodulePaths: string[] = [] let submodulePaths: string[] = []
@ -87,10 +85,6 @@ const getChangedFilesFromLocalGitHistory = async ({
gitFetchExtraArgs = ['--prune', '--no-recurse-submodules'] gitFetchExtraArgs = ['--prune', '--no-recurse-submodules']
} }
if (isFork) {
remoteName = await setForkRemote({cwd: workingDirectory})
}
let diffResult: DiffResult let diffResult: DiffResult
if (!github.context.payload.pull_request?.base?.ref) { if (!github.context.payload.pull_request?.base?.ref) {
@ -117,8 +111,7 @@ const getChangedFilesFromLocalGitHistory = async ({
isShallow, isShallow,
hasSubmodule, hasSubmodule,
gitFetchExtraArgs, gitFetchExtraArgs,
remoteName, remoteName
isFork
}) })
} }

View file

@ -744,47 +744,6 @@ export const getParentSha = async ({cwd}: {cwd: string}): Promise<string> => {
return stdout.trim() return stdout.trim()
} }
const remoteExists = async (
cwd: string,
remoteName: string
): Promise<boolean> => {
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<string> => {
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 ({ export const verifyCommitSha = async ({
sha, sha,
cwd, cwd,