2021-05-31 03:45:39 +02:00
|
|
|
##
|
|
|
|
# GIT
|
|
|
|
|
2021-06-02 00:54:33 +02:00
|
|
|
# target git-branch-create-upstream-%: Create git BRANCH from upstream/% branch
|
2021-05-31 03:45:39 +02:00
|
|
|
.PHONY: git-branch-create-upstream-%
|
2022-05-07 15:04:44 +02:00
|
|
|
git-branch-create-upstream-%: myos-user update-upstream
|
2021-06-14 14:32:14 +02:00
|
|
|
$(RUN) git fetch --prune upstream
|
|
|
|
git rev-parse --verify $(BRANCH) >/dev/null 2>&1 \
|
|
|
|
&& $(or $(call WARNING,present branch,$(BRANCH)), true) \
|
|
|
|
|| $(RUN) git branch $(BRANCH) upstream/$*
|
|
|
|
[ $$(git ls-remote --heads upstream $(BRANCH) |wc -l) -eq 0 ] \
|
|
|
|
&& $(RUN) git push upstream $(BRANCH) \
|
|
|
|
|| $(or $(call WARNING,present branch,$(BRANCH),upstream), true)
|
|
|
|
$(RUN) git checkout $(BRANCH)
|
2021-05-31 03:45:39 +02:00
|
|
|
|
2021-06-02 00:54:33 +02:00
|
|
|
# target git-branch-delete: Delete git BRANCH
|
2021-05-31 03:45:39 +02:00
|
|
|
.PHONY: git-branch-delete
|
2022-05-07 15:04:44 +02:00
|
|
|
git-branch-delete: myos-user update-upstream
|
2021-06-14 14:32:14 +02:00
|
|
|
git rev-parse --verify $(BRANCH) >/dev/null 2>&1 \
|
|
|
|
&& $(RUN) git branch -d $(BRANCH) \
|
|
|
|
|| $(or $(call WARNING,no branch,$(BRANCH)), true)
|
|
|
|
$(foreach remote,upstream,[ $$(git ls-remote --heads $(remote) $(BRANCH) |wc -l) -eq 1 ] \
|
|
|
|
&& $(RUN) git push $(remote) :$(BRANCH) \
|
|
|
|
|| $(or $(call WARNING,no branch,$(BRANCH),$(remote)), true) \
|
2021-06-14 12:52:48 +02:00
|
|
|
&&) true
|
2021-05-31 03:45:39 +02:00
|
|
|
|
2021-06-02 00:54:33 +02:00
|
|
|
# target git-branch-merge-upstream-%: Merge git BRANCH into upstream/% branch
|
2021-05-31 03:45:39 +02:00
|
|
|
.PHONY: git-branch-merge-upstream-%
|
2022-05-07 15:04:44 +02:00
|
|
|
git-branch-merge-upstream-%: myos-user update-upstream
|
2021-06-14 14:32:14 +02:00
|
|
|
git rev-parse --verify $(BRANCH) >/dev/null 2>&1
|
|
|
|
$(RUN) git checkout $(BRANCH)
|
|
|
|
$(RUN) git pull --ff-only upstream $(BRANCH)
|
|
|
|
$(RUN) git push upstream $(BRANCH)
|
|
|
|
$(RUN) git checkout $*
|
|
|
|
$(RUN) git pull --ff-only upstream $*
|
|
|
|
$(RUN) git merge --no-ff --no-edit $(BRANCH)
|
|
|
|
$(RUN) git push upstream $*
|
2021-05-31 03:45:39 +02:00
|
|
|
|
2021-06-02 00:54:33 +02:00
|
|
|
# target git-stash: git stash
|
2021-05-31 03:45:39 +02:00
|
|
|
.PHONY: git-stash
|
2022-05-07 15:04:44 +02:00
|
|
|
git-stash: myos-user
|
2021-06-14 14:32:14 +02:00
|
|
|
$(if $(filter-out 0,$(STATUS)),$(RUN) git stash)
|
2021-05-31 03:45:39 +02:00
|
|
|
|
2021-06-02 00:54:33 +02:00
|
|
|
# target git-tag-create-upstream-%: Create git TAG to reference upstream/% branch
|
2021-05-31 03:45:39 +02:00
|
|
|
.PHONY: git-tag-create-upstream-%
|
2022-05-07 15:04:44 +02:00
|
|
|
git-tag-create-upstream-%: myos-user update-upstream
|
2021-05-31 03:45:39 +02:00
|
|
|
ifneq ($(words $(TAG)),0)
|
2021-06-14 14:32:14 +02:00
|
|
|
$(RUN) git checkout $*
|
|
|
|
$(RUN) git pull --tags --prune upstream $*
|
|
|
|
$(call sed,s/^##\? $(TAG).*/## $(TAG) - $(shell date +%Y-%m-%d)/,CHANGELOG.md)
|
|
|
|
[ $$(git diff CHANGELOG.md 2>/dev/null |wc -l) -eq 0 ] \
|
|
|
|
|| $(RUN) git commit -m "$$(cat CHANGELOG.md |sed -n '/$(TAG)/,/^$$/{s/##\(.*\)/release\1\n/;p;}')" CHANGELOG.md
|
|
|
|
[ $$(git tag -l $(TAG) |wc -l) -eq 0 ] \
|
|
|
|
|| $(RUN) git tag -d $(TAG)
|
|
|
|
$(RUN) git tag $(TAG)
|
|
|
|
[ $$(git ls-remote --tags upstream $(TAG) |wc -l) -eq 0 ] \
|
|
|
|
|| $(RUN) git push upstream :refs/tags/$(TAG)
|
|
|
|
$(RUN) git push --tags upstream $*
|
2021-05-31 03:45:39 +02:00
|
|
|
endif
|
|
|
|
|
2021-06-02 00:54:33 +02:00
|
|
|
# target git-tag-merge-upstream-%: Merge git TAG into upstream/% branch
|
2021-05-31 03:45:39 +02:00
|
|
|
.PHONY: git-tag-merge-upstream-%
|
2022-05-07 15:04:44 +02:00
|
|
|
git-tag-merge-upstream-%: myos-user update-upstream
|
2021-05-31 03:45:39 +02:00
|
|
|
ifneq ($(words $(TAG)),0)
|
2021-06-14 14:32:14 +02:00
|
|
|
$(RUN) git fetch --tags -u --prune upstream $*:$*
|
|
|
|
$(RUN) git checkout $*
|
|
|
|
$(RUN) git merge --ff --no-edit $(TAG)
|
|
|
|
$(RUN) git push upstream $*
|
2021-05-31 03:45:39 +02:00
|
|
|
endif
|
|
|
|
|
2021-06-02 00:54:33 +02:00
|
|
|
# target git-unstash: git stash pop
|
2021-05-31 03:45:39 +02:00
|
|
|
.PHONY: git-unstash
|
2022-05-07 15:04:44 +02:00
|
|
|
git-unstash: myos-user
|
2021-06-14 14:32:14 +02:00
|
|
|
$(if $(filter-out 0,$(STATUS)),$(RUN) git stash pop)
|