Skip to content

Commit

Permalink
Improved issue-to-pull script
Browse files Browse the repository at this point in the history
  • Loading branch information
tclem committed Jul 3, 2012
1 parent 6412e60 commit 5be7010
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions bin/issue-to-pull
Expand Up @@ -13,13 +13,34 @@
branch=$(git symbolic-ref HEAD | sed 's/^refs\/heads\///') branch=$(git symbolic-ref HEAD | sed 's/^refs\/heads\///')
[ -z "$branch" ] && { [ -z "$branch" ] && {
echo "could not determine current branch" 1>&2 echo "could not determine current branch" 1>&2
false exit 2
} }


echo "This will turn issue $2 on $1 into a pull request for branch '$branch'" # WIP
read -s -p "GitHub Password: " pwd if ! [ -e ~/.githubauthorization ]
then
read -p "GitHub username: " name
read -s -p "GitHub password: " pass

curl -u "$name:$pass" https://api.github.com/authorizations -s \
-d '{"note":"for scripts", "scopes":["repo", "user", "public_repo", "gists"]}' \
| grep -Po '"token":.*?[^\\]",' | sed 's/\"token\": \"//g' | sed 's/\",//g' \
> ~/.githubauthorization

echo "Generated and saved an oauth token here ~/.githubauthorization"
fi

token=`cat ~/.githubauthorization`
echo "Turning issue $2 on $1 into a pull request for branch '$branch'"

curl -H "Authorization: token $token" https://api.github.com/repos/$1/pulls \
-d '{"issue":'$2', "head":"'$branch'", "base":"master"}' \
| grep -Po '"url":.*?[^\\]",' | sed 's/\"url\": \"//g' | sed 's/\",//g'


curl -u "tclem:$pwd" https://api.github.com/repos/$1/pulls \ # Old Direct method
-d '{"issue":'$2', "head":"'$branch'", "base":"master"}' # read -s -p "GitHub Password: " pwd


echo # curl -u "tclem:$pwd" https://api.github.com/repos/$1/pulls \
# -d '{"issue":'$2', "head":"'$branch'", "base":"master"}'
#
# echo

0 comments on commit 5be7010

Please sign in to comment.