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

ruby-changes:57053

From: Takashi <ko1@a...>
Date: Fri, 16 Aug 2019 01:12:16 +0900 (JST)
Subject: [ruby-changes:57053] Takashi Kokubun: d013d8e02e (master): Fix crash on $(PULL_REQUEST) expansion

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

From d013d8e02e895e08f7feb0977c0ea88e6f00b580 Mon Sep 17 00:00:00 2001
From: Takashi Kokubun <takashikkbn@g...>
Date: Fri, 16 Aug 2019 01:11:18 +0900
Subject: Fix crash on $(PULL_REQUEST) expansion

by directly passing it to Ruby without passing a shell.
Formerly it was broken when $(PULL_REQUEST) included quotes.

diff --git a/defs/gmake.mk b/defs/gmake.mk
index b26c603..2b4716b 100644
--- a/defs/gmake.mk
+++ b/defs/gmake.mk
@@ -192,9 +192,12 @@ checkout-github: fetch-github https://github.com/ruby/ruby/blob/trunk/defs/gmake.mk#L192
 .PHONY: update-github
 update-github: checkout-github
 	$(eval PULL_REQUEST_API := https://api.github.com/repos/ruby/ruby/pulls/$(PR))
-	$(eval PULL_REQUEST := $(shell curl -s $(if $(GITHUB_TOKEN),-H "Authorization: bearer $(GITHUB_TOKEN)") $(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)'))
+	$(eval PULL_REQUEST_FORK_BRANCH := $(shell \
+	  curl -s $(if $(GITHUB_TOKEN),-H "Authorization: bearer $(GITHUB_TOKEN)") $(PULL_REQUEST_API) | \
+	  $(BASERUBY) -rjson -e 'JSON.parse(STDIN.read)["head"].tap { |h| print "#{h["repo"]["full_name"]} #{h["ref"]}" }' \
+	))
+	$(eval FORK_REPO := $(shell echo $(PULL_REQUEST_FORK_BRANCH) | cut -d' ' -f1))
+	$(eval PR_BRANCH := $(shell echo $(PULL_REQUEST_FORK_BRANCH) | cut -d' ' -f2))
 	git merge master --no-edit
 	git remote add fork-$(PR) git@g...:$(FORK_REPO).git
 	git push fork-$(PR) gh-$(PR):$(PR_BRANCH)
-- 
cgit v0.10.2


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

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