twisted / towncrier

Manage the release notes for your project.

Home Page:https://towncrier.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add a pre-commit hooks

COUR4G3 opened this issue · comments

I've been toying around with the idea of creating Towncrier pre-commit hooks, one most importantly just checking that the news fragments are valid and then maybe also one to actually build the news from fragments if they hadn't already been applied.

So we'd just need to create a .pre-commit-hooks.yaml and set up with the appropriate defaults. I'm going to go ahead and create a PR, but I thought an issue might be a better place to discuss any objections or ideas.

Thinking of a .pre-commit-hooks.yaml like:

- id: towncrier-check
  name: towncrier-check
  description: Check Towncrier news updates
  entry: towncrier --draft
  pass_filenames: false
  types: [text]
  files: newsfragments/
  language: python
- id: towncrier-update
  name: towncrier-update
  description: Update news with Towncrier
  entry: towncrier
  pass_filenames: false
  args: ["--yes"]
  files: newsfragments/
  language: python

And then in one of my project's cases were a use a different towncrier configuration, I'd implement my .pre-commit-config.yaml like:

repos:
  - repo: https://github.com/twisted/towncrier
    rev: trunk
    hooks:
      - id: towncrier-check
        files: $changelog\.d/

Thoughts and suggestions welcome 😄

And done in #499