You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[refactor-bot] Add a runGitSync helper for the repeated execFileSync(getGitExecutable()) calls #449
Current state
Every synchronous git call repeats the same boilerplate: execFileSync(getGitExecutable(), [...], { cwd, encoding: 'utf-8', env: getGitEnv(), maxBuffer: ... }). That pattern appears about 17 times in src/git/diff.ts (lines 198, 208, 224, 243, 282, 294, 304, 319, 356, 373, 435, 439, 441, 470, 482, 494) and in src/git/hook.ts:64 and :828. Each call site decides its own env, stdio, and maxBuffer, so a change to git invocation (for example, the executable or env policy) must be applied in many places.
Proposed change
Add runGitSync(args, options) in src/git/diff.ts that calls getGitExecutable(), defaults encoding to utf-8, and returns trimmed or raw stdout as the caller needs. Migrate the call sites in place. Each migrated call keeps its exact current options.
Affected files
src/git/diff.ts (listed lines above)
src/git/hook.ts:64 and :828
Risk
Medium. Several calls intentionally omit env (diff.ts:144, :477; hook.ts:64, :828), so the helper must not add getGitEnv() by default. Preserve per-call stdio and maxBuffer. Existing diff and hook unit and e2e tests cover these paths. No behavior change is intended.
valid: a refactor proposal; the repeated execFileSync(getGitExecutable(), ...) boilerplate exists as described, and the call sites that omit env (diff.ts:144, :477; hook.ts:64, :828) match the issue's risk note.
Likely location
src/git/diff.ts:198 (repeated calls through ~:494); src/git/hook.ts:64 and :828
Severity
low
Next step
Add runGitSync(args, options) in src/git/diff.ts that uses getGitExecutable() and does not default env to getGitEnv(). Migrate call sites one at a time, keeping each call's exact options, and run the existing git-diff and hook tests.
Activity
404-Page-Found commentedon Dec 5, 2026
Validity
valid: a refactor proposal; the repeated
execFileSync(getGitExecutable(), ...)boilerplate exists as described, and the call sites that omitenv(diff.ts:144, :477; hook.ts:64, :828) match the issue's risk note.Likely location
src/git/diff.ts:198 (repeated calls through ~:494); src/git/hook.ts:64 and :828
Severity
low
Next step
Add
runGitSync(args, options)in src/git/diff.ts that usesgetGitExecutable()and does not defaultenvtogetGitEnv(). Migrate call sites one at a time, keeping each call's exact options, and run the existing git-diff and hook tests.