Skip to content

Conversation

@jinzhongjia
Copy link
Owner

No description provided.

- Add cherry_pick_skip operation
- Improve error messages with conflict resolution guidance
- Remove nested output/user_msg/llm_msg wrapper objects
- Remove setup handlers from tool definitions
- Rename agent to tools in all handler signatures
- Remove v17 compatibility code and comments
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jinzhongjia, 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 gitcommit extension by integrating a wide array of new Git functionalities. It empowers users with advanced remote repository management, efficient fetching and pulling capabilities, and robust tools for resolving merge and cherry-pick conflicts. The changes also include improvements to the development workflow through updated build targets and a comprehensive new test suite, ensuring a more reliable and versatile Git experience.

Highlights

  • Expanded Git Operations: Introduced comprehensive support for remote repository management (add, remove, rename, set-url), fetching updates, and pulling changes with rebase options.
  • Enhanced Conflict Resolution: Added new tools for managing conflicts during cherry-pick and merge operations, including abort, continue, and skip commands, as well as functions to list and display conflict markers in files.
  • Build System Improvements: Updated the Makefile with new targets for running tests, linting code with Stylua, and formatting code, along with a new dependency management target for mini.nvim.
  • Cross-Platform Compatibility: Implemented is_windows() and shell_quote() utility functions to ensure Git commands are correctly formatted and executed across different operating systems.
  • Refactored Tool Output Handling: Streamlined the internal handling of tool output for ai_release_notes, git_edit, and git_read to provide more consistent and simplified responses.
  • New Test Suite: Added a new test infrastructure using mini.test and created extensive unit tests for git_edit, git_read, and validation utilities to ensure robustness and correctness of the new features.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

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
Contributor

@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 is a great feature enhancement, adding support for more git commands like remote, fetch, and pull, as well as improving the cherry-pick and merge workflows with conflict handling. The introduction of tests using mini.nvim is a fantastic step towards improving code quality and maintainability. I've found a few areas for improvement, mainly around code duplication and a bug in pattern matching for git conflicts. I've also made some suggestions to improve the new test files.

I am having trouble creating individual review comments. Click here to see my feedback.

lua/codecompanion/_extensions/gitcommit/tools/git.lua (962)

critical

The Lua pattern used here to find git conflict markers is incorrect and will not work for multi-line conflict blocks. The . character in Lua patterns does not match newline characters, and the pattern itself seems to have typos (<<<<<<<. and ->). This will fail to detect most, if not all, real-world git conflicts.

A correct implementation would need to handle multi-line matching. Since Lua patterns don't have a simple multi-line flag, you could split the content by lines and process it, or use a more complex pattern that can handle newlines, for example by using string.find in a loop to find start and end markers.

lua/codecompanion/_extensions/gitcommit/tools/ai_release_notes.lua (3-20)

medium

There's duplicated code here. The helper functions is_windows and shell_quote are also defined in lua/codecompanion/_extensions/gitcommit/tools/git.lua. To avoid code duplication and improve maintainability, these functions should be extracted into a shared utility module (e.g., lua/codecompanion/_extensions/gitcommit/utils.lua) and required where needed.

lua/codecompanion/_extensions/gitcommit/tools/validation.lua (152-162)

medium

This implementation of first_error is not as robust as it could be. It iterates from 1 to max_idx, which assumes a dense array-like table. If the validations table is sparse (e.g., {[2] = err1, [4] = err2}), this loop will fail on validations[1]. A more robust approach would be to use ipairs which correctly handles standard Lua sequences, or if you need to support sparse tables, sort the keys first.

  for _, result in ipairs(validations) do
    if result then
      return result
    end
  end

tests/test_git_edit.lua (44)

medium

The test is hardcoded to expect 28 operations. While this works now, it will break every time a new operation is added, making the tests brittle. It would be more maintainable to get the list of valid operations from the VALID_OPERATIONS table in git_edit.lua and compare the lengths.

tests/test_git_read.lua (44)

medium

The test is hardcoded to expect 18 operations. This is brittle and will require updates whenever operations are added or removed. A more maintainable approach would be to get the list of valid operations from the source file and assert that the schema's enum count matches the source of truth.

@jinzhongjia
Copy link
Owner Author

/gemini review

Copy link
Contributor

@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 is an excellent and extensive refactoring of the git-related functionality. The introduction of git_utils.lua for pure functions and command.lua for command building and execution significantly improves the code's structure, testability, and maintainability. The move from Makefile to mise.toml is a great modernization of the development workflow. The addition of a comprehensive test suite is also a major improvement.

I've found a few issues, including a regression in the glob pattern matching and diff filtering, and a small bug in how pcall is used. My comments provide suggestions to address these points. Overall, this is a very strong contribution to the project.

- Fix show_conflict multiline pattern matching (. doesn't match newlines)
- Fix glob_to_lua_pattern missing [ and ] character escaping
- Fix stage_files/unstage_files losing second return value from pcall
- Replace hardcoded operation counts in tests with dynamic checks
- Add tests for square bracket escaping in glob patterns
- Add tests for sparse array handling in first_error
Add 37 new robustness tests covering:

- glob_to_lua_pattern: empty string, unicode, special chars, long input
- parse_conflicts: single/multiple/multiline conflicts, malformed input
- has_conflicts: basic detection
- filter_diff: empty diff, special filenames, unicode, malformed headers
- shell_quote_unix/windows: newlines, tabs, shell injection, metacharacters
- validation functions: various types without crash, special error messages

Extract conflict parsing to git_utils.lua for better testability.
@jinzhongjia
Copy link
Owner Author

/gemini review

Copy link
Contributor

@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 is an excellent pull request that significantly improves the structure, testability, and feature set of the gitcommit extension. The refactoring to introduce git_utils.lua and command.lua for pure functions and command execution is a fantastic move for maintainability. The addition of a comprehensive test suite is a major win for the project's long-term health. I've included a few suggestions to further reduce code duplication and improve robustness, but overall, this is a very high-quality contribution.

- Remove duplicate is_windows/shell_quote from command.lua, import from git_utils
- Refactor contributors() to limit results in Lua instead of platform-specific pipes
- Simplify filter_diff() by consolidating file path extraction logic
@jinzhongjia jinzhongjia merged commit cbb224d into main Dec 22, 2025
1 check passed
@jinzhongjia jinzhongjia deleted the feat/git-remote branch December 22, 2025 03:19
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.

2 participants