feat: phase 6 of git implementation

This commit is contained in:
2026-02-16 15:34:48 +01:00
parent 339e513a2d
commit e9743cb70f
8 changed files with 249 additions and 2 deletions

View File

@@ -69,6 +69,14 @@ export interface GitHistoryEntry {
syncStatus?: GitHistorySyncStatus;
}
export interface GitRemoteStateDto {
localBranch: string | null;
upstreamBranch: string | null;
hasUpstream: boolean;
ahead: number;
behind: number;
}
export type GitHistorySyncStatus = 'both' | 'local-only' | 'remote-only';
export type GitInitPhase =
@@ -711,6 +719,26 @@ export class GitEngine {
});
}
async getRemoteState(projectPath: string): Promise<GitRemoteStateDto> {
const git = simpleGit(projectPath);
const status = await git.status();
const localBranch = typeof status.current === 'string' && status.current.trim().length > 0
? status.current
: null;
const upstreamBranch = typeof status.tracking === 'string' && status.tracking.trim().length > 0
? status.tracking
: null;
return {
localBranch,
upstreamBranch,
hasUpstream: Boolean(upstreamBranch),
ahead: typeof status.ahead === 'number' ? status.ahead : Number(status.ahead ?? 0),
behind: typeof status.behind === 'number' ? status.behind : Number(status.behind ?? 0),
};
}
async fetch(projectPath: string): Promise<GitActionResult> {
const git = this.createNonInteractiveGit(projectPath);
try {