UNPKG

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