Repository: cookiecutter/cookiecutter-django

Issue:
[bug] Pre-commit hooks errors on first commit
## What happened?
git commit -m "Initial commit"
[WARNING] Unstaged files detected.
[INFO] Stashing unstaged files to /home/userl/.cache/pre-commit/patch1601055885.
Trim Trailing Whitespace.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing <app>/templates/base.html
Fixing utility/install_python_dependencies.sh
Fixing <app>/templates/account/password_reset_done.html

[WARNING] Stashed changes conflicted with hook auto-fixes... Rolling back fixes...
[INFO] Restored changes from /home/bill/.cache/pre-commit/patch1601055885.

## What should've happened instead?
Commit to git. This is blocking the commit process. Commit fails and log says file does not match after the trailing whitespace process changed the files.

## Additional details
git output:
Looking for git in: git
Using git 2.28.0 from git
> git rev-parse --git-dir
Open repository: /home/bill/projects/dfwtaichi
> git status -z -u
> git symbolic-ref --short HEAD
> git rev-parse master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
> git for-each-ref --sort -committerdate --format %(refname) %(objectname)
> git remote --verbose
> git config --get commit.template
> git show --textconv :config/settings/base.py
> git ls-files --stage -- /home/bill/projects/dfwtaichi/config/settings/base.py
> git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b
> git check-ignore -v -z --stdin
> git check-ignore -v -z --stdin
> git check-ignore -v -z --stdin
> git check-ignore -v -z --stdin
> git show --textconv :dfwtaichi/templates/account/password_reset_done.html
> git ls-files --stage -- /home/bill/projects/dfwtaichi/dfwtaichi/templates/account/password_reset_done.html
> git cat-file -s c59534afcf4b25c6f0c294d8c3730cf15f09e1d5
> git show --textconv :dfwtaichi/templates/base.html
> git ls-files --stage -- /home/bill/projects/dfwtaichi/dfwtaichi/templates/base.html
> git cat-file -s f37f1396ad7ca48c81e111d0b696c0201306d6ec
> git status -z -u
> git symbolic-ref --short HEAD
> git rev-parse master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
> git for-each-ref --sort -committerdate --format %(refname) %(objectname)
> git remote --verbose
> git config --get commit.template
> git show --textconv :dfwtaichi/templates/account/password_reset_done.html
> git ls-files --stage -- /home/bill/projects/dfwtaichi/dfwtaichi/templates/account/password_reset_done.html
> git cat-file -s c59534afcf4b25c6f0c294d8c3730cf15f09e1d5
> git status -z -u
> git symbolic-ref --short HEAD
> git rev-parse master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
> git for-each-ref --sort -committerdate --format %(refname) %(objectname)
> git remote --verbose
> git config --get commit.template
> git check-ignore -v -z --stdin
> git show --textconv :utility/install_python_dependencies.sh
> git ls-files --stage -- /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh
> git cat-file -s bdc181a51993964f5225d68b80e08eae70bf0d45
> git status -z -u
> git symbolic-ref --short HEAD
> git ls-files --stage -- /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh
> git rev-parse master
> git cat-file -s bdc181a51993964f5225d68b80e08eae70bf0d45
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
> git for-each-ref --sort -committerdate --format %(refname) %(objectname)
> git remote --verbose
> git show --textconv :utility/install_python_dependencies.sh
> git config --get commit.template
> git show --textconv :dfwtaichi/templates/base.html
> git ls-files --stage -- /home/bill/projects/dfwtaichi/dfwtaichi/templates/base.html
> git cat-file -s f37f1396ad7ca48c81e111d0b696c0201306d6ec
> git status -z -u
> git symbolic-ref --short HEAD
> git rev-parse master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
> git for-each-ref --sort -committerdate --format %(refname) %(objectname)
> git remote --verbose
> git config --get commit.template
> git show --textconv :dfwtaichi/templates/account/password_reset_done.html
> git ls-files --stage -- /home/bill/projects/dfwtaichi/dfwtaichi/templates/account/password_reset_done.html
> git cat-file -s c59534afcf4b25c6f0c294d8c3730cf15f09e1d5
> git show --textconv :config/settings/base.py
> git ls-files --stage -- /home/bill/projects/dfwtaichi/config/settings/base.py
> git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b
> git status -z -u
> git symbolic-ref --short HEAD
> git rev-parse master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
> git for-each-ref --sort -committerdate --format %(refname) %(objectname)
> git remote --verbose
> git config --get commit.template
> git status -z -u
> git symbolic-ref --short HEAD
> git rev-parse master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
> git for-each-ref --sort -committerdate --format %(refname) %(objectname)
> git remote --verbose
> git config --get commit.template
> git status -z -u
> git ls-files --stage -- /home/bill/projects/dfwtaichi/config/settings/base.py
> git symbolic-ref --short HEAD
> git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b
> git rev-parse master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
> git for-each-ref --sort -committerdate --format %(refname) %(objectname)
> git remote --verbose
> git show --textconv :config/settings/base.py
> git config --get commit.template
> git check-ignore -v -z --stdin
> git show --textconv HEAD:utility/install_python_dependencies.sh
> git show --textconv :utility/install_python_dependencies.sh
> git ls-tree -l HEAD -- /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh
> git ls-files --stage -- /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh
fatal: Not a valid object name HEAD
> git cat-file -s bdc181a51993964f5225d68b80e08eae70bf0d45
> git check-ignore -v -z --stdin
> git branch
> git rm --cached -r -- /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh
error: the following file has staged content different from both the
file and the HEAD:
    utility/install_python_dependencies.sh
(use -f to force removal)
> git ls-tree -l HEAD -- /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh
> git ls-files --stage -- /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh
fatal: Not a valid object name HEAD
> git cat-file -s bdc181a51993964f5225d68b80e08eae70bf0d45
> git ls-tree -l HEAD -- /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh
> git ls-files --stage -- /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh
fatal: Not a valid object name HEAD
> git cat-file -s bdc181a51993964f5225d68b80e08eae70bf0d45
> git show --textconv :dfwtaichi/templates/account/password_reset_done.html
> git ls-files --stage -- /home/bill/projects/dfwtaichi/dfwtaichi/templates/account/password_reset_done.html
> git cat-file -s c59534afcf4b25c6f0c294d8c3730cf15f09e1d5
> git show --textconv :config/settings/base.py
> git ls-files --stage -- /home/bill/projects/dfwtaichi/config/settings/base.py
> git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b
> git show --textconv :dfwtaichi/templates/base.html
> git ls-files --stage -- /home/bill/projects/dfwtaichi/dfwtaichi/templates/base.html
> git cat-file -s f37f1396ad7ca48c81e111d0b696c0201306d6ec
> git show --textconv :config/settings/base.py
> git ls-files --stage -- /home/bill/projects/dfwtaichi/config/settings/base.py
> git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b
> git ls-files --stage -- /home/bill/projects/dfwtaichi/config/settings/base.py
> git checkout -q -- /home/bill/projects/dfwtaichi/config/settings/base.py
> git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b
> git status -z -u
> git symbolic-ref --short HEAD
> git rev-parse master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
> git for-each-ref --sort -committerdate --format %(refname) %(objectname)
> git remote --verbose
> git config --get commit.template
> git status -z -u
> git symbolic-ref --short HEAD
> git rev-parse master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
> git for-each-ref --sort -committerdate --format %(refname) %(objectname)
> git remote --verbose
> git config --get commit.template
> git ls-tree -l HEAD -- /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh
> git ls-files --stage -- /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh
> git ls-files --stage -- /home/bill/projects/dfwtaichi/config/settings/base.py
> git cat-file -s bdc181a51993964f5225d68b80e08eae70bf0d45
fatal: Not a valid object name HEAD
> git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b
> git show --textconv HEAD:utility/install_python_dependencies.sh
> git show --textconv :utility/install_python_dependencies.sh
> git show --textconv :config/settings/base.py
> git ls-files --stage -- /home/bill/projects/dfwtaichi/config/settings/base.py
> git status -z -u
> git checkout -q -- /home/bill/projects/dfwtaichi/dfwtaichi/templates/base.html
> git symbolic-ref --short HEAD
> git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b
> git rev-parse master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
> git for-each-ref --sort -committerdate --format %(refname) %(objectname)
> git remote --verbose
> git config --get commit.template
> git status -z -u
> git symbolic-ref --short HEAD
> git rev-parse master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
> git for-each-ref --sort -committerdate --format %(refname) %(objectname)
> git remote --verbose
> git config --get commit.template
> git ls-tree -l HEAD -- /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh
> git ls-files --stage -- /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh
> git ls-files --stage -- /home/bill/projects/dfwtaichi/config/settings/base.py
> git cat-file -s bdc181a51993964f5225d68b80e08eae70bf0d45
fatal: Not a valid object name HEAD
> git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b
> git show --textconv HEAD:utility/install_python_dependencies.sh
> git show --textconv :utility/install_python_dependencies.sh
> git show --textconv :config/settings/base.py
> git ls-files --stage -- /home/bill/projects/dfwtaichi/config/settings/base.py
> git status -z -u
> git checkout -q -- /home/bill/projects/dfwtaichi/dfwtaichi/templates/account/password_reset_done.html
> git symbolic-ref --short HEAD
> git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b
> git rev-parse master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
> git for-each-ref --sort -committerdate --format %(refname) %(objectname)
> git remote --verbose
> git config --get commit.template
> git status -z -u
> git symbolic-ref --short HEAD
> git rev-parse master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
> git for-each-ref --sort -committerdate --format %(refname) %(objectname)
> git remote --verbose
> git config --get commit.template
> git ls-tree -l HEAD -- /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh
> git ls-files --stage -- /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh
> git ls-files --stage -- /home/bill/projects/dfwtaichi/config/settings/base.py
> git cat-file -s bdc181a51993964f5225d68b80e08eae70bf0d45
fatal: Not a valid object name HEAD
> git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b
> git show --textconv HEAD:utility/install_python_dependencies.sh
> git show --textconv :utility/install_python_dependencies.sh
> git show --textconv :config/settings/base.py
> git ls-files --stage -- /home/bill/projects/dfwtaichi/config/settings/base.py
> git status -z -u
> git checkout -q -- /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh
> git symbolic-ref --short HEAD
> git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b
> git rev-parse master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
> git for-each-ref --sort -committerdate --format %(refname) %(objectname)
> git remote --verbose
> git config --get commit.template
> git status -z -u
> git symbolic-ref --short HEAD
> git rev-parse master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
> git for-each-ref --sort -committerdate --format %(refname) %(objectname)
> git remote --verbose
> git config --get commit.template
> git check-ignore -v -z --stdin
> git ls-tree -l HEAD -- /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh
> git ls-files --stage -- /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh
> git ls-files --stage -- /home/bill/projects/dfwtaichi/config/settings/base.py
> git cat-file -s bdc181a51993964f5225d68b80e08eae70bf0d45
fatal: Not a valid object name HEAD
> git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b
> git show --textconv HEAD:utility/install_python_dependencies.sh
> git show --textconv :utility/install_python_dependencies.sh
> git show --textconv :config/settings/base.py
> git check-ignore -v -z --stdin
> git status -z -u
> git symbolic-ref --short HEAD
> git rev-parse master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
> git for-each-ref --sort -committerdate --format %(refname) %(objectname)
> git remote --verbose
> git config --get commit.template
> git ls-files --stage -- /home/bill/projects/dfwtaichi/config/settings/base.py
> git status -z -u
> git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b
> git symbolic-ref --short HEAD
> git rev-parse master
> git ls-tree -l HEAD -- /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh
> git ls-files --stage -- /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh
> git ls-files --stage -- /home/bill/projects/dfwtaichi/config/settings/base.py
> git show --textconv :config/settings/base.py
> git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b
> git cat-file -s bdc181a51993964f5225d68b80e08eae70bf0d45
fatal: Not a valid object name HEAD
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
> git for-each-ref --sort -committerdate --format %(refname) %(objectname)
> git remote --verbose
> git show --textconv HEAD:utility/install_python_dependencies.sh
> git show --textconv :utility/install_python_dependencies.sh
> git show --textconv :config/settings/base.py
> git config --get commit.template
> git ls-files --stage -- /home/bill/projects/dfwtaichi/config/settings/base.py
> git status -z -u
> git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b
> git symbolic-ref --short HEAD
> git rev-parse master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
> git for-each-ref --sort -committerdate --format %(refname) %(objectname)
> git remote --verbose
> git config --get commit.template
> git ls-files --stage -- /home/bill/projects/dfwtaichi/config/settings/base.py
> git status -z -u
> git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b
> git symbolic-ref --short HEAD
> git ls-tree -l HEAD -- /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh
> git ls-files --stage -- /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh
> git ls-files --stage -- /home/bill/projects/dfwtaichi/config/settings/base.py
> git show --textconv :config/settings/base.py
> git cat-file -s bdc181a51993964f5225d68b80e08eae70bf0d45
fatal: Not a valid object name HEAD
> git rev-parse master
> git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b
> git show --textconv HEAD:utility/install_python_dependencies.sh
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
> git for-each-ref --sort -committerdate --format %(refname) %(objectname)
> git remote --verbose
> git show --textconv :utility/install_python_dependencies.sh
> git show --textconv :config/settings/base.py
> git config --get commit.template
> git ls-files --stage -- /home/bill/projects/dfwtaichi/config/settings/base.py
> git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b

<!-- To assist you best, please include commands that you've run, options you've selected and any relevant logs -->

* Host system configuration: 
    * Version of cookiecutter CLI (get it with `cookiecutter --version`):
    * OS:
    * Python version:
    * Docker versions (if using Docker):
    * ...
* Options selected and/or [replay file](https://cookiecutter.readthedocs.io/en/latest/advanced/replay.html):
    ``` 
    ```
<summary>
Logs:
<details>
<pre>
$ cookiecutter https://github.com/pydanny/cookiecutter-django
project_name [Project Name]: ...
</pre>
</details>
</summary>



Discussion:
So I tried running pre-commit run --all-files several times until the run showed that all tests had passed.
Now git commit is failing with 
[ERROR] Your pre-commit configuration is unstaged
'git add .pre-commit-config.yaml' to fix this.

However, I don't see that file anywhere.
So, I found the .yaml file and did a git add on it.
pre-commit run --all-files returns Passed for all tests
git commit still will not run due to end of file fixes to a bunch of the files, including License and README.rst
"Stashed changes conflicted with hook auto-fixes.... Rolling back fixes.
Ok, I ran pre-commit uninstall
I then had to re-run git add .
git commit now works.
I can still use pre-commit run --all-files to fix up the files before the commit.
Still seems fairly awkward.
Yes, it's in the name. Once your files change, you need to re add all the new lines of code that black or the other hooks may have changed by doing `git add .`. If the hook fails, then the commit isn't generated; do git add then recommit.

Although I'm curious: did you not pre-commit install at first? The only way you could have gotten that error in the first place was by installing pre-commit...
I did pre-commit install at first. The problem was that it indicated that it was rolling back any changes when the commit failed, that un-doing the changes done by the pre-commit steps. I have to leave pre-commit uninstalled to get a commit to work.
Interesting. I don't think I've ever had pre-commit unroll the changes. I wonder if it's because of the linter's versions. This is my pre-commit configuration:

```
exclude: 'docs|node_modules|.git|.tox|.idea'
default_stages: [commit]

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: master
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
      - id: check-yaml

  - repo: https://github.com/psf/black
    rev: 20.8b1
    hooks:
      - id: black

  - repo: https://github.com/timothycrosley/isort
    rev: 4.3.21
    hooks:
      - id: isort
        args: ['--settings-path=setup.cfg', '-rc']
```

The problem I had before was that isort 5 wasn't compatible with black (or I couldn't get the configurations right) so I just stayed on isort 4. Try using that version instead.

If pre-commit fails because it fixed something, re run `git add .` and then `git commit`. Hopefully that info helped!
Ok, tried it. Now black and isort are disagreeing on one of the files. When isort changes the file, black changes is back.
    bc
Hm that's just something you'll have to work out in setup.cfg. Can you describe what's actually being changed to and fro? I only had that happen when isort was on version 5.

Resolving patch:
diff --git a/{{cookiecutter.project_slug}}/config/settings/base.py b/{{cookiecutter.project_slug}}/config/settings/base.py
--- a/{{cookiecutter.project_slug}}/config/settings/base.py
+++ b/{{cookiecutter.project_slug}}/config/settings/base.py
@@ -44,7 +44,7 @@
 DATABASES = {"default": env.db("DATABASE_URL")}
 {%- else %}
 DATABASES = {
-    "default": env.db("DATABASE_URL", default="postgres://{% if cookiecutter.windows == 'y' %}localhost{% endif %}/{{cookiecutter.project_slug}}")
+    "default": env.db("DATABASE_URL", default="postgres://{% if cookiecutter.windows == 'y' %}localhost{% endif %}/{{cookiecutter.project_slug}}"),
 }
 {%- endif %}
 DATABASES["default"]["ATOMIC_REQUESTS"] = True
@@ -230,7 +230,8 @@
 # ------------------------------------------------------------------------------
 # https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
 EMAIL_BACKEND = env(
-    "DJANGO_EMAIL_BACKEND", default="django.core.mail.backends.smtp.EmailBackend"
+    "DJANGO_EMAIL_BACKEND",
+    default="django.core.mail.backends.smtp.EmailBackend",
 )
 # https://docs.djangoproject.com/en/dev/ref/settings/#email-timeout
 EMAIL_TIMEOUT = 5
diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py
--- a/{{cookiecutter.project_slug}}/config/settings/production.py
+++ b/{{cookiecutter.project_slug}}/config/settings/production.py
@@ -146,7 +146,8 @@
 SERVER_EMAIL = env("DJANGO_SERVER_EMAIL", default=DEFAULT_FROM_EMAIL)
 # https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix
 EMAIL_SUBJECT_PREFIX = env(
-    "DJANGO_EMAIL_SUBJECT_PREFIX", default="[{{cookiecutter.project_name}}]"
+    "DJANGO_EMAIL_SUBJECT_PREFIX",
+    default="[{{cookiecutter.project_name}}]",
 )
 
 # ADMIN


Test patch:
diff --git a/tests/test_bare.sh b/tests/test_bare.sh
--- a/tests/test_bare.sh
+++ b/tests/test_bare.sh
@@ -27,5 +27,11 @@ sudo utility/install_os_dependencies.sh install
 # Install Python deps
 pip install -r requirements/local.txt
 
+# Lint by running pre-commit on all files
+# Needs a git repo to find the project root
+git init
+git add .
+pre-commit run --show-diff-on-failure -a
+
 # run the project's tests
 pytest
diff --git a/tests/test_docker.sh b/tests/test_docker.sh
--- a/tests/test_docker.sh
+++ b/tests/test_docker.sh
@@ -17,12 +17,16 @@ cd .cache/docker
 cookiecutter ../../ --no-input --overwrite-if-exists use_docker=y $@
 cd my_awesome_project
 
+# Lint by running pre-commit on all files
+# Needs a git repo to find the project root
+# We don't have git inside Docker, so run it outside
+git init
+git add .
+pre-commit run --show-diff-on-failure -a
+
 # run the project's type checks
 docker-compose -f local.yml run django mypy my_awesome_project
 
-# Run black with --check option
-docker-compose -f local.yml run django black --check --diff  --exclude 'migrations' ./
-
 # run the project's tests
 docker-compose -f local.yml run django pytest