Pre-push

The following Git pre-push hook will ensure that files are auto-formatted before pushing.

If there are files that are formatted incorrectly, it will format them and generate a new commit.

Due to the way Git works, when this occurs, you will need to run git push again.

You can always run git push --no-verify to skip the pre-push hook.
.git/hooks/pre-push
1#!/bin/bash
2export TERM=xterm
3
4# Check for dirty files
5if [ -n "$(git status --porcelain)" ]; then
6 echo "Error: There are dirty files in the Git working directory."
7 exit 1
8fi
9
10qlty fmt
11
12# Check for dirty files after qlty fmt
13if [ -n "$(git status --porcelain)" ]; then
14 git add .
15 git commit -m "qlty fmt"
16
17 echo "NOTE: qlty fmt modified files. Please re-run git push."
18 exit 1
19fi
20
21exit 0