-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRuby-git.mk
59 lines (48 loc) · 1.19 KB
/
Ruby-git.mk
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
58
59
V := $(shell [ -t 1 ] && echo 1)
ifeq ($(if $(V),$(V),0),0)
Q = @
ECHO = :
else
Q =
ECHO = @echo
endif
inside-work-tree := $(git rev-parse --is-inside-work-tree)
ifeq ($(inside-work-tree),true)
branches := $(shell git branch -l | sort | sed 's/\*//')
gitdir = .git
backupdir = $(gitdir)
backup = git.tar.bz2
backuparg =
else
gitdir = .
backupdir := $(notdir $(shell pwd))
backup = ../$(backupdir).tar.bz2
backuparg = -C ..
endif
backupopt = --dereference
all:
up: up-remote up-local .force
up-remote: fetch rebase .force
up-local: .force
fetch: .force
$(Q) git fetch
$(Q) $(if $(wildcard $(gitdir)/svn),git svn fetch)
# $(Q) $(if $(wildcard $(gitdir)/svn),cp -p `find refs/remotes/origin -maxdepth 1 -type f` refs/heads/)
rebase: $(addprefix rebase-,$(branches)) .force
define rebasecmd
.PHONY: rebase-$(1)
rebase-$(1): .force
git rebase origin$(if $(filter-out master,$(1)),/$(1)) $(1)
endef
$(foreach branch,$(branches),$(eval $(call rebasecmd,$(branch))))
branches: .force
echo $(branches)
backup: $(backup) .force
$(backup): $(gitdir) gc
tar $(backuparg) $(backupopt) -cjf $@ $(backupdir)
gc: .force
du -s $(gitdir)
git gc
du -s $(gitdir)
.PHONY: .force fetch rebase branch backup gc
.force: