forked from instrumentisto/toolchain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
57 lines (39 loc) · 1.09 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
######################
# Project parameters #
######################
MAINLINE_BRANCH := master
CURRENT_BRANCH := $(shell git branch | grep \* | cut -d ' ' -f2)
###########
# Aliases #
###########
squash: git.squash
################
# Git commands #
################
# Squash changes of the current Git branch onto another Git branch.
#
# WARNING: You must merge `onto` branch in the current branch before squash!
#
# Usage:
# make git.squash [onto=(<mainline-git-branch>|<git-branch>)]
# [del=(no|yes)]
# [upstream=(origin|<git-remote>)]
onto ?= $(MAINLINE_BRANCH)
upstream ?= origin
git.squash:
ifeq ($(CURRENT_BRANCH),$(onto))
echo "--> Current branch is '$(onto)' already" && false
endif
git checkout $(onto)
git branch -m $(CURRENT_BRANCH) orig-$(CURRENT_BRANCH)
git checkout -b $(CURRENT_BRANCH)
git branch --set-upstream-to $(upstream)/$(CURRENT_BRANCH)
git merge --squash orig-$(CURRENT_BRANCH)
ifeq ($(del),yes)
git branch -d orig-$(CURRENT_BRANCH)
endif
##################
# .PHONY section #
##################
.PHONY: squash \
git.squash