Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove: unused code #2014

Merged
merged 3 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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