goreadme icon indicating copy to clipboard operation
goreadme copied to clipboard

Add pre-commit support

Open alexandregv opened this issue 2 months ago • 1 comments

pre-commit is "A framework for managing and maintaining multi-language pre-commit hooks", so kinda like a local CI. It's a popular tool with a lot of community-made hooks. I thought it would be very handy to have pre-commit support in goreadme, allowing to rewrite the readme each time the doc is changed, even before pushing.

The PR only consists of a new file used by pre-commit, and the new instructions in README. It has no impact on goreadme itself.
I tested it on a private repo and it works well.

alexandregv avatar May 12 '24 01:05 alexandregv

I just added a commit making the "Use as a command line tool" sentence a header too, since it was currently included in the "GitHub Action" section, which felt wrong. Let me know if that doesn't seem right to you. Btw, a little off-topic, but shouldn't it be updated to go install github.com/posener/goreadme/cmd/goreadme@latest ?

alexandregv avatar May 12 '24 02:05 alexandregv

Sorry for the late reply.

This is cool.

I have no objection to add it.

Is there any way to test the integration?

posener avatar May 16 '24 21:05 posener

Hi, thanks for the reply!

I just created a demo repo, here: https://github.com/alexandregv/goreadme-precommit-demo I pushed a main.go file with some sample Go doc, but I voluntarily skipped the pre-commit run, so you can do it yourself.

  1. Install pre-commit: https://pre-commit.com/#install
  2. Clone the demo repo
  3. In the cloned repo, run pre-commit install (to register the hooks in .git/hooks/)
  4. Modify the main.go file so you can commit it
  5. Commit, see the pre-commit logs
  6. Check the modified README ! It should now contain the go doc info I skipped earlier.

You can also force-run pre-commit at all times with pre-commit run --all-files.

alexandregv avatar May 17 '24 18:05 alexandregv

Looks good. Thanks for the contribution.

posener avatar May 20 '24 22:05 posener