Skip to content

Commit 22edfb2

Browse files
committed
feat: test function in extension.ts
1 parent f845920 commit 22edfb2

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

src/extension.ts

Lines changed: 30 additions & 0 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
function _validateFoundRepos(git: API) {
@@ -57,9 +58,38 @@ async function _handleRepos(git: API, sourceControl: any) {
5758
*/
5859
async function _handleRepo(git: API) {
5960
const targetRepo = git.repositories[0];
61+
6062
await makeAndFillCommitMsg(targetRepo);
6163
}
6264

65+
async function _autofill(uri?: string) {
66+
const git = getGitExtension();
67+
68+
if (!git) {
69+
vscode.window.showErrorMessage("Unable to load Git Extension");
70+
return;
71+
}
72+
73+
if (git.repositories.length === 0) {
74+
vscode.window.showErrorMessage(
75+
"No repos found. Please open a repo or run git init then try this extension again."
76+
);
77+
return;
78+
}
79+
80+
vscode.commands.executeCommand("workbench.view.scm");
81+
82+
if (uri) {
83+
_handleRepos(git, uri);
84+
} else {
85+
_handleRepo(git);
86+
}
87+
88+
const templateName = await getCommitTemplateName()
89+
console.debug(templateName)
90+
91+
}
92+
6393
/**
6494
* Choose the relevant repo and apply autofill logic on files there.
6595
*/

0 commit comments

Comments
 (0)