-
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathgit.ts
More file actions
29 lines (24 loc) · 808 Bytes
/
git.ts
File metadata and controls
29 lines (24 loc) · 808 Bytes
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
import * as vscode from 'vscode';
import { Repository, Ref, Branch } from '../types/git.d';
export default class GitAdapter {
repo: Repository;
constructor(private readonly extensions: typeof vscode.extensions) {
const ext = this.extensions.getExtension('vscode.git')?.exports;
const api = ext.getAPI(1);
this.repo = api.repositories[0];
}
isGitRepo(): boolean {
return !!this.repo;
}
async show(branchName: string, fileDir: string): Promise<string> {
return this.repo.show(branchName, fileDir);
}
async allBranches(): Promise<Ref[]> {
return await this.repo.getBranches({
pattern: ''
});
}
async getBranch(name: string): Promise<Branch> {
return await this.repo.getBranch(name);
}
}