25 lines
820 B
TypeScript
25 lines
820 B
TypeScript
import { getGitBranch, readGitRemoteConfig } from './config'
|
|
import { createGiteaProvider } from './providers/gitea'
|
|
import { createGitHubProvider } from './providers/github'
|
|
import type { GitProvider } from './types'
|
|
import type { PushFile } from '@/lib/types'
|
|
|
|
function createGitProvider(): GitProvider {
|
|
const remote = readGitRemoteConfig()
|
|
const branch = getGitBranch()
|
|
|
|
if (remote.provider === 'github') {
|
|
return createGitHubProvider(remote, branch)
|
|
}
|
|
|
|
return createGiteaProvider(remote, branch)
|
|
}
|
|
|
|
export async function getRemoteFolder(folderPath: string) {
|
|
return createGitProvider().getRemoteFolder(folderPath)
|
|
}
|
|
|
|
export async function pushAllToGit(files: PushFile[], deletePaths: string[], commitMessage: string) {
|
|
return createGitProvider().pushFiles({ files, deletePaths, commitMessage })
|
|
}
|