Last active
August 29, 2015 14:04
-
-
Save wancw/4feaf7388c2dbc42fadb to your computer and use it in GitHub Desktop.
Utils for merged branch
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/sh | |
export FMC_WRAPPER=`basename $0` | |
MERGE_COMMIT=`git find-merge-commit $*` | |
if [[ $? != 0 ]]; then | |
exit $? | |
fi | |
git branch --all --contain $MERGE_COMMIT |
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/sh | |
if [[ "$#" < 1 || "$#" > 2 ]]; then | |
echo "Usage:\t${FMC_WRAPPER:-`basename $0`} [<pattern> [<mainstream branch>]]" >&2 | |
exit 1 | |
fi | |
BRANCH_NAME_PATTERN="$1" | |
MAINSTREAM_BRANCH="$2" | |
if [[ "$MAINSTREAM_BRANCH" == "" ]]; then | |
MAINSTREAM_BRANCH="master" | |
fi | |
declare -a MERGE_COMMITS | |
LOG_GREP_PATTERN="^Merge.+$BRANCH_NAME_PATTERN.+ to $MAINSTREAM_BRANCH" | |
MERGE_COMMITS=(`git log --format=format:%h -E --grep "$LOG_GREP_PATTERN"`) | |
COMMIT_COUNT=${#MERGE_COMMITS[@]} | |
if [[ $COMMIT_COUNT > 1 ]]; then | |
echo "More than one merge matched:" >&2 | |
for (( i = 0; i < $COMMIT_COUNT; i++ )); do | |
git log --oneline -1 ${MERGE_COMMITS[$i]} >&2 | |
done | |
exit 1 | |
fi | |
echo ${MERGE_COMMITS[0]} |
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/sh | |
export FMC_WRAPPER=`basename $0` | |
MERGE_COMMIT=`git find-merge-commit $*` | |
if [[ $? != 0 ]]; then | |
exit $? | |
fi | |
git log --oneline --graph ^$MERGE_COMMIT^1 $MERGE_COMMIT^2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment