Repository navigation
Expand file tree
/
Copy pathgit.ts
More file actions
99 lines (84 loc) · 2.31 KB
/
Copy pathgit.ts
File metadata and controls
99 lines (84 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Types for the `git` IPC namespace — a git client over a Project's (or the
// workspace root's) own repository. See docs/reference/ipc-contract.md, "git".
export type GitChange =
| 'modified'
| 'added'
| 'deleted'
| 'renamed'
| 'copied'
| 'typechange'
| 'untracked'
| 'unmodified';
export interface GitFileChange {
/** Repo-relative, forward slashes. */
path: string;
/** Renames/copies only. */
origPath?: string;
/** X column of porcelain v2. */
index: GitChange;
/** Y column of porcelain v2. */
worktree: GitChange;
/** Unmerged (`u`) record. */
conflicted: boolean;
}
export type GitRepoState = 'clean' | 'merging' | 'rebasing' | 'cherry-picking' | 'reverting';
export interface GitBranchHead {
/** null when detached. */
name: string | null;
/** null on an unborn branch. */
oid: string | null;
upstream?: string;
ahead: number;
behind: number;
}
export type GitStatus =
| { isRepo: false }
| {
isRepo: true;
head: GitBranchHead;
state: GitRepoState;
files: GitFileChange[];
truncated: boolean;
};
export type GitDiffSource =
| { kind: 'worktree' } // index → worktree
| { kind: 'index' } // HEAD → index
| { kind: 'commit'; sha: string }; // sha^ → sha (Phase D)
export interface GitDiffLine {
kind: 'context' | 'add' | 'del';
text: string;
oldNo?: number;
newNo?: number;
}
export interface GitHunk {
header: string;
oldStart: number;
oldLines: number;
newStart: number;
newLines: number;
lines: GitDiffLine[];
}
export type GitFileDiff =
| { kind: 'text'; path: string; oldPath?: string; hunks: GitHunk[] }
| { kind: 'binary'; path: string }
| { kind: 'too-large'; path: string; bytes: number };
/** Every `git.*` method accepts this; absent `projectId` targets the active workspace's root. */
export interface GitTargetParams {
projectId?: string;
}
export interface GitDiffParams extends GitTargetParams {
path: string;
source: GitDiffSource;
}
export interface GitPathsParams extends GitTargetParams {
paths: string[];
}
export interface GitCommitParams extends GitTargetParams {
message: string;
amend?: boolean;
}
export interface GitCommitResult {
sha: string;
}
/** `GitStatus.files` cap — beyond it the list is cut and `truncated` is set. */
export const GIT_STATUS_FILE_LIMIT = 5_000;