Spaces:
Sleeping
Sleeping
| import { runCommand } from './command.js'; | |
| export async function repoStatus(repoPath: string) { | |
| const branch = await runCommand('git', ['branch', '--show-current'], repoPath); | |
| const status = await runCommand('git', ['status', '--short'], repoPath); | |
| return { | |
| repoPath, | |
| branch: branch.stdout, | |
| clean: status.stdout.length === 0, | |
| status: status.stdout, | |
| }; | |
| } | |
| export async function startBranch(repoPath: string, branchName: string, baseRef = 'main') { | |
| await runCommand('git', ['fetch', 'origin', baseRef], repoPath); | |
| await runCommand('git', ['switch', '-C', branchName, `origin/${baseRef}`], repoPath); | |
| return repoStatus(repoPath); | |
| } | |
| export async function commitAll(repoPath: string, message: string) { | |
| await runCommand('git', ['add', '-A'], repoPath); | |
| await runCommand('git', ['commit', '-m', message], repoPath); | |
| const head = await runCommand('git', ['rev-parse', 'HEAD'], repoPath); | |
| return { repoPath, commit: head.stdout }; | |
| } | |
| export async function pushBranch(repoPath: string, remote = 'origin', branchName?: string) { | |
| const branch = branchName || (await runCommand('git', ['branch', '--show-current'], repoPath)).stdout; | |
| await runCommand('git', ['push', '-u', remote, branch], repoPath); | |
| return { repoPath, remote, branch }; | |
| } | |