Skip to content

feat: Add git tools - #104

Merged
gadenbuie merged 23 commits into
mainfrom
feat/git-tools
Oct 16, 2025
Merged

gadenbuie merged 23 commits into
mainfrom
feat/git-tools

Conversation

@gadenbuie

Copy link
Copy Markdown
Collaborator

Adds seven new git tools for basic repository operations using the {gert} package, enhancing functionality for status, diffs, commits, and branch management.

Implements 7 new git tools using the {gert} package:
- btw_tool_git_status() - Show working directory status
- btw_tool_git_diff() - View diffs between refs or working tree
- btw_tool_git_log() - List commit history
- btw_tool_git_commit() - Create commits
- btw_tool_git_branch_list() - List branches
- btw_tool_git_branch_create() - Create new branches
- btw_tool_git_branch_checkout() - Switch branches

Tools are conditionally registered only when {gert} is installed,
with runtime checks using check_installed("gert").

Generated with Claude Code
Creates tests/testthat/helpers-git.R with a helper function that
abstracts the common setup pattern for temporary git repositories.
This reduces duplication across all git tool tests and makes the
tests more maintainable.

Generated with Claude Code
Adds snapshots to capture the key outputs that are returned to LLMs
for each git tool. These snapshots provide a clear picture of the
data format and content being sent back, making it easier to validate
that tools are returning appropriate information.

Snapshots cover:
- git_status: file status tables and empty state messages
- git_diff: diff patches and no-changes messages
- git_log: commit history tables
- git_commit: commit confirmation messages
- git_branch_list: branch listing tables
- git_branch_create: branch creation confirmations
- git_branch_checkout: checkout confirmations

Generated with Claude Code
Creates a helper function in tests/testthat/helpers-git.R that
replaces variable git details (timestamps and commit SHAs) with
fixed placeholder values. This ensures snapshot tests don't change
on every test run.

The function:
- Replaces timestamps (YYYY-MM-DD HH:MM:SS) with "2025-10-11 12:13:14"
- Replaces 7-character commit SHAs with "abcd123"

All snapshot tests now use `transform = scrub_git_details` to
ensure stable, reproducible snapshots across test runs.

Generated with Claude Code
Use gert::git_diff_patch param docs and fix empty-diff detection (handle character vectors returned by git_diff_patch). Update tool description and man pages to clarify that the tool shows the diff for a single commit and note the limitation that diffing two arbitrary commits is not supported.
Add clickable action-link toggle to each tool group so users can select/deselect all
tools in a group from the btw_app UI. Introduce tool_group_icon() and refactor
set_tool_icon() to centralize group icons. Add a new 'difference' SVG icon used
for the git group.
Use enum include for git status: switch staged -> include; update tests and snapshot
@gadenbuie
gadenbuie merged commit a8b141b into main Oct 16, 2025
11 checks passed
@gadenbuie
gadenbuie deleted the feat/git-tools branch October 16, 2025 11:03
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.

1 participant