[前][次][番号順一覧][スレッド一覧]

ruby-changes:57040

From: Takashi <ko1@a...>
Date: Thu, 15 Aug 2019 01:00:48 +0900 (JST)
Subject: [ruby-changes:57040] Takashi Kokubun: 938e075273 (master): Add `make update-github PR=1234` to refresh PR (#2368)

https://git.ruby-lang.org/ruby.git/commit/?id=938e075273

From 938e075273feab804d0de840adec48ebe7508a60 Mon Sep 17 00:00:00 2001
From: Takashi Kokubun <takashikkbn@g...>
Date: Thu, 15 Aug 2019 01:00:26 +0900
Subject: Add `make update-github PR=1234` to refresh PR (#2368)


diff --git a/defs/gmake.mk b/defs/gmake.mk
index f69e0d3..e5e837b 100644
--- a/defs/gmake.mk
+++ b/defs/gmake.mk
@@ -187,6 +187,20 @@ endef https://github.com/ruby/ruby/blob/trunk/defs/gmake.mk#L187
 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@g...:$(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-% https://github.com/ruby/ruby/blob/trunk/defs/gmake.mk#L233
 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)
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]