Repository navigation
feat(git): ignore commits listed in .git-blame-ignore-revs - #1585
Conversation
Adds a use_git_blame_ignore_revs config option that, when enabled, excludes: - commits whose hash (full or abbreviated) is listed in the repository's .git-blame-ignore-revs file, and - commits that only modify that file. Mirrors what 'git blame --ignore-revs-file' already does for blame output, letting large non-semantic commits (e.g. mass reformatting) stay out of the changelog the same way they stay out of blame. Closes orhun#1084
|
Thanks for opening this pull request! Please check out our contributing guidelines! ⛰️ |
Per review feedback: a config flag is unnecessary here since the behavior is a no-op when .git-blame-ignore-revs doesn't exist, so it can just be applied unconditionally.
|
Done — removed the config option, the filtering now always runs unconditionally (it's already a no-op when |
Per review: git.md documents config options, and this isn't one anymore (it's always-on behavior), so it doesn't belong there.
|
Moved the mention to |
|
Heads up: the Looks like it's an environment thing: this CI uses the floating |
|
Hey @orhun, just checking in — since this is approved, is there anything else needed from my side before it can be merged? Happy to make any further changes if so. No rush, just following up. |
orhun
left a comment
There was a problem hiding this comment.
LGTM, thanks!
Found a better spot for the documentation change afterall :)
|
Congrats on merging your first pull request! ⛰️ |
Since 2.14.0 a commit whose only changed file is `.git-blame-ignore-revs` was dropped from the changelog even when its hash is not listed in the file: the filter treated the file as a path to exclude on its own, a side effect of the revision exclusion from #1585 (issue #1643). The filter now retains solely on the listed hash prefixes — the same rule `git blame --ignore-revs-file` applies — while a missing file, comments and abbreviated hashes behave as before. The skipping-commits docs no longer claim the file's own commits are dropped. Tests: the listed commit is still excluded, an unlisted ignore-file-only commit is kept, and abbreviated hashes still match; without the fix the new assertions fail.
Description
Adds a
use_git_blame_ignore_revsboolean config option (defaultfalse) under[git]. When enabled, it excludes:.git-blame-ignore-revsfile, andMotivation and Context
Closes #1084. Mirrors what
git blame --ignore-revs-filealready does for blame output — lets large, non-semantic commits (mass reformatting, etc.) stay out of the changelog the same way they're already kept out of blame.Implementation notes:
Repository::filter_git_blame_ignore_revsmethod ingit-cliff-core/src/repo.rs, called right afterrepository.commits(...)ingit-cliff/src/lib.rs(same spot as the existinglimit_commitstruncation), gated by the new config flag..git-blame-ignore-revsfrom the repo'sroot_path()at runtime — no-op if the file doesn't exist.config/cliff.toml(the embedded default config template) — every other boolean inGitConfigis set explicitly there rather than via#[serde(default)], so I followed that existing convention.website/docs/configuration/git.mdfollowing the same style as the neighboringinclude_paths/exclude_pathsentries.How Has This Been Tested?
git-cliff-core/src/repo.rsusing the existingcreate_temp_repo/create_commit_with_filestest helpers:filter_git_blame_ignore_revs_removes_listed_and_ignore_file_only_commits: 4 commits (2 normal, 1 listed as ignored, 1 that only adds the ignore file) → asserts exactly the 2 normal ones remain.filter_git_blame_ignore_revs_is_a_no_op_without_the_file: confirms no-op when the file is absent.cargo test --workspace: passes (pre-existing, unrelated failures on this shallow clone come from a handful ofrepo::test::*tests that hardcode this repo's own tag/commit hashes — confirmed identical failures on a clean checkout before my change)..git-blame-ignore-revs), rangit-cliffwith the option off vs. on — off shows all 4 commits, on shows only the 2 unrelated ones.cargo +nightly fmt --all -- --check: clean.cargo clippy --tests: no new warnings introduced (one pre-existing unrelateduseless_borrows_in_formattinglint elsewhere inrepo.rsblocks a full-D warningsrun on this environment's clippy version, confirmed present on a clean checkout too).Types of Changes
Checklist:
cargo +nightly fmt --allcargo clippy --tests --verbose(see note above re: a pre-existing unrelated lint blocking-D warningsin this environment)cargo test