Skip to content

add pre-commit hook for ufmt#15

Merged
amyreese merged 6 commits intoomnilib:mainfrom
pmeier:pre-commit-hook
Sep 18, 2021
Merged

add pre-commit hook for ufmt#15
amyreese merged 6 commits intoomnilib:mainfrom
pmeier:pre-commit-hook

Conversation

@pmeier
Copy link
Copy Markdown
Contributor

@pmeier pmeier commented Sep 8, 2021

As the name implies, pre-commit is a framework for running programs before a commit is performed. Especially for code formatters like usort they are really handy, because you actually want to run them before every commit. After the installation you don't need to worry about forgetting to format your code ever again and CI being the next instance to tell you that something is up.

Fortunately, the only thing that needs to added to enable ufmt as a pre-commit hook is a minimal configuration file.

ToDo:

  • add documentation about the hook to the README
  • add a test workflow to make sure the hook can be installed and executed correctly (I no longer think this is needed, since we will rarely change the hook itself).

Copy link
Copy Markdown
Contributor Author

@pmeier pmeier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the configuration is sufficient, but if you can have a look at the other configuration options.

@pmeier
Copy link
Copy Markdown
Contributor Author

pmeier commented Sep 16, 2021

Ping @jreese.

@amyreese
Copy link
Copy Markdown
Member

Does this allow other projects to configure support for ufmt via pre-commit? I'm not very familiar with how that works.

@pmeier
Copy link
Copy Markdown
Contributor Author

pmeier commented Sep 16, 2021

Yes. If we have this config in the repository, other repositories can put ufmt in their .pre-commit-config.yaml file. A minimal example would look like this:

repos:
  - repo: https://github.com/omnilib/ufmt
    rev: 1.3.0
    hooks:
      - id: ufmt

If you now run pre-commit install, the hook defined in this PR will be run on the diff of every commit and thus removing the need to invoke it manually.

@pmeier pmeier marked this pull request as ready for review September 17, 2021 16:21
@pmeier pmeier requested a review from amyreese September 17, 2021 16:22
@pmeier
Copy link
Copy Markdown
Contributor Author

pmeier commented Sep 17, 2021

I'm confused: I've removed the backticks, but the RTD build is still showing them. Do I need to run something manually for the md -> rst conversion?

Edit: something probably gone wrong, but now RTD is showing the correct result.

@pmeier pmeier requested a review from amyreese September 17, 2021 19:11
@amyreese amyreese merged commit 7fcb51f into omnilib:main Sep 18, 2021
@pmeier pmeier deleted the pre-commit-hook branch September 18, 2021 05:37
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