やりたいこと
- PRをCLIで完結したい
- 可能な限り楽にPR送りたい
- 用意しておいたテンプレートをPRのコメントとして使いたい
usages
$ edit_pull_request
$ send_pull_request <base_branch_name>
scripts
- hubを使います
function edit_pull_request {
template_dir="/hoge/geho/tmp/pull_request_template"
branch_name=$(git rev-parse --abbrev-ref HEAD)
template_base_path=$(echo "${template_dir}/base.md")
dir=$(echo "${template_dir}/${branch_name}")
path=$(echo "${dir}/template.md")
mkdir -p $dir
if [ ! -f $path ]; then
echo "cp $template_base_path $path"
cp $template_base_path $path
fi
editor $path # use your favorite editor!
}
function send_pull_request {
base_branch=$1
template_dir="/hoge/geho/tmp/pull_request_template"
branch_name=$(git rev-parse --abbrev-ref HEAD)
template_path=$(echo "${template_dir}/${branch_name}/template.md")
echo "git push"
git push
echo "hub pull-request -F $template_path -b $base_branch"
hub pull-request -F $template_path -b $base_branch
}
- template(example)
[hotfix] title
@hoge
@geho
@fuga
## やったこと
## 見て欲しいところ
## 確認したこと
補足:hub usage
usage: git pull-request [-f] [-m <MESSAGE>|-F <FILE>|-i <ISSUE>|<ISSUE-URL>] [-o] [-b <BASE>] [-h <HEAD>]
-
-Fでテンプレートファイルを指定 -
-bでbase branch -
-iでissueをリンク