Last active
March 27, 2019 12:29
-
-
Save Korayem/2789efd6bbfbdb41fbada9e927a823a5 to your computer and use it in GitHub Desktop.
search git commit message using jira issue key and return a list of branches that contain them, specifically: dev/staging/master branches to make sure they got merged properly
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 | |
# @korayem - 2019 | |
# search git commit message using jira issue key and return a list of branches that contain them, specifically: dev/staging/master branches to make sure they got merged properly | |
# ./searchgit.sh PEG-1234 PEG-3214 | |
# Returns something like this: | |
# PEG-1973 69df0fc238742acc099db85d799e05d7356b3f9b | |
# origin/HEAD -> origin/master | |
# origin/dev | |
# origin/master | |
# origin/staging | |
# PEG-1973 e2f2d0fce18e3f08744d99b1ab4130681c4aaa5f | |
# origin/HEAD -> origin/master | |
# origin/dev | |
# origin/master | |
# origin/staging | |
# *TODO:* show commit message and body along its sha by using one line option like so | |
# git log --all --oneline --grep=PEG-2070 | |
for issuekey in "$@" | |
do | |
git log --all --no-merges --grep=$issuekey | grep -E "commit\s(.+)" | grep -Eo '\s(.+)' | sed 's/^ *//;s/ *$//' | xargs -I % sh -c "echo $issuekey %; git branch -r --contains % | grep -E '(origin/dev|origin/staging|origin/master)';" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment