Skip to content

Instantly share code, notes, and snippets.

@seporaitis
Created September 13, 2017 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seporaitis/ed9a76bd3afe930b3fa9080799f59204 to your computer and use it in GitHub Desktop.
Save seporaitis/ed9a76bd3afe930b3fa9080799f59204 to your computer and use it in GitHub Desktop.
prlint.sh
#!/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