Created
June 18, 2019 16:46
-
-
Save memoryleak/a551ede86eb3caba44021981a2b6cb8d to your computer and use it in GitHub Desktop.
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 characters
#!/bin/bash | |
REGEXP=$1 | |
LOOKUP_BRANCH=$2 | |
if [[ -z "$REGEXP" ]]; then | |
echo "Usage: `basename "$0"` <ticket-regexp> [<branch>]" | |
echo "" | |
echo "Omit [<branch>] if you want to see all branches this ticket is deployed to." | |
exit 1 | |
fi | |
TICKETS=$(git branch -a | grep remotes | grep -E -o "$REGEXP" | sort) | |
if [[ ! -z "$LOOKUP_BRANCH" ]]; then | |
BRANCH=$(git branch -a | grep remotes | grep "$REGEXP") | |
BRANCH_RECENT_COMMIT=$(git log -n1 --pretty=oneline $BRANCH | cut -d " " -f1) | |
RESULT=$(git branch --contains $BRANCH_RECENT_COMMIT $LOOKUP_BRANCH) | |
if [[ ! -z "$RESULT" ]]; then | |
exit 0 | |
fi | |
exit 1 | |
fi | |
for TICKET in $TICKETS; do | |
echo "Iteration" | |
BRANCH=$(git branch -a | grep remotes | grep "$TICKET") | |
BRANCH_RECENT_COMMIT=$(git log -n1 --pretty=oneline $BRANCH | cut -d " " -f1) | |
if [[ $TICKET -ne "" ]]; then | |
BRANCHES=$(git branch --contains $BRANCH_RECENT_COMMIT | sort | tr "\n" "\t") | |
echo "$TICKET $BRANCHES" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment