-
Notifications
You must be signed in to change notification settings - Fork 1
/
core.misc.sf-update.mk
71 lines (66 loc) · 2.83 KB
/
core.misc.sf-update.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
70
71
# Adds a 'support-firecloud/update' target which will update the support-firecloud git submodule
# to the latest version (semver tag), while also showing the git commits that the update will introduce.
#
# Commits that have the word 'break' will be colour highlighted,
# so the developer can take corrective actions when needed.
#
# ------------------------------------------------------------------------------
.PHONY: _support-firecloud/update
_support-firecloud/update:
$(eval SF_SUBMODULE_PATH := $(shell $(GIT) config --file .gitmodules --get-regexp path | \
$(GREP) $(shell basename $(SUPPORT_FIRECLOUD_DIR)) | $(CUT) -d' ' -f2))
[[ -n "$(SF_SUBMODULE_PATH)" ]] || { \
$(ECHO_ERR) "Couldn't find 'support-firecloud' git submodule."; \
exit 1; \
}
$(GIT) submodule update --init --recursive $(SF_SUBMODULE_PATH)
$(GIT) -C $(SF_SUBMODULE_PATH) fetch --force --tags
.PHONY: support-firecloud/update
support-firecloud/update: _support-firecloud/update ## Update support-firecloud to latest version.
$(MAKE) support-firecloud/update/$(shell $(GIT) -C $(SF_SUBMODULE_PATH) tag \
--list \
--sort=version:refname "v*" | \
$(TAIL) -n1)
.PHONY: support-firecloud/update/v%
support-firecloud/update/v%: _support-firecloud/update ## Update support-firecloud to a specific version.
$(eval SF_COMMIT := $(shell $(GIT) rev-parse HEAD^{commit}:$(SF_SUBMODULE_PATH)))
$(eval SF_VSN := $(shell $(GIT) tag -l --points-at HEAD | $(HEAD) -1 | $(SED) "s/^$$/$(SF_COMMIT)/"))
$(eval SF_UPDATE_VSN := $(@:support-firecloud/update/v%=%))
$(eval SF_UPDATE_COMMIT := refs/tags/v$(SF_UPDATE_VSN))
$(eval SF_UPDATE_COMMIT_RANGE := $(SF_COMMIT)..$(SF_UPDATE_COMMIT))
$(ECHO_DO) "Updating $(SF_SUBMODULE_PATH) to v$(SF_UPDATE_VSN)..."
$(ECHO)
$(ECHO_INFO) "Changes in $(SF_SUBMODULE_PATH)@$(SF_UPDATE_VSN) since $(SF_VSN):"
$(ECHO)
$(GIT) -C $(SF_SUBMODULE_PATH) --no-pager log \
--color \
--graph \
--date=short \
--pretty=format:"%h %ad %s" \
--no-decorate \
$(SF_UPDATE_COMMIT_RANGE) | \
$(GREP) --color -i -E "^|break" || true
$(ECHO)
$(ECHO_INFO) "Breaking changes in $(SF_SUBMODULE_PATH)@$(SF_UPDATE_VSN) since $(SF_VSN):"
$(ECHO)
$(GIT) -C $(SF_SUBMODULE_PATH) --no-pager log \
--color \
--graph \
--date=short \
--pretty=format:"%h %ad %s" \
--no-decorate \
$(SF_UPDATE_COMMIT_RANGE) | \
$(GREP) --color -i -E "break" || true
$(ECHO)
$(GIT) -C $(SF_SUBMODULE_PATH) --no-pager \
diff --stat $(SF_UPDATE_COMMIT_RANGE)
$(ECHO)
$(ECHO) "[Q ] Updating $(SF_SUBMODULE_PATH) to v$(SF_UPDATE_VSN). OK?"
$(ECHO) " Press ENTER to Continue."
$(ECHO) " Press Ctrl+C to Cancel."
read -p ""
$(GIT) -C $(SF_SUBMODULE_PATH) reset --hard $(SF_UPDATE_COMMIT)
$(GIT) add $(SF_SUBMODULE_PATH)
$(GIT) commit -m "updated $(SF_SUBMODULE_PATH) to v$(SF_UPDATE_VSN)"
$(GIT) submodule update --init --recursive $(SF_SUBMODULE_PATH)
$(ECHO_DONE)