UNPKG

12.8 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 /** `--name-status` argument needed */
147 status?: DiffNameStatus;
148}
149
150export interface DiffResultBinaryFile {
151 file: string;
152 before: number;
153 after: number;
154 binary: true;
155
156 /** `--name-status` argument needed */
157 status?: string;
158}
159
160export interface DiffResult {
161 /** The total number of files changed as reported in the summary line */
162 changed: number;
163
164 /** When present in the diff, lists the details of each file changed */
165 files: Array<DiffResultTextFile | DiffResultBinaryFile>;
166
167 /** The number of files changed with insertions */
168 insertions: number;
169
170 /** The number of files changed with deletions */
171 deletions: number;
172}
173
174export interface FetchResult {
175 raw: string;
176 remote: string | null;
177 branches: {
178 name: string;
179 tracking: string;
180 }[];
181 tags: {
182 name: string;
183 tracking: string;
184 }[];
185 updated: {
186 name: string;
187 tracking: string;
188 to: string;
189 from: string;
190 }[];
191 deleted: {
192 tracking: string;
193 }[];
194}
195
196/** Represents the response to git.grep */
197export interface GrepResult {
198 paths: Set<string>;
199 results: Record<
200 string,
201 Array<{
202 line: number;
203 path: string;
204 preview: string;
205 }>
206 >;
207}
208
209/**
210 * The `InitResult` is returned when (re)initialising a git repo.
211 */
212export interface InitResult {
213 /**
214 * Boolean representing whether the `--bare` option was used
215 */
216 readonly bare: boolean;
217
218 /**
219 * Boolean representing whether the repo already existed (re-initialised rather than initialised)
220 */
221 readonly existing: boolean;
222
223 /**
224 * The path used when initialising
225 */
226 readonly path: string;
227
228 /**
229 * The git configuration directory - for a bare repo this is the same as `path`, in non-bare repos
230 * this will usually be a sub-directory with the name `.git` (or value of the `$GIT_DIR` environment
231 * variable).
232 */
233 readonly gitDir: string;
234}
235
236/**
237 * A parsed response summary for calls to `git mv`
238 */
239export interface MoveResult {
240 /**
241 * Array of files moved
242 */
243 moves: Array<{ from: string; to: string }>;
244}
245
246export interface PullDetailFileChanges {
247 [fileName: string]: number;
248}
249
250export interface PullDetailSummary {
251 changes: number;
252 insertions: number;
253 deletions: number;
254}
255
256export interface PullDetail {
257 /** Array of all files that are referenced in the pull */
258 files: string[];
259
260 /** Map of file names to the number of insertions in that file */
261 insertions: PullDetailFileChanges;
262
263 /** Map of file names to the number of deletions in that file */
264 deletions: PullDetailFileChanges;
265
266 summary: PullDetailSummary;
267
268 /** Array of file names that have been created */
269 created: string[];
270
271 /** Array of file names that have been deleted */
272 deleted: string[];
273}
274
275export interface PullResult extends PullDetail, RemoteMessageResult {}
276
277/**
278 * Wrapped with the `GitResponseError` as the exception thrown from a `git.pull` task
279 * to provide additional detail as to what failed.
280 */
281export interface PullFailedResult {
282 remote: string;
283 hash: {
284 local: string;
285 remote: string;
286 };
287 branch: {
288 local: string;
289 remote: string;
290 };
291 message: string;
292}
293
294/**
295 * Represents file name changes in a StatusResult
296 */
297export interface StatusResultRenamed {
298 from: string;
299 to: string;
300}
301
302export interface FileStatusResult {
303 /** Original location of the file, when the file has been moved */
304 from?: string;
305
306 /** Path of the file */
307 path: string;
308
309 /** First digit of the status code of the file, e.g. 'M' = modified.
310 Represents the status of the index if no merge conflicts, otherwise represents
311 status of one side of the merge. */
312 index: string;
313
314 /** Second digit of the status code of the file. Represents status of the working directory
315 if no merge conflicts, otherwise represents status of other side of a merge.
316 See https://git-scm.com/docs/git-status#_short_format for full documentation of possible
317 values and their meanings. */
318 working_dir: string;
319}
320
321/**
322 * The StatusResult is returned for calls to `git.status()`, represents the state of the
323 * working directory.
324 */
325export interface StatusResult {
326 not_added: string[];
327 conflicted: string[];
328 created: string[];
329 deleted: string[];
330
331 /**
332 * Ignored files are not listed by default, add `--ignored` to the task options in order to see
333 * this array of ignored files/paths.
334 *
335 * Note: ignored files will not be added to the `files` array, and will not be included in the
336 * `isClean()` calculation.
337 */
338 ignored?: string[];
339 modified: string[];
340 renamed: StatusResultRenamed[];
341 staged: string[];
342
343 /**
344 * All files represented as an array of objects containing the `path` and status in `index` and
345 * in the `working_dir`.
346 */
347 files: FileStatusResult[];
348
349 /**
350 * Number of commits ahead of the tracked branch
351 */
352 ahead: number;
353
354 /**
355 *Number of commits behind the tracked branch
356 */
357 behind: number;
358
359 /**
360 * Name of the current branch
361 */
362 current: string | null;
363
364 /**
365 * Name of the branch being tracked
366 */
367 tracking: string | null;
368
369 /**
370 * Detached status of the working copy, for more detail of what the working branch
371 * is detached from use `git.branch()`
372 */
373 detached: boolean;
374
375 /**
376 * Gets whether this represents a clean working branch.
377 */
378 isClean(): boolean;
379}
380
381/**
382 * Response retrieved when using the `git.tags` method
383 */
384export interface TagResult {
385 /**
386 * All tag names
387 */
388 all: string[];
389
390 /**
391 * The semver latest tag name or `undefined` when no tags are named in the response
392 */
393 latest: string | undefined;
394}
395
396/**
397 * The ListLogLine represents a single entry in the `git.log`, the properties on the object
398 * are mixed in depending on the names used in the format (see `DefaultLogFields`), but some
399 * properties are dependent on the command used.
400 */
401export interface ListLogLine {
402 /**
403 * When using a `--stat=4096` or `--shortstat` options in the `git.log` or `git.stashList`,
404 * each entry in the `ListLogSummary` will also have a `diff` property representing as much
405 * detail as was given in the response.
406 */
407 diff?: DiffResult;
408}
409
410export interface LogResult<T = DefaultLogFields> {
411 all: ReadonlyArray<T & ListLogLine>;
412 total: number;
413 latest: (T & ListLogLine) | null;
414}
415
416/**
417 * Where the file was deleted, if there is a modify/delete conflict
418 */
419export interface MergeConflictDeletion {
420 deleteRef: string;
421}
422
423/**
424 * Represents a single file with conflicts in the MergeSummary
425 */
426export interface MergeConflict {
427 /**
428 * Type of conflict
429 */
430 reason: string;
431
432 /**
433 * Path to file
434 */
435 file: string | null;
436
437 /**
438 * Additional detail for the specific type of conflict
439 */
440 meta?: MergeConflictDeletion;
441}
442
443export type MergeResultStatus = 'success' | string;
444
445export interface MergeDetail {
446 conflicts: MergeConflict[];
447 merges: string[];
448 result: MergeResultStatus;
449 readonly failed: boolean;
450}
451
452export type MergeResult = PullResult & MergeDetail;
453
454/**
455 *
456 */
457export interface PushResultPushedItem {
458 local: string;
459 remote: string;
460
461 readonly deleted: boolean;
462 readonly tag: boolean;
463 readonly branch: boolean;
464 readonly new: boolean;
465 readonly alreadyUpdated: boolean;
466}
467
468export interface RemoteMessagesObjectEnumeration {
469 enumerating: number;
470 counting: number;
471 compressing: number;
472 total: {
473 count: number;
474 delta: number;
475 };
476 reused: {
477 count: number;
478 delta: number;
479 };
480 packReused: number;
481}
482
483export interface RemoteMessages {
484 all: string[];
485 objects?: RemoteMessagesObjectEnumeration;
486}
487
488export interface PushResultRemoteMessages extends RemoteMessages {
489 pullRequestUrl?: string;
490 vulnerabilities?: {
491 count: number;
492 summary: string;
493 url: string;
494 };
495}
496
497export interface RemoteMessageResult<T extends RemoteMessages = RemoteMessages> {
498 remoteMessages: T;
499}
500
501export interface PushResultBranchUpdate {
502 head: {
503 local: string;
504 remote: string;
505 };
506 hash: {
507 from: string;
508 to: string;
509 };
510}
511
512export interface PushDetail {
513 repo?: string;
514 ref?: {
515 local: string;
516 };
517 pushed: PushResultPushedItem[];
518 branch?: {
519 local: string;
520 remote: string;
521 remoteName: string;
522 };
523 update?: PushResultBranchUpdate;
524}
525
526export interface PushResult extends PushDetail, RemoteMessageResult<PushResultRemoteMessages> {}
527
528/**
529 * @deprecated
530 * For consistent naming, please use `CommitResult` instead of `CommitSummary`
531 */
532export type CommitSummary = CommitResult;
533
534/**
535 * @deprecated
536 * For consistent naming, please use `MergeResult` instead of `MergeSummary`
537 */
538export type MergeSummary = MergeResult;
539
540/**
541 * @deprecated to aid consistent naming, please use `BranchSingleDeleteResult` instead of `BranchDeletionSummary`.
542 */
543export type BranchDeletionSummary = BranchSingleDeleteResult;
544
545/**
546 * @deprecated to aid consistent naming, please use `BranchMultiDeleteResult` instead of `BranchDeletionBatchSummary`.
547 */
548export type BranchDeletionBatchSummary = BranchMultiDeleteResult;
549
550export type MoveSummary = MoveResult;
551
552/**
553 * @deprecated to aid consistent naming, please use `LogResult` instead of `ListLogSummary`.
554 */
555export type ListLogSummary<T = DefaultLogFields> = LogResult<T>;