Skip to content

[Maintainability] Duplicated, divergent git logic in batch.ts vs git/diff.ts #268

Description

@404-Page-Found

Summary

src/commands/batch.ts reimplements change detection, diff retrieval, and committing with bare git, temp files, and no untracked-file support — diverging from the canonical logic in src/git/diff.ts (resolveGitExecutable(), getUntrackedDiff(), 100MB buffer, git commit -F). This duplication has already produced divergent behavior (batch skips untracked-only repos) and will keep drifting as fixes land on one path only.

Location

  • src/commands/batch.ts:64-105gitHasChanges() / getGitDiff() duplicate src/git/diff.ts getStagedDiff() / getUnstagedDiff()
  • src/commands/batch.ts:110-135gitCommit() duplicates src/git/diff.ts commit()
  • Shared helpers already exist in src/git/diff.ts (getStagedDiff, getUnstagedDiff, commit)

Suggested fix

Reuse getStagedDiff() / getUnstagedDiff() / commit() from src/git/diff.ts inside batchCommand, removing the local helpers. The batch layer should only add the repo iteration logic, not git plumbing.

Impact

  • Two independent git code paths for the same operations; bug fixes and features (untracked files, executable resolution, diff limits) must be applied twice.
  • Directly caused the batch untracked-files bug and the bare-git inconsistency.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions