Skip to content

feat(config): search .cliff.toml as alternative config file name#1482

Open
niklasmarderx wants to merge 1 commit intoorhun:mainfrom
niklasmarderx:feat/dot-cliff-toml-1446
Open

feat(config): search .cliff.toml as alternative config file name#1482
niklasmarderx wants to merge 1 commit intoorhun:mainfrom
niklasmarderx:feat/dot-cliff-toml-1446

Conversation

@niklasmarderx
Copy link
Copy Markdown

Closes #1446

What this does

When git-cliff searches for a config file it now checks both cliff.toml and .cliff.toml, in that order. Users who keep their configs under dot-prefixed names (a pattern common with .eslintrc, .rustfmt.toml, .prettierrc, etc.) can do the same for git-cliff without any extra flags.

How it works

A new CONFIG_CANDIDATES constant in git-cliff-core lists the names to try:

pub const CONFIG_CANDIDATES: &[&str] = &[DEFAULT_CONFIG, ".cliff.toml"];

All three lookup sites use this slice:

  • Config::retrieve_config_path — user-level config directory (and legacy macOS paths)
  • parent-directory walk in run_with_changelog_modifier — the ancestor search that finds a cliff.toml in a parent directory

cliff.toml is still index 0, so it always wins over .cliff.toml when both exist. DEFAULT_CONFIG and the --config default are unchanged, so existing setups are completely unaffected.

Testing

Added a unit test to config::test that asserts cliff.toml is first in CONFIG_CANDIDATES and that .cliff.toml is present.

When git-cliff looks for a configuration file it now checks both
cliff.toml and .cliff.toml, in that order. Users who prefer
dot-prefixed config files (a convention used by many other tools) can
rename their file without any other changes.

The new CONFIG_CANDIDATES constant drives all three lookup sites:
- retrieve_config_path (user-level config dir, including legacy macOS)
- the parent-directory walk in run_with_changelog_modifier

DEFAULT_CONFIG and the --config default value are unchanged so existing
setups are completely unaffected.

Closes orhun#1446
@niklasmarderx niklasmarderx requested a review from orhun as a code owner April 17, 2026 09:26
@welcome
Copy link
Copy Markdown

welcome bot commented Apr 17, 2026

Thanks for opening this pull request! Please check out our contributing guidelines! ⛰️

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.35%. Comparing base (ee8bfd1) to head (ab9f182).

Files with missing lines Patch % Lines
git-cliff-core/src/config.rs 0.00% 6 Missing ⚠️
git-cliff/src/lib.rs 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1482      +/-   ##
==========================================
- Coverage   47.40%   47.35%   -0.04%     
==========================================
  Files          24       24              
  Lines        2129     2131       +2     
==========================================
  Hits         1009     1009              
- Misses       1120     1122       +2     
Flag Coverage Δ
unit-tests 47.35% <0.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Allow reading configuration file from .cliff.toml or .config/cliff.toml

2 participants