Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # ======================== #
- # ======== Colors ======== #
- # ======================== #
- BLD="\e[1m"
- GRN="\e[32m"
- RED="\e[31m"
- RES="\e[39m"
- ORG="\e[33m"
- NOR="\e[0m"
- # ======================== #
- # ====== Main Script ===== #
- # ======================== #
- if [[ ! $# -eq 1 ]]; then
- echo -e "${BLD}[${RED}NO${RES}${BLD}]${NOR} Missing arguments. Commit message needed.${RES}${NOR}";
- echo "Usage: push_that <commit_message> [--github]";
- exit 84;
- fi
- # Clean temporary files
- RET=$(mr_clean >> tmp)
- if [[ $(cat tmp) == *"NO"* ]]; then
- echo -e "${BLD}[${RED}NO${RES}${BLD}]${NOR} Error: files not cleaned.${RES}${NOR}";
- rm -f tmp;
- exit 84;
- elif [[ ! $(cat tmp) == *"OK"* ]]; then
- 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}";
- rm -f tmp;
- exit 84;
- else
- cat tmp;
- rm -f tmp;
- fi
- # Add all files and commit it
- git add --all && git commit -am "${1}"
- echo -e "${BLD}[${GRN}OK${RES}${BLD}]${NOR} Adding files and commit with '${1}' message.${RES}${NOR}";
- # Push commited files
- echo -e "${BLD}[${GRN}OK${RES}${BLD}]${NOR} Pushing on epitech repository....${RES}${NOR}";
- git push origin master
- echo -e "${BLD}[${GRN}OK${RES}${BLD}]${NOR} Pushed files into epitech repository.${RES}${NOR}";
- if [[ $(git remote) == *"github"* ]]; then
- echo -e "${BLD}[${GRN}OK${RES}${BLD}]${NOR} Pushing on github repository...${RES}${NOR}";
- git push github master;
- echo -e "${BLD}[${GRN}OK${RES}${BLD}]${NOR} Pushed files into github repository.${RES}${NOR}"
- if [[ ! $? -eq 0 ]]; then
- echo -e "${BLD}[${RED}OK${RES}${BLD}]${NOR} Error while pushing on github.${RES}${NOR}";
- exit 84;
- fi
- fi
- exit 0;
Add Comment
Please, Sign In to add comment