Skip to content

feat: add git helpers for diff and identify - #14

Open
panasheMuriro wants to merge 2 commits into
canonical:mainfrom
panasheMuriro:feat/git-helpers
Open

feat: add git helpers for diff and identify#14
panasheMuriro wants to merge 2 commits into
canonical:mainfrom
panasheMuriro:feat/git-helpers

Conversation

@panasheMuriro

Copy link
Copy Markdown
Collaborator

Done

  • Added get_staged_diff and get_git_identity helpers to git.rs (via git2), giving the upcoming gitlance suggest command access to staged changes and the configured git identity for building LLM prompts and Signed-off-by trailers.
  • Includes unit tests covering no-staged-changes, staged-content, and unborn-HEAD cases for get_staged_diff, plus a test for get_git_identity.

Copilot AI review requested due to automatic review settings July 24, 2026 07:44
@panasheMuriro panasheMuriro self-assigned this Jul 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds git-centric helper functions to support upcoming gitlance suggest behavior by extracting staged changes and configured author identity via git2, with accompanying unit tests.

Changes:

  • Added get_staged_diff to generate a patch-format diff of index vs. HEAD (with unborn-HEAD support).
  • Added get_git_identity to read user.name / user.email for Signed-off-by trailers.
  • Added unit tests covering staged-diff scenarios and identity lookup.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/git.rs
Comment thread src/git.rs
gitlance suggest needs to read the currently staged changes (not a commit
range) and the configured git identity, to build an LLM prompt and append
a Signed-off-by trailer. Uses git2 (diff_tree_to_index) for consistency
with the rest of git.rs rather than shelling out to git.

Signed-off-by: Panashe Muriro <panashemuriro2021@gmail.com>
Covers get_staged_diff (nothing staged, staged content present, unborn HEAD) and get_git_identity.

Signed-off-by: Panashe Muriro <panashemuriro2021@gmail.com>
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