Help us understand the problem. What is going on with this article?

hubを使ってCLI上でPull Request

More than 1 year has passed since last update.

やりたいこと

  • 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をリンク
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away