Add --staged-only flag to fix unstaged changes attribution (Issue #16)#19
Closed
jalalatlassian wants to merge 2 commits intogit-ai-project:mainfrom
Closed
Add --staged-only flag to fix unstaged changes attribution (Issue #16)#19jalalatlassian wants to merge 2 commits intogit-ai-project:mainfrom
jalalatlassian wants to merge 2 commits intogit-ai-project:mainfrom
Conversation
…-ai-project#16) This commit implements a solution for Issue git-ai-project#16 where unstaged changes were incorrectly attributed to AI agents, corrupting attribution accuracy. Changes: - Add --staged-only flag to checkpoint command - Implement get_staged_files_only() to filter only staged changes - Add get_unstaged_files() to detect and warn about ignored files - Update command-line interface and help text - Add comprehensive tests for the new functionality When --staged-only is used: - Only staged changes (git add) are tracked for attribution - Unstaged changes are ignored with helpful warnings - Users are guided to stage changes or remove the flag This preserves backward compatibility while providing a path to accurate attribution. The flag can be made default in future releases. Fixes git-ai-project#16
71de20c to
f483933
Compare
- Update pre_commit.rs and tmp_repo.rs to pass staged_only=false - Fix test to check stderr instead of stdout for output - All tests now pass including comprehensive staged-only test suite
Collaborator
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.

Pull Request: Add --staged-only flag to fix unstaged changes attribution (Issue #16)
Summary
This PR implements a solution for Issue #16 where unstaged changes were incorrectly attributed to AI agents, corrupting attribution accuracy. The solution adds a
--staged-onlyflag that ensures only explicitly staged changes are tracked for attribution.Problem
Git-ai was attributing ALL working directory changes (staged, unstaged, and untracked) to the checkpoint author. This caused:
Solution
Added
--staged-onlyflag that:git add) for attributionChanges Made
1. Core Implementation (
src/commands/checkpoint.rs)staged_onlyparameter torun()functionget_staged_files_only()- filters only staged changes using git2::Status flagsget_unstaged_files()- detects unstaged changes for warnings2. Command-Line Interface (
src/main.rs)--staged-onlyflag parsing3. Comprehensive Testing (
tests/staged_only_attribution.rs)4. Manual Testing (
test_staged_only.sh)Usage Examples
Before (Problematic)
After (Fixed)
Backward Compatibility
Testing
Run the comprehensive test suite:
cargo test staged_only_attributionRun manual verification:
Future Considerations
This implementation provides a foundation for making staged-only the default behavior in future releases:
--staged-onlyflag (opt-in)--include-unstagedfor backward compatibilityFiles Changed
src/commands/checkpoint.rs(+74 lines) - Core implementationsrc/main.rs(+6 lines) - CLI interfacetests/staged_only_attribution.rs(+251 lines) - Comprehensive teststest_staged_only.sh(+73 lines) - Manual test scriptTotal: 407 additions, 3 deletions
Fixes
Closes #16
Review Notes