7 Posts Tagged ‘pre-commit’

(All tags.)


pre-commit: How to run hooks during a rebase

Let’s make your rebases soar!

pre-commit uses Git’s hook system to run tools when you commit. Unfortunately, Git doesn’t run any hooks when making a commit during a rebase. This can lead to you rebasing a branch and not realizing some code needs fixing, at least not until your CI system runs pre-commit (say, with pre-commit.ci).

Read more...

pre-commit: Various Ways to Run Hooks

Around and around the commit cycle goes…

pre-commit’s main mode of operation is to run hooks against changed files when you commit. But you can also run hooks without committing, using pre-commit run.

Read more...

Optimize your PNG’s with oxipng and pre-commit

Artist’s impression of a PNG optimizer.

PNG’s can be losslessly optimized to reduce their file size, by picking a better compression algorithm for the given image. The savings can be significant, like 50% (especially for macOS screenshots). This is an easy way to make web sites load faster.

Read more...

Introducing django-upgrade, a tool for upgrading your Django projects

Giddy-up, we’re going to the future!

Django deprecates a small list of features with every feature release, requiring us to update our projects, which can be monotonous. Today I’m announcing a new tool I’ve created, django-upgrade, that automates some of this drudgery for us all.

Read more...

Three Cheers for blacken-docs

Blacken all ye docs.

Black is the de facto standard code formatter for Python, and these days I use it on all my projects. blacken-docs is a tool that also allows you to apply Black to code samples in your docs. I recently rolled it out on my projects to great effect.

Read more...

Cheap Bug Protection With pre-commit’s Regex Hooks

You aren’t allowed to write that!

For all my linting needs these days I use the pre-commit framework. It has integrations with every tool I want to use, and uses Git’s hooks to prevent non-passing code from ever being committed.

Read more...

How to Disallow Auto-named Django Migrations

Migrating Pony

When you run Django’s manage.py makemigrations, it will try to generate a name for the migration based upon its contents. For example, if you are adding a single field, it will call the migration 0002_mymodel_myfield.py. However when your migration contains more than one step, it instead uses a simple ‘auto’ name with the current date + time, e.g. 0002_auto_20200113_1837.py. You can provide the -n/--name argument to makemigrations, but developers often forget this.

Read more...