feat: add git helpers for diff and identify - #14
Open
panasheMuriro wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
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_diffto generate a patch-format diff of index vs.HEAD(with unborn-HEADsupport). - Added
get_git_identityto readuser.name/user.emailforSigned-off-bytrailers. - Added unit tests covering staged-diff scenarios and identity lookup.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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>
panasheMuriro
force-pushed
the
feat/git-helpers
branch
from
July 24, 2026 08:39
fcab704 to
5c18d35
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Done
get_staged_diffandget_git_identityhelpers togit.rs(viagit2), giving the upcominggitlance suggestcommand access to staged changes and the configured git identity for building LLM prompts andSigned-off-bytrailers.get_staged_diff, plus a test forget_git_identity.