Skip to content

Commit e86b7cd

Browse files
committed
refactor: update cli.ts
1 parent df5867f commit e86b7cd

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/git/cli.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ import { Repository } from "../api/git";
99

1010
const exec = util.promisify(_exec);
1111

12+
const DIFF_INDEX_CMD = "diff-index";
13+
const DIFF_INDEX_OPTIONS = [
14+
"--name-status",
15+
"--find-renames",
16+
"--find-copies",
17+
"--no-color",
18+
];
19+
1220
/**
1321
* Run a `git` subcommand and return the result, with stdout and stderr available.
1422
*/
@@ -37,20 +45,12 @@ async function _diffIndex(
3745
options: string[] = [],
3846
): Promise<Array<string>> {
3947
const cwd = repository.rootUri.fsPath;
40-
const cmd = "diff-index";
41-
const fullOptions = [
42-
"--name-status",
43-
"--find-renames",
44-
"--find-copies",
45-
"--no-color",
46-
...options,
47-
"HEAD",
48-
];
49-
50-
const { stdout, stderr } = await _execute(cwd, cmd, fullOptions);
48+
const fullOptions = [...DIFF_INDEX_OPTIONS, ...options, "HEAD"];
49+
50+
const { stdout, stderr } = await _execute(cwd, DIFF_INDEX_CMD, fullOptions);
5151

5252
if (stderr) {
53-
console.debug(`stderr for 'git ${cmd}' command:`, stderr);
53+
console.debug(`stderr for 'git ${DIFF_INDEX_CMD}' command:`, stderr);
5454
}
5555

5656
const lines = stdout.split("\n");

0 commit comments

Comments
 (0)