Guest User

Untitled

a guest
Apr 20th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. # count local commits against your remote
  2. # detatch the deisred number of commits from the local head
  3. # make a new commit with the squash of the detached commits preserving the commit messages
  4.  
  5. function squash {
  6. commits=$(git rev-list --count origin/master..HEAD)
  7.  
  8. if [ $commits -lt 1 ]
  9. then
  10. tput setaf 3; echo -n "come back when you have more commits..."
  11. return
  12. fi
  13.  
  14. tput setaf 2; echo -n $commits " commits from dev...not bad...\n"
  15. tput setaf 1; echo -n "do you want to squash all these commits? (y/n) "
  16.  
  17. read response
  18. if [[ $response =~ [yY](es)* ]]
  19. then
  20. git reset --hard HEAD~$commits
  21. git merge --squash HEAD@{1}
  22. git commit
  23. tput setaf 4; echo -n "....and done....."
  24. return
  25. else
  26. tput setaf 3; echo -n "dang...maybe next time...I'll be here. Waiting....Wishing...."
  27. return
  28. fi
  29.  
  30. }
  31.  
  32. # execute the build environment steps executed in package.json
  33.  
  34. function pushIt {
  35. # If any of these fail this function should exit
  36. yarn lint || { echo 'lint failed' ; exit 1; }
  37. yarn build || { echo 'build failed' ; exit 1; }
  38. yarn ciUnitTest || { echo 'unit test failed' ; exit 1; }
  39. yarn ciE2ETest || { echo 'e2e test failed' ; exit 1; }
  40.  
  41. tput setaf 1; echo -n "$(tput setaf 2)Well done, everything looks good, $(tput setaf 1)ready to push? (y/n)"
  42. read response
  43.  
  44. if [[ $response =~ [yY](es)* ]]
  45. then
  46. tput setaf 2; echo -n 'pushing...'
  47. git push
  48. tput setaf 4; echo -n "....and done....."
  49. return
  50. else
  51. tput setaf 3; echo -n "dang...maybe next time...I'll be here. Waiting....Wishing...."
  52. return
  53. fi
  54. }
  55.  
  56. #prune local git branches that don't exist remotely
  57. function prune {
  58. git fetch --prune
  59. git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d
  60. }
Add Comment
Please, Sign In to add comment