Skip to content

test: add integration tests for commit-msg hook (GIT-84)#54

Merged
TonyCasey merged 1 commit intomainfrom
git-84
Feb 14, 2026
Merged

test: add integration tests for commit-msg hook (GIT-84)#54
TonyCasey merged 1 commit intomainfrom
git-84

Conversation

@TonyCasey
Copy link
Copy Markdown
Owner

@TonyCasey TonyCasey commented Feb 14, 2026

Summary

  • Adds comprehensive integration tests for the commit-msg hook end-to-end flow
  • 22 tests using real temp git repos created via createTestRepo() helper
  • Covers all acceptance criteria from GIT-84

Test Coverage

Basic Trailer Addition

  • AI-Agent and AI-Model trailers
  • AI-Confidence, AI-Lifecycle, AI-Memory-Id trailers

Memory Type Detection

  • Decision detection from "because" clause
  • Gotcha detection from "gotcha" keyword
  • Convention detection from patterns

Tag Inference

  • Tags from conventional commit scope
  • Tags from staged file paths

Skip Conditions

  • Skip if AI-Agent trailer already exists
  • Skip trailers when no agent detected

Config Options

  • autoAnalyze=false → only Agent/Model
  • inferTags=false → no tags
  • requireType=true → skip when no type detected
  • Custom defaultLifecycle

Claude Code Environment Detection

  • CLAUDECODE env var detection
  • ANTHROPIC_MODEL env var

Edge Cases

  • Empty commit message
  • Whitespace-only message
  • Special characters
  • Multiline message
  • Merge commit
  • Amend commit

Test Plan

  • All 22 integration tests pass
  • Full test suite passes (503 tests)
  • Type-check and lint pass

Closes GIT-84

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added comprehensive integration test suite for AI-generated commit message trailers, thoroughly validating correct behavior across configuration options, environment detection, memory type inference, tag suggestions, skip conditions, and edge cases including empty messages, special characters, multiline content, and merge/amend commits.

Tests the full commit-msg hook flow end-to-end:
- Basic trailer addition (Agent, Model, Confidence, Lifecycle, Memory-Id)
- Memory type detection (decision, gotcha, convention patterns)
- Tag inference from scope and staged files
- Skip conditions (existing trailers, no agent)
- Config options (autoAnalyze, inferTags, requireType, defaultLifecycle)
- Claude Code environment detection
- Edge cases (empty, whitespace, special chars, multiline, merge, amend)

22 integration tests using real temp git repos.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
AI-Agent: Claude-Code/2.1.42
AI-Model: claude-opus-4-5-20251101
Copilot AI review requested due to automatic review settings February 14, 2026 14:18
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 14, 2026

📝 Walkthrough

Walkthrough

Introduces comprehensive integration test suite for the git-mem commit-msg hook, validating AI-generated trailer appending across various scenarios including basic trailer addition, memory type detection, tag inference, configuration options, environment detection, and edge cases.

Changes

Cohort / File(s) Summary
Commit-msg Hook Integration Tests
tests/integration/hooks/hook-commit-msg.test.ts
Adds 581 lines of integration tests covering trailer generation (AI-Agent, AI-Model, AI-Confidence, AI-Lifecycle, AI-Memory-Id), memory type detection (AI-Decision, AI-Gotcha, AI-Convention), tag inference, skip conditions, config options (autoAnalyze, inferTags, requireType, defaultLifecycle), Claude Code environment detection, and edge cases (empty/whitespace/multiline/merge/amend messages). Includes test utilities for config and commit message file creation, and full lifecycle setup/teardown.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • Copilot
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test: add integration tests for commit-msg hook (GIT-84)' clearly and accurately describes the main change—adding comprehensive integration tests for the commit-msg hook, with a specific ticket reference.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch git-84

No actionable comments were generated in the recent review. 🎉


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive integration tests for the commit-msg hook, implementing end-to-end testing for the hook's functionality using real temporary git repositories. The tests verify that the hook correctly analyzes commit messages and adds appropriate AI-* trailers based on pattern detection, conventional commit parsing, and configuration settings.

Changes:

  • Adds 22 integration tests covering basic trailer addition, memory type detection, tag inference, skip conditions, configuration options, Claude Code environment detection, and edge cases
  • Implements helper functions writeCommitMsgConfig() and createCommitMsgFile() for test setup
  • Uses real git repositories created via the existing createTestRepo() helper from the integration test framework

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants