-
Notifications
You must be signed in to change notification settings - Fork 7
/
core.clean.mk
59 lines (51 loc) · 1.8 KB
/
core.clean.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
# Adds a 'clean' target that will remove all YP_CLEAN_FILES.
# This is a so-called safe target that removes only defined files,
# leaving untouched files that are unknown to the repository.
#
# ------------------------------------------------------------------------------
#
# Adds a 'nuke' target that will remove all untracked files,
# and reset all the changes to tracked files.
# This is an unsafe target and is meant as an alternative to removing and cloning
# the repository from scratch, when the 'clean' target fails to fix unforeseen issues.
#
# To add another file/folder to the list of files to clean do
# YP_CLEAN_FILES += \
# clean/some/other/path \
#
# ------------------------------------------------------------------------------
YP_CLEAN_FILES += \
Makefile.lazy \
.env.mk \
.bin-yp-env.mk \
# ------------------------------------------------------------------------------
.PHONY: clean
clean: ## Clean.
[[ "$(words $(YP_CLEAN_FILES))" = "0" ]] || { \
$(ECHO_DO) "Cleaning..."; \
$(RM) $(YP_CLEAN_FILES); \
$(ECHO_DONE); \
}
.PHONY: nuke
nuke: ## Nuke all files/changes not checked in.
! $(GIT_REPO_HAS_CHANGED_FILES) || { \
$(ECHO); \
$(ECHO) " Your repository has deleted/modified/new files,"; \
$(ECHO) " and continuing will remove/reset those files."; \
$(GIT) status --porcelain | $(SED) "s/^/ /g"; \
$(ECHO) "[Q ] Continue?"; \
$(ECHO) " Press ENTER to Continue."; \
$(ECHO) " Press Ctrl+C to Cancel."; \
read -r -p "" -n1; \
}
$(ECHO_DO) "Nuking..."
$(GIT) reset -- .
$(GIT) submodule foreach --recursive "$(GIT) reset -- ."
$(GIT) checkout HEAD -- .
$(GIT) clean -xdf -- .
$(GIT) submodule foreach --recursive "$(GIT) checkout HEAD -- ."
$(GIT) submodule foreach --recursive "$(GIT) clean -xdf -- ."
$(ECHO_DONE)
.PHONY: clobber
clobber: nuke
: