Skip to content

Instantly share code, notes, and snippets.

@antoinebou12
Last active June 18, 2018 14:43
Show Gist options
  • Save antoinebou12/84a4e6fcec2c73268857656ffc44dded to your computer and use it in GitHub Desktop.
Save antoinebou12/84a4e6fcec2c73268857656ffc44dded to your computer and use it in GitHub Desktop.
Good rebase on master and flake8 check for python project
#!/bin/bash
function confirm() {
# call with a prompt string or use a default
read -r -p "$(echo -e $1) Are you sure? [y/N] " response
case "$response" in
[yY][eE][sS]|[yY])
true
;;
*)
false
;;
esac
}
function flake8master(){
local flake8=$(git diff origin/master | python -m flake8 --diff --tee --output flake8.out.txt ; rm -rf flake8.out.txt)
if [[ $flake8 ]]; then
echo -e '\e[31mError\e[39m'
echo $flake8
else
echo -e '\e[32mgood code\e[39m'
fi
}
function rebasei(){
if [ -z $1 ]; then
BRANCH=$(git branch | grep \* | cut -d ' ' -f2-)
else
BRANCH=$1
fi
echo -e '\e[1m'$BRANCH'\e[21m'
git fetch --all -q
git checkout master -q
git pull -q
git checkout $BRANCH -q
git status
git rebase -i master
flake8master
text='\e[1mforce push to '$BRANCH'?\e[21m'
confirm "$text" && git push origin $BRANCH -f
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment