Skip to content

Instantly share code, notes, and snippets.

@yasinuygun
Last active January 9, 2025 13:29
Show Gist options
  • Select an option

  • Save yasinuygun/5d0dc399d3346113e2b77504c3d6b250 to your computer and use it in GitHub Desktop.

Select an option

Save yasinuygun/5d0dc399d3346113e2b77504c3d6b250 to your computer and use it in GitHub Desktop.
yapf pre-commit git hook
#!/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
@yasinuygun
Copy link
Author

Save this into: .git/hooks/pre-commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment