Last active
September 1, 2015 19:08
-
-
Save paulodiovani/148d82e2a8ae894c6c0c to your computer and use it in GitHub Desktop.
Merges branchs or commits from pull-requests as GitHub does
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 | |
### | |
# Merge commits or branches as GitHub Pull Requests | |
# | |
# Usage: ./merge-pr.sh COMMIT PRNUMBER BRANCHNAME | |
# | |
# COMMIT: Commit or branch name to merge | |
# PRNUMBER: Number of the pull request being merged (used in commit message) | |
# BRANCHNAME: Branch name being merged (used in commit message) | |
### | |
PR=$1 | |
BRANCH=$2 | |
COMMIT=$3 | |
if [ -z "$COMMIT" ] || [ -z "$PR" ] || [ -z "$BRANCH" ]; then | |
echo "usage: ./merge-pr.sh COMMIT PRNUMBER BRANCHNAME" | |
exit 1 | |
fi | |
MESSAGE="Merge pull request #$PR from Codeminer42/$BRANCH" | |
COMMAND=( git merge --no-ff --strategy-option theirs -m "'$MESSAGE'" "$COMMIT" ) | |
#run command | |
"${COMMAND[@]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment