-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathgitExtension.ts
More file actions
39 lines (35 loc) · 1.03 KB
/
gitExtension.ts
File metadata and controls
39 lines (35 loc) · 1.03 KB
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
36
37
38
39
/**
* Git extension module.
*
* Perform tasks related to the built-in Git extension.
*
* This module takes care of the high-level flow of the extension, after a repo
* is selected in the `extension.ts` module.
*
* Flow:
* 1. read Git output
* 2. process it with the logic in the generate module
* 3. set the value in the commit message box.
*/
import * as vscode from "vscode";
import { GitExtension, Repository } from "./api/git";
/**
* Fetch the commit message in the Git Extension.
*/
export function getCommitMsg(repository: Repository): string {
return repository.inputBox.value;
}
/**
* Set the commit message in the Git Extension pane's input.
*/
export function setCommitMsg(repository: Repository, msg: string) {
repository.inputBox.value = msg;
}
/**
* Return VS Code's built-in Git extension.
*/
export function getGitExtension() {
const vscodeGit = vscode.extensions.getExtension<GitExtension>("vscode.git");
const gitExtension = vscodeGit && vscodeGit.exports;
return gitExtension && gitExtension.getAPI(1);
}