Skip to content

Add a pre-commit hooks #498

@COUR4G3

Description

@COUR4G3

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 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions