Open K0nkere opened 2 years ago
run
git status
Create .gitignore and paste there no needed files
git add .
- add files to commit
git commit -m "..." - pre-commit will check and fix
Other Hooks - from .pre-commit-config.yaml
google pre-commit isort
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
name: isort (python)
copy it to .pre-commit-config.yaml and format spaces if need
google pre-commit black
- repo: https://github.com/psf/black
rev: stable
hooks:
- id: black
language_version: python3.9
its need to replace stable with version of black from Pipfile.lock > 22.8.0 copy it to .pre-commit-config.yaml and format spaces if need
google pre-commit pylint
- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
args:
[
"-rn", # Only display messages
"-sn", # Don't display the score
"--recursive=y",
]
copy it to .pre-commit-config.yaml and format spaces if need
google pre-commit pytest
- repo: local
hooks:
- id: pytest-check
name: pytest-check
entry: pytest
language: system
pass_filenames: false
always_run: true
args: [
"tests/"
]
copy it to .pre-commit-config.yaml and format spaces if need
After that we can run again
git add <filenames>
- add files to commit
git commit -m "..."
- pre-commit will check and fix and automaticly run the tests from tests/ folder
Video
!!! на последних 4 минутах показан быстрый последовательный запуск > прогон через pre-commit hooks коммит, снова прогон !!!
Pre-commit python tool
Open needed directory in VSCode Under the pipenv
pipenv install --dev pre-commit
In the source folder of git we can find .git/hooks/ > pre-commit.sample - examlpe
!!! Pre-commit hooks are executed from git repo So if we want to run pre-commit hooks for specific folder its need to create a new repo in the needed folder from the needed folder
git init
pre-commit sample-config > .pre-commit-config.yaml
To change how many spaces == tab Ctrl+Shift+P > indent > indent using whitespaces
ls .git/hooks
pre-commit install
> pre-commit installed at .git/hooks/pre-commit check this fileless .git/hooks/pre-commit
!!! Лишних отступов через Tab быть не должно - это важно для дальнейшего коммита !!!