[GH-ISSUE #182] squash-authorship doesn't accumulate total_ai_additions and total_ai_deletions from multiple commits #67

Closed
opened 2026-03-02 04:11:37 +03:00 by kerem · 2 comments
Owner

Originally created by @AtnesNess on GitHub (Nov 4, 2025).
Original GitHub issue: https://github.com/git-ai-project/git-ai/issues/182

Summary

When using git-ai squash-authorship to combine multiple commits, the command correctly preserves line-level attributions (which lines were written by AI vs human) but fails to accumulate the total_ai_additions and total_ai_deletions statistics from all the squashed commits. This causes the stats to only reflect the final commit rather than the cumulative AI work across all commits.

Reproduction Steps

  1. Create a feature branch and make multiple commits with AI assistance:

    git checkout -b feature/my-feature
    
    # Commit 1: AI adds 3 lines, deletes 2 lines
    git-ai checkpoint cursor example.py
    git add example.py
    git commit -m "AI: Add initial feature implementation"
    
    # Commit 2: AI adds 2 more lines, deletes 3 lines
    git-ai checkpoint cursor example.py
    git add example.py
    git commit -m "AI: Refine feature"
    
  2. Squash merge into main:

    git checkout main
    git merge --squash feature/my-feature
    git commit -m "Add feature"
    
  3. Run squash-authorship to preserve AI attributions:

    git-ai squash-authorship main <new_commit_sha> <old_feature_branch_sha>
    
  4. Check stats:

    git-ai stats
    

Expected Behavior

git-ai stats should show the cumulative AI work across all squashed commits:

{
  "total_ai_additions": 5,  // 3 + 2 = sum from both commits
  "total_ai_deletions": 5,  // 2 + 3 = sum from both commits
  "ai_additions": 4,         // Final state: 4 AI lines in the diff
  "ai_accepted": 4           // All 4 AI lines were accepted
}

This reflects the full development journey: the AI generated 5 lines total and deleted 5 lines total while building the feature, even though the final diff only shows 4 net AI-contributed lines.

Actual Behavior

git-ai stats only shows statistics from the final state, losing the development history:

{
  "total_ai_additions": 2,  // Only reflects final commit
  "total_ai_deletions": 3,  // Only reflects final commit
  "ai_additions": 4,         // Correct (final state)
  "ai_accepted": 4           // Correct (final state)
}
Originally created by @AtnesNess on GitHub (Nov 4, 2025). Original GitHub issue: https://github.com/git-ai-project/git-ai/issues/182 ## Summary When using `git-ai squash-authorship` to combine multiple commits, the command correctly preserves line-level attributions (which lines were written by AI vs human) but fails to accumulate the `total_ai_additions` and `total_ai_deletions` statistics from all the squashed commits. This causes the stats to only reflect the final commit rather than the cumulative AI work across all commits. ## Reproduction Steps 1. Create a feature branch and make multiple commits with AI assistance: ```bash git checkout -b feature/my-feature # Commit 1: AI adds 3 lines, deletes 2 lines git-ai checkpoint cursor example.py git add example.py git commit -m "AI: Add initial feature implementation" # Commit 2: AI adds 2 more lines, deletes 3 lines git-ai checkpoint cursor example.py git add example.py git commit -m "AI: Refine feature" ``` 2. Squash merge into main: ```bash git checkout main git merge --squash feature/my-feature git commit -m "Add feature" ``` 3. Run `squash-authorship` to preserve AI attributions: ```bash git-ai squash-authorship main <new_commit_sha> <old_feature_branch_sha> ``` 4. Check stats: ```bash git-ai stats ``` ## Expected Behavior `git-ai stats` should show the **cumulative** AI work across all squashed commits: ```json { "total_ai_additions": 5, // 3 + 2 = sum from both commits "total_ai_deletions": 5, // 2 + 3 = sum from both commits "ai_additions": 4, // Final state: 4 AI lines in the diff "ai_accepted": 4 // All 4 AI lines were accepted } ``` This reflects the full development journey: the AI generated 5 lines total and deleted 5 lines total while building the feature, even though the final diff only shows 4 net AI-contributed lines. ## Actual Behavior `git-ai stats` only shows statistics from the final state, losing the development history: ```json { "total_ai_additions": 2, // Only reflects final commit "total_ai_deletions": 3, // Only reflects final commit "ai_additions": 4, // Correct (final state) "ai_accepted": 4 // Correct (final state) } ```
kerem closed this issue 2026-03-02 04:11:37 +03:00
Author
Owner

@acunniffe commented on GitHub (Nov 4, 2025):

Definitely real. Tracked it down to how we merge stats in authorship logs.

I'm assuming you used the same AI prompt/thread for both of these AI inserts @AtnesNess ?

<!-- gh-comment-id:3485339748 --> @acunniffe commented on GitHub (Nov 4, 2025): Definitely real. Tracked it down to how we merge stats in authorship logs. I'm assuming you used the same AI prompt/thread for both of these AI inserts @AtnesNess ?
Author
Owner

@AtnesNess commented on GitHub (Nov 4, 2025):

I actually just use mock_ai preset. The test can be found here: https://github.com/acunniffe/git-ai/pull/184

<!-- gh-comment-id:3486938754 --> @AtnesNess commented on GitHub (Nov 4, 2025): I actually just use `mock_ai` preset. The test can be found here: https://github.com/acunniffe/git-ai/pull/184
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/git-ai#67
No description provided.