name: History Rewrite Tests

on:
  push:
    paths:
      - 'scripts/history-rewrite/**'
      - '.github/workflows/history-rewrite-tests.yml'
  pull_request:
    paths:
      - 'scripts/history-rewrite/**'

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout with full history
        uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
        with:
          fetch-depth: 0

      - name: Install dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y bats shellcheck

      - name: Run Bats tests
        run: |
          bats ./scripts/history-rewrite/tests || exit 1

      - name: ShellCheck scripts
        run: |
          shellcheck scripts/history-rewrite/*.sh || true
