Skip to content

Commit 4d3695f

Browse files
committed
refactor: move Git code to gitExtension.ts
1 parent d476a9f commit 4d3695f

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

src/extension.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
/**
22
* Extension module.
33
*
4-
* This sets up the extension's command entry point and applies the
5-
* prepare commit message module to a target branch.
4+
* This sets up the extension's command entry point and applies the prepare commit message module to
5+
* a target branch.
66
*/
77
import * as vscode from "vscode";
8-
import { API, GitExtension } from "./api/git";
8+
import { API } from "./api/git";
99
import { makeAndFillCommitMsg } from "./autofill";
10-
11-
/**
12-
* Return VS Code's builtin Git extension.
13-
*/
14-
function getGitExtension() {
15-
const vscodeGit = vscode.extensions.getExtension<GitExtension>("vscode.git");
16-
const gitExtension = vscodeGit && vscodeGit.exports;
17-
18-
return gitExtension && gitExtension.getAPI(1);
19-
}
10+
import { getGitExtension } from "./gitExtension";
2011

2112
/**
2213
* Flow for multiple repos in workspace and selecting just one. This is a rare flow.

src/gitExtension.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
/**
22
* Git extension module.
33
*
4-
* Perform tasks related to the builtin Git extension.
4+
* Perform tasks related to the built-in Git extension.
55
*
66
* This module takes care of the high-level flow of the extension, after a repo is selected in
77
* extension.ts module.
88
*
99
* This module handles reading git output, processes it with the logic in the generate module and
1010
* then finally sets it in the UI message box.
1111
*/
12-
import { Repository } from "./api/git";
12+
import * as vscode from "vscode";
13+
import { GitExtension, Repository } from "./api/git";
1314

1415
/**
1516
* Fetch the commit message in the Git Extension.
@@ -28,3 +29,13 @@ export function getCommitMsg(repository: Repository): string {
2829
export function setCommitMsg(repository: Repository, msg: string) {
2930
repository.inputBox.value = msg;
3031
}
32+
33+
/**
34+
* Return VS Code's built-in Git extension.
35+
*/
36+
export function getGitExtension() {
37+
const vscodeGit = vscode.extensions.getExtension<GitExtension>("vscode.git");
38+
const gitExtension = vscodeGit && vscodeGit.exports;
39+
40+
return gitExtension && gitExtension.getAPI(1);
41+
}

0 commit comments

Comments
 (0)