texworld / betterbib

:green_book: Command-line tools for bibliographies.
816 stars 42 forks source link

Add `--check` CLI option similar to Black for CI usage #186

Open skilkis opened 3 years ago

skilkis commented 3 years ago

@nschloe thanks for the awesome package, I'm enjoying using it so far! A feature request would be to have a --check option similar to the black code formatter that results in a non-zero exit code if betterbib were to make any changes. This would primarily be useful to use in CI services to check if the .bib file is up-to-date and has the right formatting.

nschloe commented 3 years ago

I don't think it'd be useful for betterbib or betterbib-sync, but it could perhaps added to betterbib-format.

skilkis commented 3 years ago

@nschloe the main use-case I have in mind would be to reject a PR if a bibliography file wasn't run through betterbib before a commit. What do you think?

nschloe commented 3 years ago

What do you think?

For sync it's not such a good idea because the online sources change once in a while which would suddenly break your tests.

skilkis commented 3 years ago

It's not a bug it's a feature 😂 Let's see if anyone else has a use for this feature request, otherwise I can implement the desired functionality with a diff as well. Thanks for the quick replies @nschloe

JensHeinrich commented 3 years ago

Dirty hack for you @skilkis : Use the pre-commit hook and pack it into your ci. If betterbib formatchanges anything, the hook fails

skilkis commented 3 years ago

@JensHeinrich that's a great suggestion! pre-commit would work well for this 🎉