IDE 자동 코드 정리
- pycharm →ctrl+alt+shift+L :리포멧,자동정렬
- visual studio code → ctrl+K+F
import 모듈 정리
isort
사용하지 않는 import 모듈과 변수 정리
autoflake
f-string 변환
flynt
코드 자동 정렬
black
Crontab을 이용한 자동정렬 업데이트
crontab
0 4 * * * bash /your/git/folder/clean_code.sh /your/git/folder/
자동 shell code
target_dir="$1"
if [ -d "${target_dir}" ]; then
echo "Auto commit: ${target_dir}"
cd "${target_dir}"
# git clean
echo "git clean"
git clean -d -f
git status | grep "modified:" | awk '{print "git checkout -- "$2 }' | sh
git status | grep "deleted:" | awk '{print "git checkout -- "$2 }' | sh
echo "git checkout yourbranch"
git checkout yourbranch
echo "git pull"
git pull
# code clean
echo "[clean code] autoflake"
find ./ | grep .py | grep -v .pyc | awk '{print "autoflake --in-place "$1 }' | sh
echo "[clean code] isort"
find ./ | grep .py | grep -v .pyc | awk '{print "isort "$1 }' | sh
echo "[clean code] flynt"
flynt ./
echo "[clean code] black"
black ./
# git upload
echo "git push"
git add ./
git commit -m "[clean code] auto commit"
git push origin yourbranch
echo "DONE!"
fi