Skip to content
Browse files

Merge pull request #4 from jehiah/create_issue_on_the_fly_4

create issues on the fly
  • Loading branch information...
2 parents 014f505 + 347d1ad commit e42d03f92c841bbcb64ecc3426d346b857bff81f @jehiah committed Apr 9, 2012
Showing with 36 additions and 1 deletion.
  1. +36 −1 git-open-pull
View
37 git-open-pull
@@ -175,7 +175,42 @@ if [ -z "$BASE_REPO" ]; then
fi
if [ -z "$ISSUE_NUMBER" ]; then
- read -p "enter issue number: " ISSUE_NUMBER
+ read -p "enter issue number (or 'c' to create): " ISSUE_NUMBER
+ if [ "$ISSUE_NUMBER" == "c" ]; then
+ read -p "issue title: " ISSUE_TITLE
+ read -p "issue description: " ISSUE_DESCRIPTION
+ endpoint="https://api.github.com/repos/$BASE_ACCOUNT/$BASE_REPO/issues"
+ json="{\"title\":\"$ISSUE_TITLE\", \"body\":\"$ISSUE_DESCRIPTION\"}"
+ ISSUE_JSON=`curl --silent -H "Accept: application/vnd.github-issue.text+json,application/json" --data-binary "$json" "$endpoint?access_token=$GITHUB_TOKEN"`
+ ISSUE_NUMBER=$(echo $ISSUE_JSON | $PYTHON_CMD -c '
+try:
+ import simplejson as json
+except ImportError:
+ import json
+import sys
+data = sys.stdin.read().strip().replace("\n",r"\n").replace("\r","")
+data = json.loads(data)
+if "number" not in data:
+ print "ERROR verifying issue number: ", data
+else:
+ print data.get("number")
+')
+ if ! echo $ISSUE_NUMBER | egrep -q '^[0-9]+$'; then
+ echo "Error creating issue $ISSUE_NUMBER"
+ exit 1;
+ fi
+
+ echo "created issue $ISSUE_NUMBER"
+ read -p "rename branch to ${FEATURE_BRANCH}_${ISSUE_NUMBER} [y/n]:" confirm
+ if [ "$confirm" == "y" ] || [ -z "$confirm" ]; then
+ echo "renaming local branch $FEATURE_BRANCH -> ${FEATURE_BRANCH}_${ISSUE_NUMBER}"
+ $GIT_CMD branch -m "${FEATURE_BRANCH}_${ISSUE_NUMBER}" || exit 1
+ echo "pushing branch to $GITHUB_USER"
+ $GIT_CMD push $GITHUB_USER "${FEATURE_BRANCH}_${ISSUE_NUMBER}"
+ FEATURE_BRANCH="${FEATURE_BRANCH}_${ISSUE_NUMBER}"
+ fi
+
+ fi
else
read -p "issue number [$ISSUE_NUMBER]: " temp
[ -n "$temp" ] && ISSUE_NUMBER=$temp

0 comments on commit e42d03f

Please sign in to comment.
Something went wrong with that request. Please try again.