Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

288 - Alterando pre-commit hook para pre-push #291

Merged
merged 12 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
printf "Running pre-push hook checks\n\n"

make check

bash -c "if [[ $? != 0 ]];then printf '\nPlease run the following command before push:\n\n make format\n\n\
Remember to commit any changes made on the process.\n'; exit 1; fi"
7 changes: 0 additions & 7 deletions .pre-commit-config.yaml

This file was deleted.

9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
install:
git config --local core.hooksPath .githooks/
chmod -R +x .githooks
@poetry install
@poetry run pre-commit install -f -t pre-commit --hook-type commit-msg

shell:
@poetry shell
Expand All @@ -9,12 +10,10 @@ run-python:
@poetry run python

format:
@poetry run ruff format .
@poetry run ruff .
@poetry run ruff check . --fix
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MarcelFox Você sabe dizer qual a diferença entre @poetry run ruff check . --fix e @poetry run ruff . --fix? Eu usei o segundo e funcionou bem também.

Copy link
Contributor Author

@MarcelFox MarcelFox Nov 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O ruff check . --fix de fato corrige possíveis problemas encontrados, de acordo com a ducumentação:

image

Já o ruff . --fix não parece ser uma opção:
image

O que fiquei sem entender é o format que pra mim não fez nada. O check funcionou tanto pra checar quanto pra corrigir os erros encontrados e aparentemente formatou o código então optei por ele.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Faz sentido, valeu! Também não tinha achado na doc


check:
@poetry run ruff format . --check
@poetry run ruff .
@poetry run ruff check .

test:
@PYTHONDONTWRITEBYTECODE=1 poetry run python3 -m unittest discover tests/ -v
196 changes: 1 addition & 195 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ python = "^3.8.1"
coverage = "^7.2.7"

[tool.poetry.group.dev.dependencies]
pre-commit = ">=2.21,<4.0"
ruff = "^0.1.4"

[tool.ruff]
Expand Down
3 changes: 0 additions & 3 deletions scripts/make-format.sh

This file was deleted.

2 changes: 1 addition & 1 deletion tests/test_phone.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
generate_landline_phone,
generate_mobile_phone,
is_valid,
remove_symbols_phone,
remove_international_code_phone,
remove_symbols_phone,
)


Expand Down