Skip to content

Instantly share code, notes, and snippets.

@hirokazumiyaji
Created August 3, 2015 06:19
Show Gist options
  • Save hirokazumiyaji/7d815b2381af0cb8e7b5 to your computer and use it in GitHub Desktop.
Save hirokazumiyaji/7d815b2381af0cb8e7b5 to your computer and use it in GitHub Desktop.
isort and autopep8 code format script when jenkins build
#!/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