Created
September 13, 2017 10:10
-
-
Save seporaitis/ed9a76bd3afe930b3fa9080799f59204 to your computer and use it in GitHub Desktop.
prlint.sh
This file contains hidden or 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
#!/usr/bin/env bash | |
prlint() { | |
if [ "$1" = "" ] | |
then | |
echo "prlint <pr>" | |
return 1 | |
fi | |
pr_number=$1 | |
pr_branch=PR${pr_number} | |
branch=$(git rev-parse --abbrev-ref HEAD) | |
if [ "$branch" = "HEAD" ] | |
then | |
branch="origin/master" | |
fi | |
echo "Current branch '${branch}'." | |
git fetch origin pull/${pr_number}/head:${pr_branch} | |
git diff-files --quiet | |
dirty=$? | |
if [ "$dirty" = "1" ] | |
then | |
git stash | |
fi | |
git checkout ${pr_branch} | |
echo "Running linter..." | |
tox -e lint | |
result=$? | |
git checkout $branch | |
git branch -D ${pr_branch} | |
if [ "$dirty" = "1" ] | |
then | |
git stash pop | |
fi | |
return $result | |
} | |
prlint $1 | |
retval=$? | |
exit $retval |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment