Created
July 12, 2018 12:46
-
-
Save benjaoming/267e5f9877a948d0c767709ead574196 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
#!/usr/bin/env bash | |
# get the upstream repository username | |
upstream_repo=$(git config remote.upstream.url | sed 's/^.*://' | sed 's/\/.*$//') | |
# open the PR against develop, or another branch specified as the first command-line argument | |
upstream_branch=${1:-develop} | |
# branch | |
branch=$(git symbolic-ref HEAD | sed 's/refs\/heads\///') | |
# make sure it's pushed | |
git push origin "$branch" || exit "failed to push $branch" | |
# get the user/project name | |
project=$(git config remote.origin.url | sed 's/^.*://' | sed 's/\.git$//') | |
# Assume that the HTTP website is the same as the git host.. works for | |
# gitlab, github and much more | |
githost=$(git config remote.origin.url | sed 's/:.*$//' | sed 's/.*\@//') | |
if [ "$githost" == "" ] | |
then | |
echo "No host detected" | |
exit 1 | |
fi | |
# create pull request | |
firefox "https://${githost}/${project}/compare/$upstream_repo:$upstream_branch...$branch" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment