Skip to content

test: mock git config in signoff ignore-author test - #481

Merged
shenxianpeng merged 1 commit into
mainfrom
bugfix/signoff-test-mock-git-config
Jul 25, 2026
Merged

test: mock git config in signoff ignore-author test#481
shenxianpeng merged 1 commit into
mainfrom
bugfix/signoff-test-mock-git-config

Conversation

@shenxianpeng

@shenxianpeng shenxianpeng commented Jul 25, 2026

Copy link
Copy Markdown
Member

Summary

test_default_signoff_skips_ignored_author did not mock get_git_config_value, which makes it environment-dependent and fail on any machine where the developer has a local git config user.name set.

Root cause

Author resolution (_resolve_current_author) reads git config user.name first when validating a prospective message (stdin). The test only mocked get_commit_info (returning the ignored bot author), so with a real user.name configured, resolution returned the developer's name instead of dependabot[bot] — the author was not recognized as ignored, the signoff check ran, and the test failed. It only passed in environments where user.name happened to be unset (e.g. CI).

Fix

Mock get_git_config_value to return an empty string so author resolution deterministically falls back to the commit author (get_commit_info("an")), matching the test's intent. No production code changes.

Verification

  • The test now passes regardless of the local user.name setting.
  • Full test suite passes.

Generated by Claude Code

Summary by CodeRabbit

  • Tests
    • Updated test coverage to ensure default sign-off behavior correctly falls back to the commit author when local Git author configuration is unavailable.

test_default_signoff_skips_ignored_author did not mock get_git_config_value.
Since author resolution reads git config user.name first when validating a
prospective message, the test failed whenever the developer had user.name
configured locally (it only passed in environments where user.name was
unset). Mock it to return an empty string so resolution deterministically
falls back to the commit author.
@shenxianpeng
shenxianpeng requested a review from a team as a code owner July 25, 2026 06:05
@netlify

netlify Bot commented Jul 25, 2026

Copy link
Copy Markdown

Deploy Preview for commit-check ready!

Name Link
🔨 Latest commit 13e2893
🔍 Latest deploy log https://app.netlify.com/projects/commit-check/deploys/6a64521116b56c000801a9d3
😎 Deploy Preview https://deploy-preview-481--commit-check.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added bug Something isn't working tests Add test related changes labels Jul 25, 2026
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 492f6719-1ced-4ab3-af17-67fa9a812a54

📥 Commits

Reviewing files that changed from the base of the PR and between bd890f1 and 13e2893.

📒 Files selected for processing (1)
  • tests/engine_test.py

📝 Walkthrough

Walkthrough

Changes

Author resolution test

Layer / File(s) Summary
Mock git configuration in signoff test
tests/engine_test.py
test_default_signoff_skips_ignored_author patches git configuration lookup to return an empty value, ensuring author resolution uses the commit author fallback.

Estimated code review effort: 2 (Simple) | ~5 minutes

Suggested reviewers: zerwes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: mocking git config in the signoff ignore-author test.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix/signoff-test-mock-git-config

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.28%. Comparing base (bd890f1) to head (13e2893).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #481   +/-   ##
=======================================
  Coverage   97.28%   97.28%           
=======================================
  Files          12       12           
  Lines        1179     1179           
=======================================
  Hits         1147     1147           
  Misses         32       32           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed-hq

codspeed-hq Bot commented Jul 25, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 380 untouched benchmarks
⏩ 114 skipped benchmarks1


Comparing bugfix/signoff-test-mock-git-config (13e2893) with main (bd890f1)

Open in CodSpeed

Footnotes

  1. 114 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@shenxianpeng
shenxianpeng merged commit ae0362e into main Jul 25, 2026
33 checks passed
@shenxianpeng
shenxianpeng deleted the bugfix/signoff-test-mock-git-config branch July 25, 2026 06:26
@shenxianpeng shenxianpeng removed the bug Something isn't working label Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Add test related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant