Skip to content

Commit 25a1f95

Browse files
committed
feat: add functions to cli.ts
1 parent 64c2a9d commit 25a1f95

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/git/cli.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,36 @@ export async function getChanges() {
8888
}
8989
return allChanges;
9090
}
91+
92+
93+
/**
94+
* Get a value from the Git config.
95+
*
96+
* The CLI will assume local (project) project by default.
97+
*/
98+
export async function _getConfigValue(options: string[]) {
99+
const cmd = "config"
100+
101+
const { stdout, stderr } = await _execute(
102+
getWorkspaceFolder(),
103+
cmd,
104+
options
105+
);
106+
107+
if (stderr) {
108+
console.debug(`stderr for 'git ${cmd}' command:`, stderr);
109+
}
110+
111+
return stdout
112+
}
113+
114+
/**
115+
* Get the configured value for a commit template path if set, or empty string.
116+
*/
117+
export async function getCommitTemplateName() {
118+
try {
119+
return await _getConfigValue(['commit.template'])
120+
} catch (_e) {
121+
return ""
122+
}
123+
}

0 commit comments

Comments
 (0)