1コマンドでまとめて複数のプルリク(pr)をmergeする方法
Terminal
% git fetch upstream
% git checkout -b new_stgup_branch upstream/master
% toMergeForStgUp
コンフリクトでこけたら、 直して、また toMergeForStgUp
を叩けば続きだけmergeできる
事前準備
hub コマンドinstall
https://github.com/github/hub
.git/config
[remote "upstream"]
url = git@github.com:<オーナー名/リポジトリ名>.git
fetch = +refs/heads/*:refs/remotes/upstream/*
fetch = +refs/pull/*/head:refs/remotes/upstream/pr/*
.zshrc
## まとめてstgにあげるprをmerge
# githubのラベルが s-uptoStaging または s-Staging がついているものをまとめてmerge
# \d{5} の数字は pr番号の桁数
# 適宜、チームのルールに合わせて変える
function toMergeForStgUp(){
hub pr list -f "%i %l%n" | grep -e s-uptoStaging -e s-Staging | grep -o -E "\d{5} " | while read i
do
git merge upstream/pr/$i
done
}
※ -f "%i %l%n"
で、 pr id と ラベル情報を改行で取得。タイトルにissue番号が入っている時に grep -o -E "\d{5} "
で該当にならないように 必要な情報にしぼる。