Skip to content

Commit 52c59cb

Browse files
committed
feat: test function in extension.ts
1 parent 25a1f95 commit 52c59cb

File tree

1 file changed

+32
-24
lines changed

1 file changed

+32
-24
lines changed

src/extension.ts

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import * as vscode from "vscode";
88
import { API } from "./api/git";
99
import { makeAndFillCommitMsg } from "./autofill";
10+
import { getCommitTemplateName } from "./git/cli";
1011
import { getGitExtension } from "./gitExtension";
1112

1213
/**
@@ -30,38 +31,45 @@ async function _handleRepos(git: API, uri: any) {
3031
*/
3132
async function _handleRepo(git: API) {
3233
const targetRepo = git.repositories[0];
34+
3335
await makeAndFillCommitMsg(targetRepo);
3436
}
3537

38+
async function _autofill(uri?: string) {
39+
const git = getGitExtension();
40+
41+
if (!git) {
42+
vscode.window.showErrorMessage("Unable to load Git Extension");
43+
return;
44+
}
45+
46+
if (git.repositories.length === 0) {
47+
vscode.window.showErrorMessage(
48+
"No repos found. Please open a repo or run git init then try this extension again."
49+
);
50+
return;
51+
}
52+
53+
vscode.commands.executeCommand("workbench.view.scm");
54+
55+
if (uri) {
56+
_handleRepos(git, uri);
57+
} else {
58+
_handleRepo(git);
59+
}
60+
61+
const templateName = await getCommitTemplateName()
62+
console.debug(templateName)
63+
64+
}
65+
3666
/**
37-
* Setup this extension's autofill command to run when triggered.
67+
* Set up this extension's autofill command to run when triggered.
3868
*/
3969
export function activate(context: vscode.ExtensionContext) {
4070
const disposable = vscode.commands.registerCommand(
4171
"commitMsg.autofill",
42-
async (uri?) => {
43-
const git = getGitExtension();
44-
45-
if (!git) {
46-
vscode.window.showErrorMessage("Unable to load Git Extension");
47-
return;
48-
}
49-
50-
if (git.repositories.length === 0) {
51-
vscode.window.showErrorMessage(
52-
"No repos found. Please open a repo or run git init then try this extension again."
53-
);
54-
return;
55-
}
56-
57-
vscode.commands.executeCommand("workbench.view.scm");
58-
59-
if (uri) {
60-
_handleRepos(git, uri);
61-
} else {
62-
_handleRepo(git);
63-
}
64-
}
72+
_autofill
6573
);
6674

6775
context.subscriptions.push(disposable);

0 commit comments

Comments
 (0)