summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2019-08-15 01:00:26 +0900
committerGitHub <noreply@github.com>2019-08-15 01:00:26 +0900
commit938e075273feab804d0de840adec48ebe7508a60 (patch)
tree6f91265398982e0b54bd7f4810a0eb68ff271a4c
parente173012f44dfef513c18d69abbd01b3354e897ed (diff)
Add `make update-github PR=1234` to refresh PR (#2368)
Notes
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
-rw-r--r--defs/gmake.mk15
1 files changed, 15 insertions, 0 deletions
diff --git a/defs/gmake.mk b/defs/gmake.mk
index f69e0d30cd..e5e837b370 100644
--- a/defs/gmake.mk
+++ b/defs/gmake.mk
@@ -187,6 +187,20 @@ endef
checkout-github: fetch-github
git -C "$(srcdir)" checkout "gh-$(PR)"
+.PHONY: update-github
+update-github: checkout-github
+ $(eval PULL_REQUEST_API := https://api.github.com/repos/ruby/ruby/pulls/$(PR))
+ $(if $(GITHUB_TOKEN), \
+ $(eval PULL_REQUEST := $(shell curl -s -H "Authorization: bearer $$GITHUB_TOKEN" $(PULL_REQUEST_API))), \
+ $(eval PULL_REQUEST := $(shell curl -s $(PULL_REQUEST_API))) \
+ )
+ $(eval FORK_REPO := $(shell $(BASERUBY) -rjson -e 'print JSON.parse(ARGV[0]).dig("head", "repo", "full_name")' '$(PULL_REQUEST)'))
+ $(eval PR_BRANCH := $(shell $(BASERUBY) -rjson -e 'print JSON.parse(ARGV[0]).dig("head", "ref")' '$(PULL_REQUEST)'))
+ git merge master --no-edit
+ git remote add fork-$(PR) git@github.com:$(FORK_REPO).git
+ git push fork-$(PR) gh-$(PR):$(PR_BRANCH)
+ git remote rm fork-$(PR)
+
.PHONY: pull-github
pull-github: fetch-github
$(call pull-github,$(PR))
@@ -219,6 +233,7 @@ pr-% pull-github-%: fetch-github-%
HELP_EXTRA_TASKS = \
" checkout-github: checkout GitHub Pull Request [PR=1234]" \
" pull-github: rebase GitHub Pull Request to new worktree [PR=1234]" \
+ " update-github: merge master branch and push it to Pull Request [PR=1234]" \
""
ifeq ($(words $(filter update-gems extract-gems,$(MAKECMDGOALS))),2)