Skip to content

Replace isomorphic-git with direct git calls#108

Open
bluwy wants to merge 1 commit into
mainfrom
no-iso-git
Open

Replace isomorphic-git with direct git calls#108
bluwy wants to merge 1 commit into
mainfrom
no-iso-git

Conversation

@bluwy

@bluwy bluwy commented Jun 14, 2026

Copy link
Copy Markdown
Member

Refactor git.ts to use the git diff and git ls-files commands to get the changed files, rather than isomorphic-git.

This uses a different technique to before, but should achieve the same result (which is covered by tests).

  • Before (isomorphic-git): Walks the ref worktree and current worktree to build changed files.
  • After (this PR): Generates file diffs with git diff and get untracked file additions with git ls-files, iterate throught the output to build the changed fles.

This new code is slightly more involved, but shouldn't be too hard to read.


Also, I refactored the git.log from isomorphic-git to a simple git rev-parse command. Later I think we can try not needing this at all and detect the error in getFileChanges directly.

Base automatically changed from update-integration to main June 14, 2026 19:10
Comment thread src/git.ts
return { additions, deletions };
}

async function getOidForRef(ref: string, cwd: string): Promise<string | null> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think cwd usually makes more sense as the first param

other than that - perhaps this should be getShaForRef/resolveSha? That's probably a better understood concept than oid and rev-parse should always resolve to a commit sha

Comment thread src/git.ts
}
}

async function findGitRoot(start: string): Promise<string | null> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm not mistaken, this could be git rev-parse --git-dir - but this is OK too

Comment thread src/git.ts
Comment on lines +140 to +142

additions.sort((a, b) => (a.path > b.path ? 1 : -1));
deletions.sort((a, b) => (a.path > b.path ? 1 : -1));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
additions.sort((a, b) => (a.path > b.path ? 1 : -1));
deletions.sort((a, b) => (a.path > b.path ? 1 : -1));

Comment thread src/git.ts
);
}
// Test executable files
if (stat.mode & 0o111) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it would be nice to have constants for those - then we wouldn't even need a comment like the one above this check

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants