[PR #199] Add E2E Test for Interactive Rebase with Squash #319

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

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

State: closed
Merged: Yes


Overview

This PR adds comprehensive end-to-end testing to verify that authorship tracking is correctly preserved when performing interactive rebase operations with squash commands.

Changes

New Files

  • tests/e2e/squash-editor.sh: A bash script that automates the git interactive rebase editor by programmatically changing pick commands to squash for all commits except the first one.
  • tests/e2e/user-scenarios.bats: New test case "interactive rebase with squash preserves authorship"

Test Scenario

The test validates a complex multi-commit workflow involving both human and AI contributions:

  1. Base Commit: Creates initial Python Flask API structure
  2. Commit 1: Adds user creation endpoint
    • Human adds: 2 lines (route definition and function signature)
    • AI adds: 3 lines (data extraction and basic response)
  3. Commit 2: Adds documentation and improves validation
    • Human adds: 2 lines (TODO comments)
    • AI adds: 2 lines (username validation)
    • AI deletes: 1 line (replaces simple return with validation logic)
  4. Interactive Rebase: Squashes commits 1 and 2 into a single commit

What's Being Tested

The test verifies that after squashing:

  • Both AI and human attributions are preserved in the blame output
  • Line-level authorship tracking remains accurate
  • Statistics correctly aggregate across squashed commits:
    • 4 human additions preserved
    • 4 AI additions in final file
    • 5 total AI additions (including 1 later deleted)
    • 1 AI deletion tracked
  • Tool/model breakdown remains intact (mock_ai::unknown)

Key Features of the Test

  • Uses git-ai checkpoint to track authorship boundaries between human and AI edits
  • Employs the squash-editor.sh script via GIT_SEQUENCE_EDITOR for automated testing
  • Validates stats at each commit stage (before and after squashing)
  • Compares JSON output using the helper function compare_json
  • Includes detailed logging output for debugging (redirected to &3)

Why This Matters

Interactive rebase with squash is a common git workflow for cleaning up commit history before merging. This test ensures that git-ai's authorship tracking system correctly handles this operation, maintaining accurate attribution of code contributions even when commits are combined.

Testing

Run the test with:

bats tests/e2e/user-scenarios.bats -f "interactive rebase with squash preserves authorship"
  • Complements existing rebase tests in tests/rebase.rs and tests/merge_rebase.rs
  • Builds upon the checkpoint functionality tested throughout the test suite
  • Part of the broader git-ai authorship tracking system
**Original Pull Request:** https://github.com/git-ai-project/git-ai/pull/199 **State:** closed **Merged:** Yes --- ## Overview This PR adds comprehensive end-to-end testing to verify that authorship tracking is correctly preserved when performing interactive rebase operations with squash commands. ## Changes ### New Files - **`tests/e2e/squash-editor.sh`**: A bash script that automates the git interactive rebase editor by programmatically changing `pick` commands to `squash` for all commits except the first one. - **`tests/e2e/user-scenarios.bats`**: New test case `"interactive rebase with squash preserves authorship"` ### Test Scenario The test validates a complex multi-commit workflow involving both human and AI contributions: 1. **Base Commit**: Creates initial Python Flask API structure 2. **Commit 1**: Adds user creation endpoint - Human adds: 2 lines (route definition and function signature) - AI adds: 3 lines (data extraction and basic response) 3. **Commit 2**: Adds documentation and improves validation - Human adds: 2 lines (TODO comments) - AI adds: 2 lines (username validation) - AI deletes: 1 line (replaces simple return with validation logic) 4. **Interactive Rebase**: Squashes commits 1 and 2 into a single commit ### What's Being Tested The test verifies that after squashing: - ✅ Both AI and human attributions are preserved in the blame output - ✅ Line-level authorship tracking remains accurate - ✅ Statistics correctly aggregate across squashed commits: - 4 human additions preserved - 4 AI additions in final file - 5 total AI additions (including 1 later deleted) - 1 AI deletion tracked - ✅ Tool/model breakdown remains intact (`mock_ai::unknown`) ### Key Features of the Test - Uses `git-ai checkpoint` to track authorship boundaries between human and AI edits - Employs the `squash-editor.sh` script via `GIT_SEQUENCE_EDITOR` for automated testing - Validates stats at each commit stage (before and after squashing) - Compares JSON output using the helper function `compare_json` - Includes detailed logging output for debugging (redirected to `&3`) ## Why This Matters Interactive rebase with squash is a common git workflow for cleaning up commit history before merging. This test ensures that git-ai's authorship tracking system correctly handles this operation, maintaining accurate attribution of code contributions even when commits are combined. ## Testing Run the test with: ```bash bats tests/e2e/user-scenarios.bats -f "interactive rebase with squash preserves authorship" ``` ## Related - Complements existing rebase tests in `tests/rebase.rs` and `tests/merge_rebase.rs` - Builds upon the checkpoint functionality tested throughout the test suite - Part of the broader git-ai authorship tracking system
kerem 2026-03-02 04:13:17 +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#319
No description provided.