Last active
January 9, 2025 13:29
-
-
Save yasinuygun/5d0dc399d3346113e2b77504c3d6b250 to your computer and use it in GitHub Desktop.
yapf pre-commit git hook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # Run yapf on modified Python files | |
| files=$(git diff --cached --name-only --diff-filter=AM | grep -E '\.py$') | |
| if [ -n "$files" ]; then | |
| yapf --style "{based_on_style: pep8, column_limit: 120}" -i $files | |
| git add $files | |
| fi |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Save this into:
.git/hooks/pre-commit