mirror of
https://github.com/tj-actions/changed-files
synced 2024-12-17 13:47:20 +00:00
remove: unused code (#2014)
This commit is contained in:
parent
2ca8dc42f6
commit
90941b398f
5 changed files with 8 additions and 62 deletions
BIN
dist/index.js
generated
vendored
BIN
dist/index.js
generated
vendored
Binary file not shown.
BIN
dist/index.js.map
generated
vendored
BIN
dist/index.js.map
generated
vendored
Binary file not shown.
|
@ -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<DiffResult> => {
|
||||
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) {
|
||||
|
|
11
src/main.ts
11
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
|
||||
})
|
||||
}
|
||||
|
||||
|
|
41
src/utils.ts
41
src/utils.ts
|
@ -744,47 +744,6 @@ export const getParentSha = async ({cwd}: {cwd: string}): Promise<string> => {
|
|||
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 ({
|
||||
sha,
|
||||
cwd,
|
||||
|
|
Loading…
Reference in a new issue