refactor: share api dto types

This commit is contained in:
Federico Jaramillo Martinez
2026-05-07 23:45:13 +02:00
parent ef63a7a063
commit d7cb7ed655
8 changed files with 165 additions and 266 deletions
+1 -27
View File
@@ -1,34 +1,8 @@
import { createHash } from "node:crypto";
import { spawn } from "node:child_process";
import type { GitDiffResponse, GitFileState, GitStatusFile, GitStatusResponse } from "../../shared/apiTypes.js";
import { normalizeRelativePath } from "../workspaces/pathSafety.js";
export type GitFileState = "unmodified" | "modified" | "added" | "deleted" | "renamed" | "copied" | "untracked" | "ignored" | "conflicted";
export interface GitStatusFile {
path: string;
oldPath?: string;
index: GitFileState;
workingTree: GitFileState;
}
export interface GitStatusResponse {
isGitRepo: boolean;
hash: string;
branch?: string;
upstream?: string;
ahead?: number;
behind?: number;
files: GitStatusFile[];
}
export interface GitDiffResponse {
path?: string;
staged: boolean;
hash: string;
diff: string;
truncated: boolean;
}
const MAX_OUTPUT = 2 * 1024 * 1024;
export async function gitStatus(cwd: string): Promise<GitStatusResponse> {