Skip to content

test: replace git CLI calls with gix library in test helpers - #364

Open
Ziinc wants to merge 3 commits into
mainfrom
claude/testrepo-helpers-gix-migration-kdm33n
Open

test: replace git CLI calls with gix library in test helpers#364
Ziinc wants to merge 3 commits into
mainfrom
claude/testrepo-helpers-gix-migration-kdm33n

Conversation

@Ziinc

@Ziinc Ziinc commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Refactor the test repository helpers to use the gix library directly instead of shelling out to git CLI commands. This improves test reliability and performance by eliminating subprocess overhead and external dependencies.

Key Changes

  • Repository initialization: Replace git init and git init --bare with gix::init() and gix::init_bare()
  • Configuration management: Implement append_git_config() to directly write git config INI format instead of using git config CLI
  • Branch operations:
    • Add set_head_branch() to point HEAD at a branch via gix ref transactions (works on unborn HEAD and for branch switching)
    • Add gix_create_branch_at_head() to create branches without switching to them
  • Commit creation:
    • Implement write_tree_from_dir() to recursively build git tree objects from working directory contents
    • Implement gix_commit_all() to stage and commit via gix, replacing git add and git commit CLI calls
  • Remote configuration: Replace git remote add with direct config file writing
  • Dependencies: Enable blocking-network-client and worktree-mutation features in gix to support the new operations

Notable Implementation Details

  • The write_tree_from_dir() function recursively builds tree objects while skipping .git, .jj, and .treq metadata directories
  • Unix file permissions (executable bit) are preserved when writing blobs
  • The set_head_branch() function handles both unborn HEAD (before first commit) and normal branch switching scenarios
  • Network-bound operations (push, fetch) still use git CLI as gix doesn't provide push support in this version
    https://claude.ai/code/session_01V1rj5DQEfaLSS3WUa8YML3

@Ziinc
Ziinc force-pushed the claude/testrepo-helpers-gix-migration-kdm33n branch from eab41da to 39b6aef Compare August 27, 2026 21:23
@Ziinc Ziinc changed the title Replace git CLI calls with gix library in test helpers test: replace git CLI calls with gix library in test helpers Aug 27, 2026
@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Ziinc commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

rust / test / windows-latest is red on the current head (22e4d90), but not from this PR's diff (only src-tauri/tests/e2e_test_helpers.rs changed here). The only two failures are:

  • pty::tests::removes_session_after_child_eof
  • pty::tests::echo_suppression_releases_output_after_bounded_buffer

Both are timing-sensitive PTY tests in src-tauri/src/pty.rs, unrelated to git/gix or TestRepo. I re-ran the failed jobs once and got the identical two failures both times (run 33120382758), so this isn't a one-off flake — it looks like a pre-existing Windows-timing issue in the PTY test suite. I don't have a fix for it in scope here; flagging it rather than widening this PR to touch pty.rs.

Everything else on this PR is green: Ubuntu/macOS Rust tests, JS unit/integration tests, CLI Binary, Deploy Web, and the conventional-title check.


Generated by Claude Code

claude added 3 commits August 28, 2026 15:31
…o git

Repo init, config, branch creation/switching, and add+commit now go
through gix (init, edit_reference, write_blob/write_object, commit).
Push and the bare-remote setup calls stay on the git CLI since this
gix version has no push support; JjVerifier and other assertion
helpers are untouched.
Committing via gix wrote objects and moved refs but never touched
.git/index, so git saw every working-tree file as untracked. Any
subsequent `git checkout` (used directly in several test files, and
by jj's colocated git backend) then refused to switch branches with
"would be overwritten by checkout". Rebuild and write the index from
the new tree after each gix commit to keep it in sync.
Git config values treat backslash as an escape character, so writing
a raw Windows path (C:\Users\...\remote.git) into [remote "origin"]
url produced "bad config line" and broke every with_remote() test on
windows-latest. Forward slashes parse the same path fine on all
platforms.
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