feat: support more configuration files#1448
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1448 +/- ##
==========================================
+ Coverage 47.57% 47.65% +0.08%
==========================================
Files 24 24
Lines 2119 2122 +3
==========================================
+ Hits 1008 1011 +3
Misses 1111 1111
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Thanks for the PR! Just wanted to say this goes into the right direction. Let me know when this is ready for review |
Hey! I think the current code should work, but I want to explore a few changes first to make it a bit more robust. I'll be away for a couple of weeks though. I'll let you all know when it's ready. Or you can give it a try yourself if you are inclined. Cheers. |
|
Hey @orhun, it should be good for review now. I added a couple of tests and updated the documentation to cover the changes. I did notice there are some inconsistencies in how the configuration files are loaded, but I decided to leave that out of the scope of this PR. Eg:
Let me know your thoughts. |
|
|
||
| **git-cliff** will look for a configuration file first in the project directory, then in the global user directory. If no configuration file is found, **git-cliff** will use the default configuration values. | ||
|
|
||
| ## Project Configuration |
There was a problem hiding this comment.
I'm not sure if separating this section as Project and User Configuration makes sense here. What was the reasoning behind it?
There was a problem hiding this comment.
I wanted to avoid confusion since the naming convention for project and global user configurations are different.
Since the global user configuration is already scoped to git-cliff namespace, it doesn't make sense for additional scoping.
- ✔️
/home/<user>/.config/git-cliff/cliff.toml - ❌
/home/<user>/.config/git-cliff/.cliff.tomlunnecessary scoping, other programs (git, mise, etc) don't follow this convention - ❌
/home/<user>/.config/git-cliff/.config/cliff.tomlunnecessary scoping, other programs (git, mise, etc) don't follow this convention
I also used https://mise.jdx.dev/configuration.html#global-config-config-mise-config-toml as reference, they have a more detailed section for all the configuration files possible locations and patterns, and how they differ from each other.
There was a problem hiding this comment.
I think it would be cleaner to just list the actual paths it will search through instead of filenames and trying to explain relative path situations. E.g.
./cliff.toml./.cliff.toml./.config/.cliff.toml~/cliff.toml~/.cliff.toml~/.config/.cliff.toml
A bit more verbose, but easier to understand than trying to deduplicate parts of the paths.
ognis1205
left a comment
There was a problem hiding this comment.
Thanks for the PR!
This is slightly tangential to the changes in this PR, but I wanted to share a broader design thought.
From my perspective, git-cliff is fundamentally a project-level tool, and its configuration should ideally be tied to the repository to ensure reproducibility. In that sense:
- The presence of sections like
remoteincliff.tomlsuggests that the config is repository-specific - We already support generating a project-local config via
git cliff --init - Keeping configuration within the repository helps maintain consistency across environments
Given that, supporting xdg / os-specific config directories might introduce additional maintenance overhead while providing relatively limited benefit, and could blur the intended design direction.
Personally, I would even consider deprecating user-level cliff.toml at some point, if it aligns with the overall direction of the project.
Curious to hear what others think. cc: @orhun
| /// Check config files in order of priority. | ||
| /// cliff.toml has the highest priority to preserve | ||
| /// Backward compatibility cliff.toml > .cliff.toml > ... > .config/cliff.toml |
There was a problem hiding this comment.
I think the doc comment /// is unnecessary here since this is a test. The function name already explains the intent well, so we might not need an additional comment here.
This comment seems to describe the behavior of retrieve_project_config_path rather than the test itself. It might be better to move it to the function as a doc comment.
There was a problem hiding this comment.
I don't have a strong opinion either way. @orhun suggested moving it there #1448 (comment). What's the consensus/best practice here?
Description
Motivation and Context
Fixes #1446
How Has This Been Tested?
Screenshots / Logs (if applicable)
Types of Changes
Checklist:
cargo +nightly fmt --allcargo clippy --tests --verbose -- -D warningscargo test