Skip to content

Commit 506100f

Browse files
committed
update cli.ts
1 parent 4f215d5 commit 506100f

File tree

1 file changed

+5
-36
lines changed

1 file changed

+5
-36
lines changed

src/git/cli.ts

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const exec = util.promisify(childProcess.exec);
1313
/**
1414
* Run a `git` subcommand with options and return output.
1515
*/
16-
function _execute(cwd: string, subcommand: string, options: string[] = []) {
16+
export function execute(cwd: string, subcommand: string, options: string[] = []) {
1717
const command = `git ${subcommand} ${options.join(" ")}`;
1818

1919
const result = exec(command, { cwd });
@@ -44,8 +44,10 @@ async function _diffIndex(options: string[] = []): Promise<Array<string>> {
4444
...options,
4545
"HEAD",
4646
];
47-
const { stdout, stderr } = await _execute(
48-
getWorkspaceFolder(),
47+
48+
const workspace = getWorkspaceFolder()
49+
const { stdout, stderr } = await execute(
50+
workspace,
4951
cmd,
5052
fullOptions
5153
);
@@ -88,36 +90,3 @@ export async function getChanges() {
8890
}
8991
return allChanges;
9092
}
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)