-
-
Notifications
You must be signed in to change notification settings - Fork 320
/
Copy pathBranchSummary.ts
35 lines (31 loc) · 904 Bytes
/
BranchSummary.ts
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
import type { BranchSummary, BranchSummaryBranch } from '../../../typings';
export enum BranchStatusIdentifier {
CURRENT = '*',
LINKED = '+',
}
export class BranchSummaryResult implements BranchSummary {
public all: string[] = [];
public branches: { [p: string]: BranchSummaryBranch } = {};
public current: string = '';
public detached: boolean = false;
push(
status: BranchStatusIdentifier | unknown,
detached: boolean,
name: string,
commit: string,
label: string
) {
if (status === BranchStatusIdentifier.CURRENT) {
this.detached = detached;
this.current = name;
}
this.all.push(name);
this.branches[name] = {
current: status === BranchStatusIdentifier.CURRENT,
linkedWorkTree: status === BranchStatusIdentifier.LINKED,
name,
commit,
label,
};
}
}