UNPKG

10.9 kBTypeScriptView Raw
1import { DefaultLogFields } from '../src/lib/tasks/log';
2
3export interface BranchSummaryBranch {
4 current: boolean;
5 name: string;
6 commit: string;
7 label: string;
8}
9
10export interface BranchSummary {
11 detached: boolean;
12 current: string;
13 all: string[];
14 branches: {
15 [key: string]: BranchSummaryBranch;
16 };
17}
18
19/**
20 * Represents the successful deletion of a single branch
21 */
22export interface BranchSingleDeleteSuccess {
23 branch: string;
24 hash: string;
25 success: true;
26}
27
28/**
29 * Represents the failure to delete a single branch
30 */
31export interface BranchSingleDeleteFailure {
32 branch: string;
33 hash: null;
34 success: false;
35}
36
37export type BranchSingleDeleteResult = BranchSingleDeleteFailure | BranchSingleDeleteSuccess;
38
39/**
40 * Represents the status of having deleted a batch of branches
41 */
42export interface BranchMultiDeleteResult {
43 /**
44 * All branches included in the response
45 */
46 all: BranchSingleDeleteResult[];
47
48 /**
49 * Branches mapped by their branch name
50 */
51 branches: { [branchName: string]: BranchSingleDeleteResult };
52
53 /**
54 * Array of responses that are in error
55 */
56 errors: BranchSingleDeleteResult[];
57
58 /**
59 * Flag showing whether all branches were deleted successfully
60 */
61 readonly success: boolean;
62}
63
64export interface CleanSummary {
65 readonly dryRun: boolean;
66 paths: string[];
67 files: string[];
68 folders: string[];
69}
70
71export interface CommitResult {
72 author: null | {
73 email: string;
74 name: string;
75 };
76 branch: string;
77 commit: string;
78 root: boolean;
79 summary: {
80 changes: number;
81 insertions: number;
82 deletions: number;
83 };
84}
85
86/** Represents the response to using `git.getConfig` */
87export interface ConfigGetResult {
88 /** The key that was searched for */
89 key: string;
90
91 /** The single value seen by `git` for this key (equivalent to `git config --get key`) */
92 value: string | null;
93
94 /** All possible values for this key no matter the scope (equivalent to `git config --get-all key`) */
95 values: string[];
96
97 /** The file paths from which configuration was read */
98 paths: string[];
99
100 /**
101 * The full hierarchy of values the property can have had across the
102 * various scopes that were searched (keys in this Map are the strings
103 * also found in the `paths` array).
104 */
105 scopes: Map<string, string[]>;
106}
107
108/**
109 * Represents the current git configuration, as defined by the output from `git log`
110 */
111export interface ConfigListSummary {
112
113 /**
114 * All configuration settings, where local/user settings override user/global settings
115 * the overridden value will appear in this object.
116 */
117 readonly all: ConfigValues;
118
119 /**
120 * The file paths configuration was read from
121 */
122 files: string[];
123
124 /**
125 * The `ConfigValues` for each of the `files`, use this object to determine
126 * local repo, user and global settings.
127 */
128 values: { [fileName: string]: ConfigValues };
129}
130
131/**
132 * Represents the map of configuration settings
133 */
134export interface ConfigValues {
135 [key: string]: string | string[];
136}
137
138export interface DiffResultTextFile {
139 file: string;
140 changes: number;
141 insertions: number;
142 deletions: number;
143 binary: false;
144}
145
146export interface DiffResultBinaryFile {
147 file: string;
148 before: number;
149 after: number;
150 binary: true;
151}
152
153export interface DiffResult {
154 /** The total number of files changed as reported in the summary line */
155 changed: number;
156
157 /** When present in the diff, lists the details of each file changed */
158 files: Array<DiffResultTextFile | DiffResultBinaryFile>;
159
160 /** The number of files changed with insertions */
161 insertions: number;
162
163 /** The number of files changed with deletions */
164 deletions: number;
165}
166
167export interface FetchResult {
168 raw: string;
169 remote: string | null;
170 branches: {
171 name: string;
172 tracking: string;
173 }[];
174 tags: {
175 name: string;
176 tracking: string;
177 }[];
178}
179
180/**
181 * The `InitResult` is returned when (re)initialising a git repo.
182 */
183export interface InitResult {
184 /**
185 * Boolean representing whether the `--bare` option was used
186 */
187 readonly bare: boolean;
188
189 /**
190 * Boolean representing whether the repo already existed (re-initialised rather than initialised)
191 */
192 readonly existing: boolean;
193
194 /**
195 * The path used when initialising
196 */
197 readonly path: string;
198
199 /**
200 * The git configuration directory - for a bare repo this is the same as `path`, in non-bare repos
201 * this will usually be a sub-directory with the name `.git` (or value of the `$GIT_DIR` environment
202 * variable).
203 */
204 readonly gitDir: string;
205}
206
207/**
208 * A parsed response summary for calls to `git mv`
209 */
210export interface MoveResult {
211 /**
212 * Array of files moved
213 */
214 moves: Array<{from: string, to: string}>;
215}
216
217export interface PullDetailFileChanges {
218 [fileName: string]: number;
219}
220
221export interface PullDetailSummary {
222 changes: number;
223 insertions: number;
224 deletions: number;
225}
226
227export interface PullDetail {
228 /** Array of all files that are referenced in the pull */
229 files: string[];
230
231 /** Map of file names to the number of insertions in that file */
232 insertions: PullDetailFileChanges;
233
234 /** Map of file names to the number of deletions in that file */
235 deletions: PullDetailFileChanges;
236
237 summary: PullDetailSummary;
238
239 /** Array of file names that have been created */
240 created: string[];
241
242 /** Array of file names that have been deleted */
243 deleted: string[];
244}
245
246export interface PullResult extends PullDetail, RemoteMessageResult {
247}
248
249/**
250 * Represents file name changes in a StatusResult
251 */
252export interface StatusResultRenamed {
253 from: string;
254 to: string;
255}
256
257export interface FileStatusResult {
258
259 /** Original location of the file, when the file has been moved */
260 from?: string
261
262 /** Path of the file */
263 path: string;
264
265 /** First digit of the status code of the file, e.g. 'M' = modified.
266 Represents the status of the index if no merge conflicts, otherwise represents
267 status of one side of the merge. */
268 index: string;
269
270 /** Second digit of the status code of the file. Represents status of the working directory
271 if no merge conflicts, otherwise represents status of other side of a merge. */
272 working_dir: string;
273}
274
275/**
276 * The StatusResult is returned for calls to `git.status()`, represents the state of the
277 * working directory.
278 */
279export interface StatusResult {
280 not_added: string[];
281 conflicted: string[];
282 created: string[];
283 deleted: string[];
284 modified: string[];
285 renamed: StatusResultRenamed[];
286 staged: string[];
287 files: FileStatusResult[];
288 ahead: number;
289 behind: number;
290 current: string | null;
291 tracking: string | null;
292
293 /**
294 * Gets whether this represents a clean working branch.
295 */
296 isClean(): boolean;
297}
298
299/**
300 * Response retrieved when using the `git.tags` method
301 */
302export interface TagResult {
303 /**
304 * All tag names
305 */
306 all: string[];
307
308 /**
309 * The semver latest tag name or `undefined` when no tags are named in the response
310 */
311 latest: string | undefined;
312}
313
314/**
315 * The ListLogLine represents a single entry in the `git.log`, the properties on the object
316 * are mixed in depending on the names used in the format (see `DefaultLogFields`), but some
317 * properties are dependent on the command used.
318 */
319export interface ListLogLine {
320 /**
321 * When using a `--stat=4096` or `--shortstat` options in the `git.log` or `git.stashList`,
322 * each entry in the `ListLogSummary` will also have a `diff` property representing as much
323 * detail as was given in the response.
324 */
325 diff?: DiffResult;
326}
327
328export interface LogResult<T = DefaultLogFields> {
329 all: ReadonlyArray<T & ListLogLine>;
330 total: number;
331 latest: (T & ListLogLine) | null;
332}
333
334/**
335 * Where the file was deleted, if there is a modify/delete conflict
336 */
337export interface MergeConflictDeletion {
338 deleteRef: string;
339}
340
341/**
342 * Represents a single file with conflicts in the MergeSummary
343 */
344export interface MergeConflict {
345
346 /**
347 * Type of conflict
348 */
349 reason: string;
350
351 /**
352 * Path to file
353 */
354 file: string | null;
355
356 /**
357 * Additional detail for the specific type of conflict
358 */
359 meta?: MergeConflictDeletion;
360}
361
362export type MergeResultStatus = 'success' | string;
363
364export interface MergeDetail {
365 conflicts: MergeConflict[];
366 merges: string[];
367 result: MergeResultStatus;
368 readonly failed: boolean;
369}
370
371export type MergeResult = PullResult & MergeDetail;
372
373/**
374 *
375 */
376export interface PushResultPushedItem {
377 local: string;
378 remote: string;
379
380 readonly deleted: boolean;
381 readonly tag: boolean;
382 readonly branch: boolean;
383 readonly new: boolean;
384 readonly alreadyUpdated: boolean;
385}
386
387export interface RemoteMessagesObjectEnumeration {
388 enumerating: number,
389 counting: number,
390 compressing: number,
391 total: {
392 count: number,
393 delta: number,
394 },
395 reused: {
396 count: number,
397 delta: number,
398 },
399 packReused: number,
400}
401
402export interface RemoteMessages {
403 all: string[];
404 objects?: RemoteMessagesObjectEnumeration;
405}
406
407export interface PushResultRemoteMessages extends RemoteMessages {
408 pullRequestUrl?: string;
409 vulnerabilities?: {
410 count: number;
411 summary: string;
412 url: string;
413 };
414}
415
416export interface RemoteMessageResult<T extends RemoteMessages = RemoteMessages> {
417 remoteMessages: T;
418}
419
420export interface PushResultBranchUpdate {
421 head: {
422 local: string;
423 remote: string;
424 };
425 hash: {
426 from: string;
427 to: string;
428 };
429}
430
431export interface PushDetail {
432 repo?: string;
433 ref?: {
434 local: string;
435 };
436 pushed: PushResultPushedItem[];
437 branch?: {
438 local: string;
439 remote: string;
440 remoteName: string;
441 };
442 update?: PushResultBranchUpdate;
443}
444
445export interface PushResult extends PushDetail, RemoteMessageResult<PushResultRemoteMessages> {
446}
447
448/**
449 * @deprecated
450 * For consistent naming, please use `CommitResult` instead of `CommitSummary`
451 */
452export type CommitSummary = CommitResult;
453
454/**
455 * @deprecated
456 * For consistent naming, please use `MergeResult` instead of `MergeSummary`
457 */
458export type MergeSummary = MergeResult;
459
460/**
461 * @deprecated to aid consistent naming, please use `BranchSingleDeleteResult` instead of `BranchDeletionSummary`.
462 */
463export type BranchDeletionSummary = BranchSingleDeleteResult;
464
465/**
466 * @deprecated to aid consistent naming, please use `BranchMultiDeleteResult` instead of `BranchDeletionBatchSummary`.
467 */
468export type BranchDeletionBatchSummary = BranchMultiDeleteResult;
469
470export type MoveSummary = MoveResult;
471
472/**
473 * @deprecated to aid consistent naming, please use `LogResult` instead of `ListLogSummary`.
474 */
475export type ListLogSummary<T = DefaultLogFields> = LogResult<T>;