Open jakub-g opened 4 years ago
echo 'Fetching from GitHub...' git fetch
CURR_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
PROD=$(git describe origin/prod) MASTER=$(git describe origin/master) HEAD=$(git describe HEAD)
DIFF_HEAD_MASTER=$(git rev-list --left-right --count origin/master...HEAD) BEHIND=$(echo "${DIFF_HEAD_MASTER}" | cut -f1) AHEAD=$(echo "${DIFF_HEAD_MASTER}" | cut -f2)
displayTickets() { CURR_BRANCH_IS_STAGED=0 for ITEM in "$@"; do if [[ "$CURR_BRANCH_NAME" = "$ITEM" ]]; then printf '* '; echo -e "$ITEM"; CURR_BRANCH_IS_STAGED=1 else printf ' '; echo -e "$ITEM"; fi done
if [[ "$CURR_BRANCH_IS_STAGED" = "0" ]]; then RED='\033[0;31m' RESET='\033[0m' echo -e "${RED}Current branch is not yet deployed.${RESET}" fi }
echo '-------------------------------------------------------------------' echo echo 'Most recent prod:' $(git log origin/prod -1 --format=%cr) '--' $(git log origin/prod -1 --format=%cd) echo ' '$(git log origin/prod --format="%s" | head -1 | grep -Eo '[0-9]{4,5}' | awk '$0="PV-"$0')
echo echo 'Tickets on preprod:' PREPROD=$(git log origin/preprod --format="%s" | grep 'preprod' | grep 'Merge remote-tracking branch' | cut -d' ' -f4 | grep -Eo '[0-9]{4,5}' | sort -un | awk '$0="PV-"$0') displayTickets ${PREPROD[@]}
echo echo 'Tickets on stage:' STAGED=$(git log origin/stage-01 --format="%s" | grep 'stage-01' | grep 'Merge remote-tracking branch' | cut -d' ' -f4 | grep -Eo '[0-9]{4,5}' | sort -un | awk '$0="PV-"$0') displayTickets ${STAGED[@]}
echo echo '-------------------------------------------------------------------' echo "prod: v${PROD:6:4 } -- contains" $(git rev-list --left-right --count origin/master...origin/prod | cut -f2) "new commits" echo "master: v${MASTER:6:4}" echo "branch: v${HEAD:6:4 } -- $BEHIND commits behind master, $AHEAD commits added" echo '-------------------------------------------------------------------'
!/bin/bash
echo 'Fetching from GitHub...' git fetch
CURR_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
PROD=$(git describe origin/prod) MASTER=$(git describe origin/master) HEAD=$(git describe HEAD)
DIFF_HEAD_MASTER=$(git rev-list --left-right --count origin/master...HEAD) BEHIND=$(echo "${DIFF_HEAD_MASTER}" | cut -f1) AHEAD=$(echo "${DIFF_HEAD_MASTER}" | cut -f2)
displayTickets() { CURR_BRANCH_IS_STAGED=0 for ITEM in "$@"; do if [[ "$CURR_BRANCH_NAME" = "$ITEM" ]]; then printf '* '; echo -e "$ITEM"; CURR_BRANCH_IS_STAGED=1 else printf ' '; echo -e "$ITEM"; fi done
if [[ "$CURR_BRANCH_IS_STAGED" = "0" ]]; then RED='\033[0;31m' RESET='\033[0m' echo -e "${RED}Current branch is not yet deployed.${RESET}" fi }
echo '-------------------------------------------------------------------' echo echo 'Most recent prod:' $(git log origin/prod -1 --format=%cr) '--' $(git log origin/prod -1 --format=%cd) echo ' '$(git log origin/prod --format="%s" | head -1 | grep -Eo '[0-9]{4,5}' | awk '$0="PV-"$0')
echo echo 'Tickets on preprod:' PREPROD=$(git log origin/preprod --format="%s" | grep 'preprod' | grep 'Merge remote-tracking branch' | cut -d' ' -f4 | grep -Eo '[0-9]{4,5}' | sort -un | awk '$0="PV-"$0') displayTickets ${PREPROD[@]}
echo echo 'Tickets on stage:' STAGED=$(git log origin/stage-01 --format="%s" | grep 'stage-01' | grep 'Merge remote-tracking branch' | cut -d' ' -f4 | grep -Eo '[0-9]{4,5}' | sort -un | awk '$0="PV-"$0') displayTickets ${STAGED[@]}
echo echo '-------------------------------------------------------------------' echo "prod: v${PROD:6:4 } -- contains" $(git rev-list --left-right --count origin/master...origin/prod | cut -f2) "new commits" echo "master: v${MASTER:6:4}" echo "branch: v${HEAD:6:4 } -- $BEHIND commits behind master, $AHEAD commits added" echo '-------------------------------------------------------------------'