1 | import { Config, Disposable, Project } from '../index';
|
2 |
|
3 |
|
4 | export class GitRepository {
|
5 |
|
6 |
|
7 | static open(path: string, options?: { refreshOnWindowFocus?: boolean | undefined }): GitRepository;
|
8 |
|
9 | constructor(path: string, options?: { refreshOnWindowFocus?: boolean | undefined; config?: Config | undefined; project?: Project | undefined });
|
10 |
|
11 | // Lifecycle
|
12 | /** Destroy this GitRepository object. */
|
13 | destroy(): void;
|
14 |
|
15 | /** Returns a boolean indicating if this repository has been destroyed. */
|
16 | isDestroyed(): boolean;
|
17 |
|
18 | // Event Subscription
|
19 | /**
|
20 | * Invoke the given callback when this GitRepository's destroy() method is
|
21 | * invoked.
|
22 | */
|
23 | onDidDestroy(callback: () => void): Disposable;
|
24 |
|
25 | /**
|
26 | * Invoke the given callback when a specific file's status has changed. When
|
27 | * a file is updated, reloaded, etc, and the status changes, this will be fired.
|
28 | */
|
29 | onDidChangeStatus(callback: (event: RepoStatusChangedEvent) => void): Disposable;
|
30 |
|
31 | /** Invoke the given callback when a multiple files' statuses have changed. */
|
32 | onDidChangeStatuses(callback: () => void): Disposable;
|
33 |
|
34 | // Repository Details
|
35 | /** A string indicating the type of version control system used by this repository. */
|
36 | getType(): 'git';
|
37 |
|
38 | /** Returns the string path of the repository. */
|
39 | getPath(): string;
|
40 |
|
41 | /** Returns the string working directory path of the repository. */
|
42 | getWorkingDirectory(): string;
|
43 |
|
44 | /** Returns true if at the root, false if in a subfolder of the repository. */
|
45 | isProjectAtRoot(): boolean;
|
46 |
|
47 | /** Makes a path relative to the repository's working directory. */
|
48 | relativize(): string;
|
49 |
|
50 | /** Returns true if the given branch exists. */
|
51 | hasBranch(branch: string): boolean;
|
52 |
|
53 | /** Retrieves a shortened version of the HEAD reference value. */
|
54 | getShortHead(path?: string): string;
|
55 |
|
56 | /** Is the given path a submodule in the repository? */
|
57 | isSubmodule(path: string): boolean;
|
58 |
|
59 | /**
|
60 | * Returns the number of commits behind the current branch is from the its
|
61 | * upstream remote branch. The default reference is the HEAD.
|
62 | * @param reference The branch reference name.
|
63 | * @param path The path in the repository to get this ifnromation for, only
|
64 | * needed if the repository contains submodules.
|
65 | * @return Returns the number of commits behind the current branch is from its
|
66 | * upstream remote branch.
|
67 | */
|
68 | getAheadBehindCount(reference: string, path?: string): { ahead: number; behind: number };
|
69 |
|
70 | |
71 |
|
72 |
|
73 |
|
74 | getCachedUpstreamAheadBehindCount(path?: string): { ahead: number; behind: number };
|
75 |
|
76 |
|
77 | getConfigValue(key: string, path?: string): string;
|
78 |
|
79 |
|
80 | getOriginURL(path?: string): string;
|
81 |
|
82 | |
83 |
|
84 |
|
85 |
|
86 | getUpstreamBranch(path?: string): string | null;
|
87 |
|
88 |
|
89 | getReferences(path?: string): { heads: string[]; remotes: string[]; tags: string[] };
|
90 |
|
91 |
|
92 | getReferenceTarget(reference: string, path?: string): string;
|
93 |
|
94 |
|
95 |
|
96 | isPathModified(path: string): boolean;
|
97 |
|
98 |
|
99 | isPathNew(path: string): boolean;
|
100 |
|
101 |
|
102 | isPathIgnored(path: string): boolean;
|
103 |
|
104 |
|
105 | getDirectoryStatus(path: string): number;
|
106 |
|
107 |
|
108 | getPathStatus(path: string): number;
|
109 |
|
110 |
|
111 | getCachedPathStatus(path: string): number | null;
|
112 |
|
113 |
|
114 | isStatusModified(status: number): boolean;
|
115 |
|
116 |
|
117 | isStatusNew(status: number): boolean;
|
118 |
|
119 |
|
120 | |
121 |
|
122 |
|
123 |
|
124 | getDiffStats(path: string): { added: number; deleted: number };
|
125 |
|
126 | |
127 |
|
128 |
|
129 |
|
130 | getLineDiffs(
|
131 | path: string,
|
132 | text: string,
|
133 | ): Array<{ oldStart: number; newStart: number; oldLines: number; newLines: number }>;
|
134 |
|
135 |
|
136 | |
137 |
|
138 |
|
139 |
|
140 | checkoutHead(path: string): boolean;
|
141 |
|
142 |
|
143 | checkoutReference(reference: string, create: boolean): boolean;
|
144 | }
|
145 |
|
146 | export interface RepoStatusChangedEvent {
|
147 | path: string;
|
148 |
|
149 | |
150 |
|
151 |
|
152 |
|
153 | pathStatus: number;
|
154 | }
|