Created
August 3, 2015 06:19
-
-
Save hirokazumiyaji/7d815b2381af0cb8e7b5 to your computer and use it in GitHub Desktop.
isort and autopep8 code format script when jenkins build
This file contains 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 | |
cd ${WORKSPACE} | |
BRANCH=`echo ${GIT_BRANCH} | cut -d'/' -f2` | |
git checkout ${BRANCH} | |
git pull origin ${BRANCH} | |
git submodule sync > /dev/null && git submodule -i > /dev/null | |
for FILE in `git diff --name-only ${GIT_PREVIOUS_COMMIT} ${GIT_COMMIT} | grep "py$"`; do | |
autopep8 -i ${FILE} | |
isort ${FILE} | |
end | |
CHANGES=$(`git st -s | grep '^ M' | cut -d' ' -f3) | |
if [ ${CHANGES} -eq 0 ]; then | |
echo "Not Change." | |
exit 0 | |
fi | |
git commit -am "isort and autopep8." | |
git push origin ${BRANCH} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment