This repository has been archived on 2025-04-19. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
git-hooks/pre-commit.d/autoflake.sh
2019-05-19 14:18:51 +00:00

14 lines
406 B
Bash
Executable file

#!/bin/bash
FILES=$(git diff --cached --name-only --diff-filter=ACM "*.py" | sed 's| |\\ |g')
if [ ! -z "$FILES" ]; then
# Format all selected files
echo "$FILES" | xargs -I {} /bin/bash -c "/home/sonny/.local/bin/autoflake --in-place --remove-unused-variables {}"
if [ $? -ne 0 ]; then
exit 1
fi
# Add back the modified files to staging
echo "$FILES" | xargs git add
fi