orhun / git-cliff

A highly customizable Changelog Generator that follows Conventional Commit specifications ⛰️
https://git-cliff.org
Apache License 2.0
9.08k stars 192 forks source link

Improve documentation for replace and replace_command #609

Open Cyclonit opened 5 months ago

Cyclonit commented 5 months ago

Is there an existing issue or pull request for this?

Feature description

changelog.postprocessors and git.commit_preprocessors work on the entire changelog or git message respectively. The documentation does not clearly describe this. As a first time user, one might expect that either processor only affects the part of the input that actually matches the pattern.

For example, a postprocessor like the following would be expected to replace all occurrences of <REPO> with https://github.com/orhun/git-cliff. It replaces the entire changelog instead.

postprocessors = [
  { pattern = '<REPO>', replace_template = 'https://github.com/orhun/git-cliff' }
]

Desired solution

The documentation should be revised in all places to clearly state that pattern does not limit the scope of the replacement, but instead is only used to check if a given string is supposed to replaced entirely.

Alternatives considered

None

Additional context

No response

orhun commented 5 months ago

Agreed. We can also mention something like:

{ pattern = '.*', replace_command = 'typos --write-changes -' }

is the equivalent of:

echo "<matched_part_of_the_changelog>" | typos --write-changes -

Marked as good first issue, feel free to tackle this as well!