From af07e07ac9331ec9c2f16b2329a0471ea663dd95 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 17 Jul 2019 11:56:40 +0900 Subject: Separate pull-github from merge-github [ci skip] --- defs/gmake.mk | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/defs/gmake.mk b/defs/gmake.mk index 0824cabc8d..4a16552a1f 100644 --- a/defs/gmake.mk +++ b/defs/gmake.mk @@ -185,36 +185,54 @@ endef checkout-github: fetch-github git -C "$(srcdir)" checkout "gh-$(PR)" +.PHONY: pull-github +pull-github: fetch-github + $(call pull-github,$(PR)) + .PHONY: merge-github -merge-github: fetch-github +merge-github: pull-github $(call merge-github,$(PR)) -define merge-github +define pull-github $(eval GITHUB_MERGE_BASE := $(shell git -C "$(srcdir)" log -1 --format=format:%H)) $(eval GITHUB_MERGE_BRANCH := $(shell git -C "$(srcdir)" symbolic-ref --short HEAD)) $(eval GITHUB_MERGE_WORKTREE := $(shell mktemp -d "$(srcdir)/gh-$(1)-XXXXXX")) git -C "$(srcdir)" worktree add $(notdir $(GITHUB_MERGE_WORKTREE)) "gh-$(1)" git -C "$(GITHUB_MERGE_WORKTREE)" rebase $(GITHUB_MERGE_BRANCH) - git -C "$(srcdir)" worktree remove $(notdir $(GITHUB_MERGE_WORKTREE)) - git -C "$(srcdir)" merge --ff-only "gh-$(1)" - git -C "$(srcdir)" branch -D "gh-$(1)" - git -C "$(srcdir)" filter-branch -f \ + git -C "$(GITHUB_MERGE_WORKTREE)" filter-branch -f \ --msg-filter 'cat && echo && echo "Closes: $(GITHUB_RUBY_URL)/pull/$(1)"' \ -- "$(GITHUB_MERGE_BASE)..@" $(eval COMMIT_GPG_SIGN := $(COMMIT_GPG_SIGN)) $(if $(filter true,$(COMMIT_GPG_SIGN)), \ - git -C "$(srcdir)" rebase --exec "git commit --amend --no-edit -S" "$(GITHUB_MERGE_BASE)"; \ + git -C "$(GITHUB_MERGE_WORKTREE)" rebase --exec "git commit --amend --no-edit -S" "$(GITHUB_MERGE_BASE)"; \ ) endef +define merge-github + git -C "$(srcdir)" worktree remove $(notdir $(GITHUB_MERGE_WORKTREE)) + git -C "$(srcdir)" merge --ff-only "gh-$(1)" + git -C "$(srcdir)" branch -D "gh-$(1)" +endef + +.PHONY: fetch-github-% fetch-github-%: $(call fetch-github,$*) -pr-% merge-github-%: fetch-github-% +.PHONY: checkout-github-% +checkout-github-%: fetch-github-% + git -C "$(srcdir)" checkout "gh-$(1)" + +.PHONY: pr-% pull-github-% +pr-% pull-github-%: fetch-github-% + $(call pull-github,$*) + +.PHONY: merge-github-% +merge-github-%: pull-github-% $(call merge-github,$*) HELP_EXTRA_TASKS = \ " checkout-github: checkout GitHub Pull Request [PR=1234]" \ + " pull-github: rebase GitHub Pull Request to new worktree [PR=1234]" \ " merge-github: merge GitHub Pull Request to current HEAD [PR=1234]" \ "" -- cgit v1.2.3