Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # count local commits against your remote
- # detatch the deisred number of commits from the local head
- # make a new commit with the squash of the detached commits preserving the commit messages
- function squash {
- commits=$(git rev-list --count origin/master..HEAD)
- if [ $commits -lt 1 ]
- then
- tput setaf 3; echo -n "come back when you have more commits..."
- return
- fi
- tput setaf 2; echo -n $commits " commits from dev...not bad...\n"
- tput setaf 1; echo -n "do you want to squash all these commits? (y/n) "
- read response
- if [[ $response =~ [yY](es)* ]]
- then
- git reset --hard HEAD~$commits
- git merge --squash HEAD@{1}
- git commit
- tput setaf 4; echo -n "....and done....."
- return
- else
- tput setaf 3; echo -n "dang...maybe next time...I'll be here. Waiting....Wishing...."
- return
- fi
- }
- # execute the build environment steps executed in package.json
- function pushIt {
- # If any of these fail this function should exit
- yarn lint || { echo 'lint failed' ; exit 1; }
- yarn build || { echo 'build failed' ; exit 1; }
- yarn ciUnitTest || { echo 'unit test failed' ; exit 1; }
- yarn ciE2ETest || { echo 'e2e test failed' ; exit 1; }
- tput setaf 1; echo -n "$(tput setaf 2)Well done, everything looks good, $(tput setaf 1)ready to push? (y/n)"
- read response
- if [[ $response =~ [yY](es)* ]]
- then
- tput setaf 2; echo -n 'pushing...'
- git push
- tput setaf 4; echo -n "....and done....."
- return
- else
- tput setaf 3; echo -n "dang...maybe next time...I'll be here. Waiting....Wishing...."
- return
- fi
- }
- #prune local git branches that don't exist remotely
- function prune {
- git fetch --prune
- git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d
- }
Add Comment
Please, Sign In to add comment