LoginSignup
2
0

More than 5 years have passed since last update.

hubを使ってCLI上でPull Request

Last updated at Posted at 2016-06-29

やりたいこと

  • 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をリンク
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0