-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
33 lines (32 loc) · 952 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
CURRENT_GIT_BRANCH := $(shell echo $$(git rev-parse --abbrev-ref HEAD))
push:
ifeq ($(branch),)
echo "make command must have \"branch\" parameter - make push branch=master"
exit 1
endif
git add .
ifeq ($(message),)
git commit -a --allow-empty
else
git commit -am "$(message)" --allow-empty
endif
git pull origin $(CURRENT_GIT_BRANCH)
ifneq ($(CURRENT_GIT_BRANCH),$(branch))
ifeq ($(shell git show-ref refs/heads/$(branch) | wc -l | sed -e 's/^[[:space:]]*//'),0)
git checkout -b $(branch)
else
ifeq ($(shell git show-ref refs/heads/$(branch) | wc -l | sed -e 's/^[[:space:]]*//'),1)
git checkout $(branch)
endif
endif
endif
ifneq ($(shell git ls-remote --exit-code origin $(branch) | wc -l | sed -e 's/^[[:space:]]*//'),0)
git pull origin $(branch)
endif
ifneq ($(CURRENT_GIT_BRANCH),$(branch))
git merge $(CURRENT_GIT_BRANCH)
endif
git push origin $(branch)
ifneq ($(CURRENT_GIT_BRANCH),$(branch))
git checkout $(CURRENT_GIT_BRANCH)
endif