[PR #195] TEST stats range cmd #315

Closed
opened 2026-03-02 04:13:16 +03:00 by kerem · 0 comments
Owner

Original Pull Request: https://github.com/git-ai-project/git-ai/pull/195

State: closed
Merged: Yes


Add Test for git-ai stats Range Command

Motivation

The git-ai stats command supports Git range syntax (<commitBaseSha>..<commitHeadSha>) to compute aggregated statistics across multiple commits, but this functionality lacked test coverage. This test ensures the range command works correctly and maintains accurate statistics across commit ranges.

Changes

Added a comprehensive E2E test for the git-ai stats range command:

Test: git-ai stats range command works correctly

The test validates:

  • Stats aggregation across multiple commits
  • Correct handling of Git range syntax (commit1..commit2)
  • All stats fields are accurate (human_additions, ai_additions, ai_accepted, etc.)
  • Both authorship_stats and range_stats structures
  • Tool model breakdown with per-agent statistics

Test Scenario

The test creates a simple two-commit scenario:

  1. Commit 1: Human adds 3 lines to example.txt

    H: Human Line 1
    H: Human Line 2
    H: Human Line 3
    
  2. Commit 2: AI adds 5 lines to the same file

    AI: AI Line 1
    AI: AI Line 2
    AI: AI Line 3
    AI: AI Line 4
    AI: AI Line 5
    

The test then validates stats for two different ranges:

  • base..commit2: Should show 3 human + 5 AI additions
  • commit1..commit2: Should show only 5 AI additions

Validated Fields

The test verifies all important JSON fields:

authorship_stats

  • total_commits
  • commits_with_authorship
  • authors_commiting_authorship
  • authors_not_commiting_authorship
  • commits_without_authorship
  • commits_without_authorship_with_authors

range_stats

  • human_additions
  • mixed_additions
  • ai_additions
  • ai_accepted
  • total_ai_additions
  • total_ai_deletions
  • time_waiting_for_ai
  • git_diff_deleted_lines
  • git_diff_added_lines
  • tool_model_breakdown (with all sub-fields per agent)

Testing

Run the test with:

bats tests/e2e/user-scenarios.bats -f "git-ai stats range command works correctly"

Output:

✓ git-ai stats range command works correctly

Benefits

  • 🛡️ Prevents regressions - Ensures range syntax continues to work correctly
  • 📊 Stats accuracy - Validates that multi-commit aggregations are computed correctly
  • 🔍 Comprehensive validation - Tests both range scenarios and all stats fields
  • CI-ready - Integrates seamlessly with existing BATS test suite
**Original Pull Request:** https://github.com/git-ai-project/git-ai/pull/195 **State:** closed **Merged:** Yes --- # Add Test for `git-ai stats` Range Command ## Motivation The `git-ai stats` command supports Git range syntax (`<commitBaseSha>..<commitHeadSha>`) to compute aggregated statistics across multiple commits, but this functionality lacked test coverage. This test ensures the range command works correctly and maintains accurate statistics across commit ranges. ## Changes Added a comprehensive E2E test for the `git-ai stats` range command: **Test**: `git-ai stats range command works correctly` The test validates: - ✅ Stats aggregation across multiple commits - ✅ Correct handling of Git range syntax (`commit1..commit2`) - ✅ All stats fields are accurate (`human_additions`, `ai_additions`, `ai_accepted`, etc.) - ✅ Both `authorship_stats` and `range_stats` structures - ✅ Tool model breakdown with per-agent statistics ## Test Scenario The test creates a simple two-commit scenario: 1. **Commit 1**: Human adds 3 lines to `example.txt` ``` H: Human Line 1 H: Human Line 2 H: Human Line 3 ``` 2. **Commit 2**: AI adds 5 lines to the same file ``` AI: AI Line 1 AI: AI Line 2 AI: AI Line 3 AI: AI Line 4 AI: AI Line 5 ``` The test then validates stats for two different ranges: - `base..commit2`: Should show 3 human + 5 AI additions - `commit1..commit2`: Should show only 5 AI additions ## Validated Fields The test verifies all important JSON fields: ### `authorship_stats` - `total_commits` - `commits_with_authorship` - `authors_commiting_authorship` - `authors_not_commiting_authorship` - `commits_without_authorship` - `commits_without_authorship_with_authors` ### `range_stats` - `human_additions` - `mixed_additions` - `ai_additions` - `ai_accepted` - `total_ai_additions` - `total_ai_deletions` - `time_waiting_for_ai` - `git_diff_deleted_lines` - `git_diff_added_lines` - `tool_model_breakdown` (with all sub-fields per agent) ## Testing Run the test with: ```bash bats tests/e2e/user-scenarios.bats -f "git-ai stats range command works correctly" ``` Output: ``` ✓ git-ai stats range command works correctly ``` ## Benefits - 🛡️ **Prevents regressions** - Ensures range syntax continues to work correctly - 📊 **Stats accuracy** - Validates that multi-commit aggregations are computed correctly - 🔍 **Comprehensive validation** - Tests both range scenarios and all stats fields - ✅ **CI-ready** - Integrates seamlessly with existing BATS test suite
kerem 2026-03-02 04:13:16 +03:00
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#315
No description provided.