LoginSignup
0
0

More than 5 years have passed since last update.

githubにアクセスするのが面倒なのでコマンドラインからPullRequestを作る

Posted at

はじめに

プログラマは怠惰な生き物です。
手を抜けるところには手を抜いて生きていきたい。
そんな方々に捧げます。

準備

hub コマンドが必要なため、installします

go get -u github.com/github/hub
cd $GOPATH/src/github.com/github/hub
go build

これで最新版(現在は2.5.0)のバイナリができるので、パスが通っているところにCPしちゃいます。

hubコマンドを使ったPullRequestの作り方

hub コマンドでは hub pull-request というコマンドでPullRequestを作るわけですが長すぎて使ってられないのでaliasを定義します。

vim ~/.gitconfig
[alias]
    pr = !hub pull-request

これで、PullRequestが作られるようになりましたが、このまま叩くとタイトルやコメントが空のPullRequestが作られてしまいます。

テンプレートの使い方

リポジトリによっては、PULL_REQUEST_TEMPLATE.md でPullRequestのテンプレを作っているリポジトリもあるので、それを活用します。
hub pull-request -F .github/PULL_REQUEST_TEMPLATE.md でテンプレを読み込めるようになりますが、テンプレ内に # が書かれている場合、初期設定ではコメントとみなされてしまうため、これを回避します。

git config --global core.commentchar "/"

これで、コメント文字を / にしておきます。

その後、 -f .github/PULL_REQUEST_TEMPLATE.md をgitconfigに足し、エディタを立ち上げたいので --edit オプションを付加して完成です。

vim ~/.gitconfig
[alias]
    pr = !hub pull-request -f .github/PULL_REQUEST_TEMPLATE.md --edit
0
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
0
0