Last active
October 21, 2020 07:04
-
-
Save silvandiepen/780593d032cf7a43c8ff4a9684e4861d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') | |
staged=$(git diff --name-only --cached) | |
yellow=`tput setaf 3` | |
blue=`tput setaf 4` | |
reset=`tput sgr0` | |
bold=`tput bold` | |
dim=`tput dim` | |
printf "\n" | |
echo "\t${bold}${blue}GiG${reset}${bold}Commit${reset}" | |
printf "\n" | |
branchArray=(${branch//-/ }) | |
printf "\t${bold}Team ID${reset} ${blue}($branchArray)${reset} \n" | |
read -p " " TEAM_ANSWER | |
TEAM="${TEAM_ANSWER:-$branchArray}" | |
TICKET_NUMBER="${branch//[^0-9]/}" | |
printf "\t${bold}Ticket Number${reset} ${blue}($TICKET_NUMBER)${reset} \n" | |
read -p " " TICKET_ANSWER | |
TICKET="${TICKET_ANSWER:-$TICKET_NUMBER}" | |
PACKAGE_FOLDER=$(basename $PWD) | |
printf "\t${bold}Package name${reset} ${blue}($PACKAGE_FOLDER)${reset} \n" | |
read -p " " PACKAGE_ANSWER | |
PACKAGE="${PACKAGE_ANSWER:-$PACKAGE_FOLDER}" | |
TYPE_DEFAULT=$(basename $PWD) | |
printf "\t${bold}type${reset} ${blue}($TYPE_DEFAULT)${reset} \n" | |
read -p " " TYPE_ANSWER | |
TYPE="${TYPE_ANSWER:-$TYPE_DEFAULT}" | |
printf "\t${bold}Commit Message${reset} " | |
read -p " " MESSAGE_ANSWER | |
MESSAGE=`echo "$MESSAGE_ANSWER" | awk '{ print tolower($1) }'` | |
COMMIT_MSG="git commit -m \"$TYPE($PACKAGE): $MESSAGE \" -m \"Closes #${TEAM}-${TICKET}\"" | |
printf "\n" | |
echo "\t${yellow}$COMMIT_MSG${reset}" | |
echo "\t" | |
read -p "Do you want to commit? ${blue}Y/n${reset} " COMMIT_ANSWER | |
Y='y'; | |
DO_COMMIT="${COMMIT_ANSWER:-$Y}" | |
echo $DO_COMMIT | |
if [["$DO_COMMIT" = "Y" || "$DO_COMMIT" = 'y']]; then | |
echo 'Gonna commit it to your mother!' | |
# COMMIT_MSG | |
else | |
echo "Ok, you don't have to.." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment