mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
add initial git-pull-request(1) implementation
This commit is contained in:
parent
2287e07204
commit
d489ee24f5
54
bin/git-pull-request
Executable file
54
bin/git-pull-request
Executable file
|
|
@ -0,0 +1,54 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
#
|
||||
# Echo <msg> and exit
|
||||
#
|
||||
|
||||
abort() {
|
||||
echo $@
|
||||
exit 1
|
||||
}
|
||||
|
||||
#
|
||||
# Produce json with <title>, <body>, and <head>
|
||||
#
|
||||
|
||||
json() {
|
||||
cat <<EOF
|
||||
{
|
||||
"title": "$1",
|
||||
"body": "$2",
|
||||
"head": "$3",
|
||||
"base": "master"
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
||||
# user
|
||||
|
||||
user=$(git config --global user.email)
|
||||
test -z "$user" && abort "git config user.email required"
|
||||
|
||||
# branch
|
||||
|
||||
branch=$1
|
||||
test -z "$branch" && abort "<branch> required"
|
||||
|
||||
# lame hack to get project
|
||||
|
||||
project=$(git config remote.origin.url | sed 's/^.*://' | sed 's/\.git$//')
|
||||
|
||||
# prompt
|
||||
|
||||
echo
|
||||
echo " create pull-request for $project '$branch'"
|
||||
echo
|
||||
printf " title: " && read title
|
||||
printf " body: " && read body
|
||||
echo
|
||||
|
||||
# create pull request
|
||||
|
||||
body=$(json $title $body $branch)
|
||||
curl -u "$user" https://api.github.com/repos/$project/pulls -d $body
|
||||
|
||||
Loading…
Reference in a new issue