I have a Django project with several pre-commit hooks with Python's pre-commit
tool, configured as below:
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/python/black
rev: master
hooks:
- id: black
- repo: https://github.com/asottile/seed-isort-config
rev: master
hooks:
- id: seed-isort-config
- repo: https://github.com/pre-commit/mirrors-isort
rev: master
hooks:
- id: isort
- repo: https://gitlab.com/pycqa/flake8
rev: master
hooks:
- id: flake8
Normally, I do below when a commit fails due to pre-commit hooks on terminal:
git add foo.py
git commit -m "added foo"
# pre-commit runs and fails
# black, end-of-file-fixer fixes staged files
git add foo.py # add fixed files again
git commit -m "added foo"
# this time, runs successfully
I'd like to get the same behavior from VSCode.
I stage my changes, write commit message and commit. VSCode naturally fails.
No matter how many times I commit on VSCode, it does not "stage" the automatic changes made by black
and end-of-file-fixer
. So, when I click again, I'd like VSCode to add the files again because their contents are updated. How can I do this?
Thanks in advance.
Environment
- VSCode 1.52.1
- Git 2.25.1
- pre-commit 2.9.3
If relevant:
- Kubuntu 20.04.1
- Python 3.8
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…