refactor: split git provider adapters

This commit is contained in:
Tom Boullay
2026-05-17 14:12:09 +02:00
parent 377ed7cfb3
commit 81c513ee1f
13 changed files with 779 additions and 644 deletions
+24
View File
@@ -0,0 +1,24 @@
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 })
}