Skip to content

Conversation

@jinzhongjia
Copy link
Owner

No description provided.

Add unit tests for buffer, git, and command modules.
Add -- separator to git commands in CommandBuilder.
Add window_stability_delay setting to config_validation.lua.
Check window visibility in Buffer._insert_commit_message.
Add fallback to git diff in Git.get_contextual_diff.
Remove fatal string check from CommandExecutor.run.
Add EmmyLua annotations and nil-safety checks to release notes functions
to ensure robust processing of commit data and version information.
Replace string shell commands and redirects with arrays in git.lua
and command.lua. Replace vim.fn.system with CommandExecutor and
replace vim.loop with vim.uv.
Replace string-based command generation in CommandBuilder with arrays to
improve cross-platform reliability. Update CommandExecutor and associated
tests to handle the new format and remove manual shell quoting logic.
Add GitUtils.path_join to handle platform-specific separators and
normalization. Replace manual string concatenation in git.lua and
tools/git.lua with the new helper.
@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 undertakes a significant refactoring of the gitcommit extension's interaction with Git, moving from potentially problematic shell string commands to a more robust and secure array-based command execution system. It introduces dedicated modules for building and executing Git commands, enhancing cross-platform compatibility and security. Additionally, it refines the commit message buffer handling, improves release note generation logic with better input validation, and adds a substantial suite of unit tests to ensure the reliability of these changes.

Highlights

  • Refactored Git Command Execution: Transitioned from string-based vim.fn.system calls to more robust and secure array-based commands for all Git operations, improving cross-platform compatibility and preventing shell injection issues.
  • Introduced CommandBuilder and CommandExecutor: A new command.lua module centralizes the construction of Git commands into arrays (CommandBuilder) and their execution (CommandExecutor), providing both synchronous and asynchronous execution capabilities.
  • Enhanced Commit Message Buffer Logic: The commit message buffer now intelligently handles cursor positioning only when visible and introduces a new window_stability_delay configuration option for auto-generation.
  • Improved Release Notes Generation: The release notes prompt generation logic received significant updates, including better input validation, new LuaDoc type definitions for commit information, and more robust handling of commit data.
  • Comprehensive Unit Test Coverage: Extensive unit tests have been added and updated across buffer.lua, command.lua, git.lua, git_tool.lua, git_utils.lua, and ui.lua to ensure the reliability and correctness of the new command execution system and related functionalities.

🧠 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.

@jinzhongjia jinzhongjia merged commit 60eb35c into main Dec 23, 2025
1 check passed
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 introduces a comprehensive suite of unit tests, which is a fantastic addition for ensuring the stability and correctness of the gitcommit extension. The extensive refactoring to use command arrays instead of strings for system calls is a major improvement for security and cross-platform reliability. I've found one issue with a new utility function and a minor improvement for one of the new tests. Overall, this is excellent work that significantly improves the quality of the codebase.

Comment on lines +227 to 253
function M.path_join(...)
local parts = { ... }
if #parts == 0 then
return ""
end

-- Normalize all parts to use forward slashes
local normalized = {}
for i, part in ipairs(parts) do
normalized[i] = part:gsub("\\+", "/")
end

-- Remove leading/trailing slashes from middle parts
for i = 2, #normalized - 1 do
normalized[i] = normalized[i]:gsub("^/", ""):gsub("/$", "")
end

-- Join with forward slashes
local result = table.concat(normalized, "/")

-- Convert to Windows backslashes if on Windows
if M.is_windows() then
result = result:gsub("/", "\\")
end

return result
end
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The custom path_join implementation has some bugs that can lead to incorrect paths with double separators (e.g., path_join('a/', 'b') would result in a//b). Since your project targets Neovim 0.8+, you can simplify this greatly and improve robustness by using the built-in vim.fs.joinpath. It's designed for this purpose and handles cross-platform differences correctly.

function M.path_join(...)
  return vim.fs.joinpath(...)
end

Comment on lines +785 to 794
T["release_notes_log"]["returns correct command"] = function()
local result = child.lua([[
local Command = require("codecompanion._extensions.gitcommit.tools.command")
return Command.CommandBuilder.release_notes_log("v1.0.0", "v1.1.0")
]])
h.eq(result[1], "git")
h.eq(result[2], "log")
h.eq(result[4], "--date=short")
h.eq(result[5], "v1.0.0..v1.1.0")
end
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This test for release_notes_log is a bit incomplete as it doesn't check for the --pretty=format argument at index 3. You can make the test more robust by comparing the entire resulting array.

T["release_notes_log"]["returns correct command"] = function()
  local result = child.lua([[
    local Command = require("codecompanion._extensions.gitcommit.tools.command")
    return Command.CommandBuilder.release_notes_log("v1.0.0", "v1.1.0")
  ]])
  h.eq({
    "git",
    "log",
    "--pretty=format:%h\x01%s\x01%an\x01%ad",
    "--date=short",
    "v1.0.0..v1.1.0",
  }, result)
end

@jinzhongjia jinzhongjia deleted the fix branch December 24, 2025 03:38
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