Skip to content

Conversation

@ackkerman
Copy link
Owner

Summary

  • handle PATH using join_paths so tests work cross‑platform
  • add Windows compatible git shim scripts
  • use ORIG_PATH inside shims to call the real git

Testing

  • cargo test

https://chatgpt.com/codex/tasks/task_e_6880bd6cd2b08330b23ef46b770a6e3e

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @ackkerman, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the test suite's cross-platform compatibility, primarily by addressing how git shims and environment variables (specifically PATH) are handled. The changes enable the tests to run reliably on Windows by providing appropriate shim scripts and a robust mechanism for PATH manipulation, ensuring that the test environment correctly interacts with git.

Highlights

  • Cross-Platform Test Compatibility: Introduced platform-specific git shim scripts (.cmd for Windows, shell scripts for Unix-like systems) to ensure tests behave correctly across different operating systems.
  • Environment Variable Handling: Implemented a new helper function path_vars to manage the PATH environment variable in a cross-platform compatible way, correctly prepending the shim directory and preserving the original PATH.
  • Shim Script Refinement: Modified git shim scripts to utilize an ORIG_PATH environment variable. This allows the shims to temporarily restore the original system PATH when needing to call the real git executable (e.g., for git config commands), preventing recursion or incorrect behavior.
  • Test Code Simplification: Refactored test functions (connect_and_list_roundtrip, pull_falls_back_to_add, pull_with_custom_message, remove_mapping) to use the new path_vars helper, reducing duplication and improving clarity in how PATH is set for test commands.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully makes the test suite cross-platform by introducing platform-specific git shims and correctly handling the PATH environment variable. The use of std::env::join_paths and std::env::split_paths is a great improvement for portability.

My review focuses on improving the maintainability of the newly added test helpers. I've suggested refactoring to reduce code duplication between the shim-creation functions and improving the readability of the embedded shell scripts.

tests/cli.rs Outdated
.unwrap();

let script = if cfg!(windows) {
"@echo off\r\nif \"%1\"==\"config\" (\r\n set \"PATH=%ORIG_PATH%\"\r\n git %*\r\n) else (\r\n echo git %*\r\n exit /b 0\r\n)"

Choose a reason for hiding this comment

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

medium

This single-line batch script is a bit hard to read. For better readability and maintainability, you could format it as a multi-line string using the concat! macro. This combines string literals at compile time with no performance cost.

Suggested change
"@echo off\r\nif \"%1\"==\"config\" (\r\n set \"PATH=%ORIG_PATH%\"\r\n git %*\r\n) else (\r\n echo git %*\r\n exit /b 0\r\n)"
concat!(
"@echo off\r\n",
"if \"%1\"==\"config\" (\r\n",
" set \"PATH=%ORIG_PATH%\"\r\n",
" git %*\r\n",
") else (\r\n",
" echo git %*\r\n",
" exit /b 0\r\n",
")"
)

tests/cli.rs Outdated
&shim,

let script = if cfg!(windows) {
"@echo off\r\nif \"%1\"==\"config\" (\r\n set \"PATH=%ORIG_PATH%\"\r\n git %*\r\n) else if \"%1\"==\"remote\" if \"%2\"==\"get-url\" (\r\n exit /b 1\r\n) else if \"%1\"==\"subtree\" if \"%2\"==\"pull\" (\r\n echo hint: use 'git subtree add' 1>&2\r\n exit /b 1\r\n) else (\r\n echo git %*\r\n exit /b 0\r\n)"

Choose a reason for hiding this comment

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

medium

This long, single-line batch script is difficult to read and maintain. To improve readability, you can format it as a multi-line string using the concat! macro. This will make the script's logic much clearer without any runtime overhead.

Suggested change
"@echo off\r\nif \"%1\"==\"config\" (\r\n set \"PATH=%ORIG_PATH%\"\r\n git %*\r\n) else if \"%1\"==\"remote\" if \"%2\"==\"get-url\" (\r\n exit /b 1\r\n) else if \"%1\"==\"subtree\" if \"%2\"==\"pull\" (\r\n echo hint: use 'git subtree add' 1>&2\r\n exit /b 1\r\n) else (\r\n echo git %*\r\n exit /b 0\r\n)"
concat!(
"@echo off\r\n",
"if \"%1\"==\"config\" (\r\n",
" set \"PATH=%ORIG_PATH%\"\r\n",
" git %*\r\n",
") else if \"%1\"==\"remote\" if \"%2\"==\"get-url\" (\r\n",
" exit /b 1\r\n",
") else if \"%1\"==\"subtree\" if \"%2\"==\"pull\" (\r\n",
" echo hint: use 'git subtree add' 1>&2\r\n",
" exit /b 1\r\n",
") else (\r\n",
" echo git %*\r\n",
" exit /b 0\r\n",
")"
)

@ackkerman
Copy link
Owner Author

test(windows): forward git config to real Git in shim

  • build.rs now embeds a Rust‑compiled git_shim that:
    • detects git config and re‑executes the real git.exe with ORIG_PATH
    • keeps the subtree‑pull failure stub for fallback tests
    • prints echoed commands for all other sub‑commands
  • prevents infinite self‑recursion on Windows, fixing test timeouts

@ackkerman ackkerman merged commit 8b5d95c into main Jul 23, 2025
1 check passed
@ackkerman ackkerman deleted the 2025-07-23-make-test-cases-os-independent branch July 23, 2025 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants