77import * as vscode from "vscode" ;
88import { API } from "./api/git" ;
99import { makeAndFillCommitMsg } from "./autofill" ;
10+ import { getCommitTemplateName } from "./git/cli" ;
1011import { getGitExtension } from "./gitExtension" ;
1112
1213/**
@@ -30,38 +31,45 @@ async function _handleRepos(git: API, uri: any) {
3031 */
3132async 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 */
3969export 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