Skip to content

Conversation

@john-mutuma
Copy link
Owner

What does this PR do?

This PR improves the existing CopilotChat Git context integration by adding a branch picker. Users can now select from "staged", "unstaged", or any local branch when generating a Git diff context for CopilotChat prompts (such as generating pull request descriptions). This enhancement streamlines the workflow for referencing specific changes and branches directly within Neovim.

Changes made in this PR

  • CopilotChat Plugin:

    • Enhanced the existing git context to present a picker UI, allowing users to select "staged", "unstaged", or any local branch as the diff anchor.
    • Updated the context resolution logic to use the selected branch or state.
    • Added a prompt template for generating pull request titles and descriptions from code changes.
  • Utility Functions:

    • Added run_command in utils/common.lua for running shell commands and capturing output.
    • Added utils/git.lua with:
      • get_git_branches() to list all local branches.
      • get_git_diff(branch, git_dir) to get the diff for staged, unstaged, or a specific branch.

Why is it needed?

  • Improves usability by allowing users to easily select the desired diff anchor (branch, staged, or unstaged) via a UI prompt.
  • Makes it easier to generate context-aware prompts for CopilotChat, such as pull request descriptions, based on specific changes or branches.
  • Enhances the developer experience by streamlining Git operations within Neovim.

How have the changes been tested?

  • Manually tested the branch picker for various Git states (staged, unstaged, different branches).
  • Verified correct fetching and display of diffs for each selection.
  • Confirmed that the new prompt for pull request descriptions is available and functional.

Screenshots (if applicable)

N/A (UI is via Neovim prompt and CopilotChat window)

Checklist

  • Enhanced Git context with branch picker support
  • Added utility functions for Git operations
  • Added prompt template for pull request descriptions
  • Manual testing for different Git states and error handling
  • Code follows project conventions

- Add a git utility module to fetch branches and diffs using Lua.
- Integrate a "git" context into CopilotChat for selecting staged,
  unstaged, or branch diffs via vim.ui.select.
- Enable CopilotChat to generate PR titles and descriptions from code
  changes using the new git context.
- Add a common async system command helper for future extensibility.
@john-mutuma john-mutuma force-pushed the user/johnmutuma/copilot_git-diff_context branch from 917edee to 5b128a8 Compare May 26, 2025 15:05
@john-mutuma john-mutuma merged commit e8025b3 into develop May 26, 2025
@john-mutuma john-mutuma deleted the user/johnmutuma/copilot_git-diff_context branch May 26, 2025 15:09
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