delqhi/sin-github-issues
0
1import { runCommand } from './command.js';2 3export async function repoStatus(repoPath: string) {4 const branch = await runCommand('git', ['branch', '--show-current'], repoPath);5 const status = await runCommand('git', ['status', '--short'], repoPath);6 return {7 repoPath,8 branch: branch.stdout,9 clean: status.stdout.length === 0,10 status: status.stdout,11 };12}13 14export async function startBranch(repoPath: string, branchName: string, baseRef = 'main') {15 await runCommand('git', ['fetch', 'origin', baseRef], repoPath);16 await runCommand('git', ['switch', '-C', branchName, `origin/${baseRef}`], repoPath);17 return repoStatus(repoPath);18}19 20export async function commitAll(repoPath: string, message: string) {21 await runCommand('git', ['add', '-A'], repoPath);22 await runCommand('git', ['commit', '-m', message], repoPath);23 const head = await runCommand('git', ['rev-parse', 'HEAD'], repoPath);24 return { repoPath, commit: head.stdout };25}26 27export async function pushBranch(repoPath: string, remote = 'origin', branchName?: string) {28 const branch = branchName || (await runCommand('git', ['branch', '--show-current'], repoPath)).stdout;29 await runCommand('git', ['push', '-u', remote, branch], repoPath);30 return { repoPath, remote, branch };31}32 