Created
February 22, 2012 16:21
-
-
Save CyberShadow/1885859 to your computer and use it in GitHub Desktop.
Easy GitHub pull requests
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 | |
set -e | |
die() { | |
echo "$@" >&2 ; exit 1 | |
} | |
BRANCH=$(git branch 2>/dev/null|grep -e ^* | tr -d \*\ ) | |
test -n "$BRANCH" || die "No branch" | |
test $BRANCH != master || die "You should create a branch instead of working on master: git checkout -b my-awesome-contribution" | |
USER=$(git config --get github.user) | |
if [ -n "$USER" ] | |
then | |
REMOTE=$(git remote -v | grep -F $USER/ | head -n 1 | cut -f 1) | |
test -n "$REMOTE" || die "github.user is set, but no remote found" | |
else | |
REMOTE=$1 | |
test -n "$REMOTE" || die "Remote not specified and github.user not set" | |
fi | |
URL=$(git config --get remote.$REMOTE.url | sed -e 's#^[^:/]\+:\(//[^/]\+/\)\?#https://github.com/#' -e 's#\.git$##' -e 's#/$##' ) | |
test -n "$URL" || die "Couldn't get remote URL" | |
git push $REMOTE $BRANCH | |
git config branch.$BRANCH.remote $REMOTE | |
git-web--browse $URL/pull/new/$BRANCH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment