Created
April 5, 2014 06:49
-
-
Save bouzuya/9988251 to your computer and use it in GitHub Desktop.
Backlog + git-flow + WIP PRな運用でdevelopブランチからWIP PR投げるまでを処理するスクリプト
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
#!/bin/bash | |
# Description: | |
# Backlog + git-flow + WIP PR script | |
# Usage: | |
# wip-pr pj-123 | |
# | |
# Requirement: | |
# use Mac OS X | |
# install git | |
# install hub | |
# install [email protected] | |
# create master repository | |
# create backlog issue | |
# cd /path/to/your/repository | |
# git checkout develop | |
# | |
# Note: | |
# brew install git | |
# brew install hub | |
# npm install -g [email protected] | |
# | |
# Configuration: | |
backlog_username='' # yamauchi | |
github_username='' # bouzuya | |
github_username_master='' # faithcreates | |
# check requirement | |
test -x "$(which git)" || { echo 'install git'; exit 1; } | |
test -x "$(which hub)" || { echo 'install hub'; exit 1; } | |
test -x "$(which backlog)" || { echo 'install [email protected]'; exit 1; } | |
test "$(backlog --version)" = '0.2.0' \ | |
|| { echo 'install [email protected]'; exit 1; } | |
test "$(git symbolic-ref HEAD 2>/dev/null)" = 'refs/heads/develop' \ | |
|| { echo 'git checkout develop'; exit 1; } | |
test -n "${backlog_username}" || { echo 'set backlog_username'; exit 1; } | |
test -n "${github_username}" || { echo 'set github_username'; exit 1; } | |
test -n "${github_username_master}" || { echo 'set github_username_master'; exit 1; } | |
# parse args | |
project=$(echo $1 | tr '[:lower:]' '[:upper:]') | |
issue_no=$2 | |
issue_key="${project}-${issue_no}" | |
test -n "${issue_key}" || { echo 'Usage: wip-pr PJ 999'; exit 1; } | |
test -n "${project}" || { echo 'Usage: wip-pr PJ 999'; exit 1; } | |
test -n "${issue_no}" || { echo 'Usage: wip-pr PJ 999'; exit 1; } | |
# fetch issue info | |
issue_summary=$(backlog issue info ${issue_key} -f summary) | |
issue_url=$(backlog issue info ${issue_key} -f url) | |
test -n "${issue_summary}" || exit 1 | |
test -n "${issue_url}" || exit 1 | |
# prompt | |
echo ${issue_summary} | |
echo ${issue_url} | |
read -p 'OK? [yN]' yn | |
test "${yn}" = 'y' -o "${yn}" = 'Y' || exit 0 | |
# commit & push | |
git checkout -b feature/${issue_no} | |
git commit --allow-empty -m "[WIP] ${issue_key} ${issue_summary}" | |
git push ${github_username} feature/${issue_no} | |
# pull request | |
cat >pull-request-comment <<EOS | |
[WIP] ${issue_key} ${issue_summary} | |
${issue_url} | |
EOS | |
hub pull-request \ | |
-F pull-request-comment \ | |
-b "${github_username_master}:develop" > pull-request-url | |
pull_request_url=$(cat pull-request-url) | |
rm pull-request-comment | |
rm pull-request-url | |
# update issue | |
backlog issue status ${issue_key} 2 \ | |
--assigner ${backlog_username} \ | |
--comment ${pull_request_url} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment