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 pre-commit support #133

Merged
merged 3 commits into from
May 20, 2024
Merged

Add pre-commit support #133

merged 3 commits into from
May 20, 2024

Conversation

alexandregv
Copy link
Contributor

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
Copy link
Contributor Author

alexandregv commented May 12, 2024

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 ?

@posener
Copy link
Owner

posener commented May 16, 2024

Sorry for the late reply.

This is cool.

I have no objection to add it.

Is there any way to test the integration?

@alexandregv
Copy link
Contributor Author

alexandregv commented May 17, 2024

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.

@posener
Copy link
Owner

posener commented May 20, 2024

Looks good.
Thanks for the contribution.

@posener posener merged commit 1e2e5c4 into posener:master May 20, 2024
0 of 3 checks passed
@alexandregv alexandregv deleted the feat/pre-commit branch May 21, 2024 00:07
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

Successfully merging this pull request may close these issues.

2 participants