import { z } from 'zod'; import { createDecorator, type ServiceIdentifier } from '#/_base/di/instantiation'; import type { GitWorkTree } from './workTree'; export type { GitWorkTree } from './workTree'; export const fsGitStatusSchema = z.enum([ 'clean', 'modified', 'added', 'deleted', 'renamed', 'untracked', 'ignored', 'conflicted', ]); export type FsGitStatus = z.infer; export const fsPullRequestSchema = z.object({ number: z.number().int().positive(), state: z.enum(['open', 'merged', 'closed', 'draft']), url: z.string().url(), }); export type FsPullRequest = z.infer; export const fsGitStatusRequestSchema = z.object({ paths: z.array(z.string().min(1)).optional(), }); export type FsGitStatusRequest = z.infer; export const fsGitStatusResponseSchema = z.object({ branch: z.string(), ahead: z.number().int().nonnegative(), behind: z.number().int().nonnegative(), entries: z.record(z.string(), fsGitStatusSchema), additions: z.number().int().nonnegative(), deletions: z.number().int().nonnegative(), pullRequest: fsPullRequestSchema.nullable(), }); export type FsGitStatusResponse = z.infer; export const fsDiffRequestSchema = z.object({ path: z.string().min(1), }); export type FsDiffRequest = z.infer; export const fsDiffResponseSchema = z.object({ path: z.string(), diff: z.string(), truncated: z.boolean(), }); export type FsDiffResponse = z.infer; export interface IGitService { readonly _serviceBrand: undefined; status(cwd: string, pathFilter?: ReadonlySet): Promise; diff(cwd: string, relPath: string, absPath: string): Promise; findWorkTree(cwd: string): Promise; } export const IGitService: ServiceIdentifier = createDecorator('gitService');