Select Git revision
target-git.mk

Volker Schukai authored
target-git.mk 2.04 KiB
#############################################################################################
#############################################################################################
##
## GIT-TARGETS
##
#############################################################################################
#############################################################################################
ifeq ($(GIT),)
$(error $(ERRORMARKER) Git is not defined, check your Makefile if git.mk is included)
endif
## Current Branch-GIT_TAG
GIT_TAG := -
## Git Commit GIT_MESSAGE for git-push
GIT_MESSAGE := current status
.PHONY: git-branch
## create new branch (use GIT_TAG-Variable)
git-branch:
$(QUIET) export BRANCH="b$(GIT_TAG)/$(shell uuidgen --random)" ; \
$(QUIET) $(GIT) checkout -b $${BRANCH} && \
RESULT=$$($(GIT) push origin $$BRANCH 2>&1) && \
RESULT2=$$($(GIT) branch --set-upstream-to=origin/$$BRANCH $$BRANCH) && \
GITLABURL=$$(echo "$$RESULT" | tr '\n' '\#' | grep -o 'remote\:\s*https:\/\/gitlab\.schukai\.com[^ ]*' | cut -d " " -f2-9 | sed -e 's/^[ \t]*//') && \
if $(OPENBROWSER) ; then google-chrome --profile-directory="Default" $$GITLABURL ; fi
.PHONY: git-to-master
## git checkout master, fetch and merge
git-to-master:
$(QUIET) $(GIT) checkout master && $(GIT) fetch -pP && $(GIT) merge
.PHONY: git-push-to-server
## git push changes to server
git-push-to-server:
$(QUIET) $(GIT) add -A
$(QUIET) $(GIT) commit -m"$(GIT_MESSAGE)"
$(QUIET) $(GIT) push
.PHONY: git-push
## git create branch and push changes to server
git-push: git-branch git-push-to-server
.PHONY: git-tag
## git create version tag
git-tag:
$(QUIET) $(GIT) tag -a "$(COMPONENT_VERSION)" -m "release $(COMPONENT_VERSION)"
.PHONY: git-prune-remote
## removes your local remote tracking branches where the branch no longer exists on the remote
git-prune-remote:
$(QUIET) $(GIT) remote prune origin
.PHONY: git-prune-local
## deletes local merged branches except the master branch
git-prune-local:
$(QUIET) $(GIT) branch --merged master | grep -v '^[ *]*master$$' | xargs git branch -d