Last active
August 12, 2019 14:43
-
-
Save miguelortizdev/d0ef61355cedffdcf61846a19274734c to your computer and use it in GitHub Desktop.
Revisions
-
miguelortizdev renamed this gist
Aug 12, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
miguelortizdev created this gist
Aug 12, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ #!/bin/bash # Creamos una variable en el bash para almacenar las ramas a la que no deseamos aplicar la regla si dicha variable no existe if [ -z "$BRANCHES_TO_SKIP" ]; then BRANCHES_TO_SKIP=(master develop test) fi # Obtenemos el correo configurado en el equipo USER_EMAIL=$(git config user.email) # Obtenemos el nombre de la rama actual BRANCH_NAME=$(git symbolic-ref --short HEAD) BRANCH_NAME="${BRANCH_NAME##*/}" # Verificamos que la rama actual no es una d elas excluidas BRANCH_EXCLUDED=$(printf "%s\n" "${BRANCHES_TO_SKIP[@]}" | grep -c "^$BRANCH_NAME$") BRANCH_IN_COMMIT=$(grep -c "\[$BRANCH_NAME\]" $1) # Si la rama actual no esta excluida entonces modificamos el mensaje para la confirmación actual if [ -n "$BRANCH_NAME" ] && ! [[ $BRANCH_EXCLUDED -eq 1 ]] && ! [[ $BRANCH_IN_COMMIT -ge 1 ]]; then sed -i.bak -e "1s/$/ :: [$BRANCH_NAME] - $USER_EMAIL/" $1 fi