Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to filter messages through command in commit_preprocessors #86

Closed
alerque opened this issue Apr 28, 2022 · 2 comments
Closed

Comments

@alerque
Copy link
Contributor

alerque commented Apr 28, 2022

Issue #84 was about a specific use case and the initial suggestion was a bit of a false start. By the end of the issue discussion I think there was a useful proposal in this comment.

The current use of commit_precocessors just allows a regex replacement to run on matching patterns. I propose a new feature that filters the message through an external command. The commit message would be passed on STDIN and a replacement read back from STDOUT. This would allow all sorts of filtering, format conversion, etc.

I think the remaining questions are things like:

  • Whether the external command filter should happen before/after/or exclusive of regex replacements. (To my use cases this is a bit of a wash.)
  • How exit codes should be considered. (I suggest any errors be considered fatal, a different approach might be to skip commits that error, but I suggest a different mechanism such as skipping anything that returns an empty string but a success exit code.)
  • Whether any useful ENV vars should be set that would enable a filter script to do fancier things like read the commit themselves (e.g. maybe setting the current commit sha in an env var would be useful).
@orhun
Copy link
Owner

orhun commented Jun 7, 2022

Hey!

I implemented this in 7d0786c:

[git]
commit_preprocessors = [
	{ pattern = "foo", replace_command = "pandoc -t commonmark"},
	{ pattern = 'bar', replace_command = 'rev | xargs echo "reversed: $@"' },
    { pattern = 'baz', replace_command = 'git show -s --format=%B $COMMIT_SHA' }
]

README.md is also updated with these examples.

Feel free to try it out 🐻

@orhun
Copy link
Owner

orhun commented Jul 12, 2022

0.8.1 is released with this feature.

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

No branches or pull requests

2 participants