Git Integration

Mutagoph integrates with Git for diff-based incremental testing.

Diff-Based Testing

Only test mutations in files changed since a specific commit:

# Changes since main branch
mutagoph run --diff-base main

# Changes in last commit
mutagoph run --diff-base HEAD~1

# Changes in PR (vs origin/main)
mutagoph run --diff-base origin/main

# Changes since specific commit
mutagoph run --diff-base abc1234

How It Works

  1. Gets list of changed .go files from git diff
  2. Gets changed line ranges within each file
  3. Only generates mutations for changed lines
  4. Tests only those mutations

Requirements

  • Project must be a git repository
  • Git must be available in PATH
  • Specified ref must exist

Use Cases

Pull Request Validation

Only test code changed in the PR:

# GitHub Actions
- name: Mutation Testing
  run: mutagoph run --diff-base origin/$

Incremental Development

Test only your recent changes:

# Test changes since last commit
mutagoph run --diff-base HEAD~1

# Test uncommitted changes
mutagoph run --diff-base HEAD

Branch Comparison

Compare mutation coverage between branches:

# Changes between branches
mutagoph run --diff-base feature-branch

Combining with Other Options

# Diff-based with quality gate
mutagoph run --diff-base main --min-score 80

# Diff-based with specific mutation set
mutagoph run --diff-base main --mutations standard

# Diff-based with HTML report
mutagoph run --diff-base main --output html --output-file pr-mutations.html

Performance Benefits

Diff-based testing is significantly faster:

Scenario Full Run Diff-Based
Large codebase Minutes Seconds
Small PR Overhead Fast
Incremental dev Slow Instant feedback