Last active
September 20, 2019 12:56
-
-
Save suzuki-shunsuke/f7033be1bcec54bc67b10a7da50d5ee8 to your computer and use it in GitHub Desktop.
The shell function to create a pull request from the current feature branch.
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
send-pr() { | |
local remote=`git config branch.master.remote` | |
local remote_url=`git config remote.${remote}.url` | |
case "$remote_url" in | |
https://github.com*) | |
git-pr | |
;; | |
https://ghe.example.com*) | |
ghe-pr | |
;; | |
*) | |
echo "unexpected remote_url: $remote_url" >&2 | |
return 1 | |
;; | |
esac | |
} | |
ghe-pr() { | |
GIT_USERNAME=<your github user name> \ | |
GITHUB_TOKEN=<your github personal access token> \ | |
GITHUB_HOST=ghe.example.com \ | |
_git-pr | |
} | |
git-pr() { | |
GIT_USERNAME=<your github user name> \ | |
GITHUB_TOKEN=<your github personal access token> \ | |
_git-pr | |
} | |
_git-pr() { | |
local branch=`git-current-branch` | |
if [ "$branch" = "" ]; then | |
echo "failed to get the current branch" >&2 | |
return 1 | |
fi | |
git push origin $branch || return 1 | |
hub pull-request -o -h $GIT_USERNAME:$branch | |
} | |
git-current-branch() { | |
git branch | grep "^\* " | sed -e "s/^\* \(.*\)/\1/" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment