Permalink
Browse files

Improved issue-to-pull script

  • Loading branch information...
tclem committed Jul 3, 2012
1 parent 6412e60 commit 5be7010d3d0d0b4bdb13507c19f60bb2324a3c0d
Showing with 27 additions and 6 deletions.
  1. +27 −6 bin/issue-to-pull
View
@@ -13,13 +13,34 @@
branch=$(git symbolic-ref HEAD | sed 's/^refs\/heads\///')
[ -z "$branch" ] && {
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'"
-read -s -p "GitHub Password: " pwd
+# WIP
+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 \
- -d '{"issue":'$2', "head":"'$branch'", "base":"master"}'
+# Old Direct method
+# 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.