Files
upload-gltf/lib/git/index.ts
T
2026-05-17 14:12:09 +02:00

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 })
}