Skip to content

Commit

Permalink
remove: unused code (#2014)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackton1 authored Mar 26, 2024
1 parent 2ca8dc4 commit 90941b3
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 128 deletions.
94 changes: 29 additions & 65 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

18 changes: 6 additions & 12 deletions src/commitSha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ interface SHAForPullRequestEvent {
hasSubmodule: boolean
gitFetchExtraArgs: string[]
remoteName: string
isFork: boolean
}

export const getSHAForPullRequestEvent = async ({
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
11 changes: 2 additions & 9 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
hasLocalGitDirectory,
isRepoShallow,
recoverDeletedFiles,
setForkRemote,
setOutput,
submoduleExists,
updateGitGlobalConfig,
Expand Down Expand Up @@ -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[] = []
Expand All @@ -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) {
Expand All @@ -117,8 +111,7 @@ const getChangedFilesFromLocalGitHistory = async ({
isShallow,
hasSubmodule,
gitFetchExtraArgs,
remoteName,
isFork
remoteName
})
}

Expand Down
41 changes: 0 additions & 41 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 90941b3

Please sign in to comment.