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