Skip to content

Commit

Permalink
Fix crash on $(PULL_REQUEST) expansion
Browse files Browse the repository at this point in the history
by directly passing it to Ruby without passing a shell.
Formerly it was broken when $(PULL_REQUEST) included quotes.
  • Loading branch information
k0kubun committed Aug 15, 2019
1 parent 7c46aa6 commit d013d8e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions defs/gmake.mk
Expand Up @@ -192,9 +192,12 @@ checkout-github: fetch-github
.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@github.com:$(FORK_REPO).git
git push fork-$(PR) gh-$(PR):$(PR_BRANCH)
Expand Down

0 comments on commit d013d8e

Please sign in to comment.