-
Notifications
You must be signed in to change notification settings - Fork 1
/
checks.mk
71 lines (64 loc) · 2.08 KB
/
checks.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
60
61
62
63
64
65
66
67
68
69
.PHONY: check_dirty check_tags manifest
include util.mk
GIT_PROG=git
GIT=$(call get_prog,GIT_PROG)
GIT_MOD_CMD = diff --quiet
GIT_UC_CMD = diff --cached --quiet
manifest:
@if [ -d _build/$(REBAR_PROFILE)/lib ]; then \
{ echo $(pwd)/.git; find -L _build/$(REBAR_PROFILE)/lib -type d -name ".git"; } | \
while read gd; do \
if [ -d $$gd ]; then \
wd="$$(dirname $$gd)"; \
app="$$(basename $$wd)"; \
echo "$$app $$($(GIT) --git-dir="$$gd" --work-tree="$$wd" describe --long --always)"; \
fi; \
done | sort; \
fi
check_dirty:
@if [ -d _build/$(REBAR_PROFILE)/lib ]; then \
{ echo $(pwd)/.git; find -L _build/$(REBAR_PROFILE)/lib -type d -name ".git"; } | \
while read gd; do \
if [ -d $$gd ]; then \
unset dirty; \
wt="$$(dirname $$gd)"; \
$(GIT) --git-dir="$$gd" --work-tree="$$wt" $(GIT_MOD_CMD) || dirty=y ; \
$(GIT) --git-dir="$$gd" --work-tree="$$wt" $(GIT_UC_CMD) || dirty=y; \
[ -z "$$dirty" ] || echo "$$wt"; \
fi; \
done; \
fi
# Generates a list of git tag commands required to tag
# repos under the current and deps directories with the contents of the
# APP_VERSION file. It skips directories that don't contain
# APP_VERSION. It doesn't actually do the tag or the push,
# but something like this would help:
#
# make check_tags | sh
#
# and then push them up individually.
check_tags:
@{ if [ -d "./.git" ]; then echo "./.git"; fi; \
if [ -d _build/$(REBAR_PROFILE)/lib ]; then \
find -L _build/$(REBAR_PROFILE)/lib -maxdepth 2 -type d -name '.git'; \
fi; \
} | \
while read gd; do \
wt="$$(dirname $$gd)"; \
if [ -r "$$wt/APP_VERSION" ]; then \
newtag=v$$(cat "$$wt/APP_VERSION"); \
tags=$$($(GIT) --git-dir="$$gd" --work-tree="$$wt" tag -l); \
unset skip_tags; \
for t in $$tags; do \
if [ "$$t" = "$$newtag" ]; then \
skip_tags=1; \
break; \
fi; \
done; \
if [ -z "$$skip_tags" ]; then \
echo "$(GIT) --git-dir='$$gd' --work-tree='$$wt' tag -am'$$newtag' '$$newtag'"; \
else \
echo "# [$$wt] '$$newtag' is already present - skipping"; \
fi; \
fi; \
done