Guest User

Untitled

a guest
Jan 21st, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # ======================== #
  4. # ======== Colors ======== #
  5. # ======================== #
  6.  
  7. BLD="\e[1m"
  8. GRN="\e[32m"
  9. RED="\e[31m"
  10. RES="\e[39m"
  11. ORG="\e[33m"
  12. NOR="\e[0m"
  13.  
  14. # ======================== #
  15. # ====== Main Script ===== #
  16. # ======================== #
  17.  
  18. if [[ ! $# -eq 1 ]]; then
  19. echo -e "${BLD}[${RED}NO${RES}${BLD}]${NOR} Missing arguments. Commit message needed.${RES}${NOR}";
  20. echo "Usage: push_that <commit_message> [--github]";
  21. exit 84;
  22. fi
  23.  
  24. # Clean temporary files
  25. RET=$(mr_clean >> tmp)
  26.  
  27. if [[ $(cat tmp) == *"NO"* ]]; then
  28. echo -e "${BLD}[${RED}NO${RES}${BLD}]${NOR} Error: files not cleaned.${RES}${NOR}";
  29. rm -f tmp;
  30. exit 84;
  31. elif [[ ! $(cat tmp) == *"OK"* ]]; then
  32. echo -e "${BLD}[${RED}NO${RES}${BLD}]${NOR} Error: command not found. Please sure you have the 'mr_clean' file in your bin directory.${RES}${NOR}";
  33. rm -f tmp;
  34. exit 84;
  35. else
  36. cat tmp;
  37. rm -f tmp;
  38. fi
  39.  
  40. # Add all files and commit it
  41. git add --all && git commit -am "${1}"
  42. echo -e "${BLD}[${GRN}OK${RES}${BLD}]${NOR} Adding files and commit with '${1}' message.${RES}${NOR}";
  43.  
  44. # Push commited files
  45. echo -e "${BLD}[${GRN}OK${RES}${BLD}]${NOR} Pushing on epitech repository....${RES}${NOR}";
  46. git push origin master
  47. echo -e "${BLD}[${GRN}OK${RES}${BLD}]${NOR} Pushed files into epitech repository.${RES}${NOR}";
  48.  
  49. if [[ $(git remote) == *"github"* ]]; then
  50. echo -e "${BLD}[${GRN}OK${RES}${BLD}]${NOR} Pushing on github repository...${RES}${NOR}";
  51. git push github master;
  52. echo -e "${BLD}[${GRN}OK${RES}${BLD}]${NOR} Pushed files into github repository.${RES}${NOR}"
  53.  
  54. if [[ ! $? -eq 0 ]]; then
  55. echo -e "${BLD}[${RED}OK${RES}${BLD}]${NOR} Error while pushing on github.${RES}${NOR}";
  56. exit 84;
  57. fi
  58. fi
  59.  
  60. exit 0;
Add Comment
Please, Sign In to add comment