Skip to content

Commit 90941b3

Browse files
authored
remove: unused code (#2014)
1 parent 2ca8dc4 commit 90941b3

File tree

5 files changed

+38
-128
lines changed

5 files changed

+38
-128
lines changed

dist/index.js

+29-65
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/commitSha.ts

+6-12
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,6 @@ interface SHAForPullRequestEvent {
326326
hasSubmodule: boolean
327327
gitFetchExtraArgs: string[]
328328
remoteName: string
329-
isFork: boolean
330329
}
331330

332331
export const getSHAForPullRequestEvent = async ({
@@ -335,8 +334,7 @@ export const getSHAForPullRequestEvent = async ({
335334
isShallow,
336335
hasSubmodule,
337336
gitFetchExtraArgs,
338-
remoteName,
339-
isFork
337+
remoteName
340338
}: SHAForPullRequestEvent): Promise<DiffResult> => {
341339
let targetBranch = github.context.payload.pull_request?.base?.ref
342340
const currentBranch = github.context.payload.pull_request?.head?.ref
@@ -507,18 +505,14 @@ export const getSHAForPullRequestEvent = async ({
507505
}
508506
}
509507
} else {
510-
if (github.context.payload.action === 'closed' || isFork) {
511-
previousSha = github.context.payload.pull_request?.base?.sha
512-
} else {
508+
previousSha = github.context.payload.pull_request?.base?.sha
509+
510+
if (!previousSha) {
513511
previousSha = await getRemoteBranchHeadSha({
514512
cwd: workingDirectory,
515-
branch: targetBranch,
516-
remoteName
513+
remoteName,
514+
branch: targetBranch
517515
})
518-
519-
if (!previousSha) {
520-
previousSha = github.context.payload.pull_request?.base?.sha
521-
}
522516
}
523517

524518
if (isShallow) {

src/main.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
hasLocalGitDirectory,
2424
isRepoShallow,
2525
recoverDeletedFiles,
26-
setForkRemote,
2726
setOutput,
2827
submoduleExists,
2928
updateGitGlobalConfig,
@@ -73,8 +72,7 @@ const getChangedFilesFromLocalGitHistory = async ({
7372
}
7473

7574
const isTag = env.GITHUB_REF?.startsWith('refs/tags/')
76-
const isFork = github.context.payload.pull_request?.head.repo.fork || false
77-
let remoteName = 'origin'
75+
const remoteName = 'origin'
7876
const outputRenamedFilesAsDeletedAndAdded =
7977
inputs.outputRenamedFilesAsDeletedAndAdded
8078
let submodulePaths: string[] = []
@@ -87,10 +85,6 @@ const getChangedFilesFromLocalGitHistory = async ({
8785
gitFetchExtraArgs = ['--prune', '--no-recurse-submodules']
8886
}
8987

90-
if (isFork) {
91-
remoteName = await setForkRemote({cwd: workingDirectory})
92-
}
93-
9488
let diffResult: DiffResult
9589

9690
if (!github.context.payload.pull_request?.base?.ref) {
@@ -117,8 +111,7 @@ const getChangedFilesFromLocalGitHistory = async ({
117111
isShallow,
118112
hasSubmodule,
119113
gitFetchExtraArgs,
120-
remoteName,
121-
isFork
114+
remoteName
122115
})
123116
}
124117

src/utils.ts

-41
Original file line numberDiff line numberDiff line change
@@ -744,47 +744,6 @@ export const getParentSha = async ({cwd}: {cwd: string}): Promise<string> => {
744744
return stdout.trim()
745745
}
746746

747-
const remoteExists = async (
748-
cwd: string,
749-
remoteName: string
750-
): Promise<boolean> => {
751-
const {exitCode} = await exec.getExecOutput(
752-
'git',
753-
['remote', 'get-url', remoteName],
754-
{
755-
cwd,
756-
ignoreReturnCode: true,
757-
silent: !core.isDebug()
758-
}
759-
)
760-
761-
return exitCode === 0
762-
}
763-
764-
export const setForkRemote = async ({cwd}: {cwd: string}): Promise<string> => {
765-
const remoteName = 'changed-files-fork'
766-
767-
const remoteFound = await remoteExists(cwd, remoteName)
768-
769-
if (!remoteFound) {
770-
await exec.getExecOutput(
771-
'git',
772-
[
773-
'remote',
774-
'add',
775-
remoteName,
776-
github.context.payload.repository?.clone_url
777-
],
778-
{
779-
cwd,
780-
silent: !core.isDebug()
781-
}
782-
)
783-
}
784-
785-
return remoteName
786-
}
787-
788747
export const verifyCommitSha = async ({
789748
sha,
790749
cwd,

0 commit comments

Comments
 (0)