betterbib icon indicating copy to clipboard operation
betterbib copied to clipboard

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

Open skilkis opened this issue 3 years ago • 6 comments

@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.

skilkis avatar Jun 17 '21 12:06 skilkis

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

nschloe avatar Jun 23 '21 10:06 nschloe

@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?

skilkis avatar Jun 24 '21 13:06 skilkis

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.

nschloe avatar Jun 24 '21 13:06 nschloe

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

skilkis avatar Jun 25 '21 05:06 skilkis

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

JensHeinrich avatar Sep 13 '21 12:09 JensHeinrich

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

skilkis avatar Sep 17 '21 12:09 skilkis