mmag

ハマったことメモなど

初回プッシュ以外でもプルリクをつくるリンクを表示する

remote: Resolving deltas: 100% (7/7), completed with 7 local objects.
remote:
remote: Create a pull request for 'baz' on GitHub by visiting:
remote:      https://github.com/foo/bar/pull/new/baz
remote:

このリンク。そのブランチを初めてプッシュしたときしか出してくれず不便なので、ググって.git/hooks/pre-pushに仕込んだ。

#!/bin/sh

branch=$(git rev-parse --abbrev-ref HEAD)
userRepo=$(git remote -v | grep fetch | awk '{print $2}' | grep "github.com" | cut -d':' -f2)

if [ -n "$userRepo" ]
then
  echo ""
  echo "Create PR at: https://github.com/$userRepo/compare/$branch?expand=1&labels=qux"
  echo ""
fi

よく使うラベルを指定することも可能。