-
Notifications
You must be signed in to change notification settings - Fork 1
/
core.check.path.mk
63 lines (51 loc) · 1.67 KB
/
core.check.path.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
# Adds a 'check-path' internal target to run path and filename checks
# over SF_PATH_FILES (defaults to all committed and staged files).
# The 'check-path' target is automatically added to the 'check' target via SF_CHECK_TARGETS.
#
# The check is a match check against a regular expression defined via SF_PATH_LINT_RE.
#
# For convenience, specific files can be ignored
# via grep arguments given to SF_PATH_FILES_IGNORE:
# SF_PATH_FILES_IGNORE += \
# -e "^path/to/dir/" \
# -e "^path/to/file$" \
#
# ------------------------------------------------------------------------------
SF_PATH_LINT_RE := ^[a-z0-9/.-]\+$$
SF_PATH_FILES_IGNORE += \
-e "^$$" \
$(SF_VENDOR_FILES_IGNORE) \
SF_PATH_FILES_IGNORE += \
-e "^.github/" \
-e "^Brewfile.inc.sh$$" \
SF_PATH_FILES_IGNORE += \
-e "^AUTHORS$$" \
SF_PATH_FILES_IGNORE += \
-e "^CONST\.inc$$" \
-e "^CONST\.inc\.secret$$" \
SF_PATH_FILES_IGNORE += \
-e "^Dockerfile" \
-e "/Dockerfile" \
SF_PATH_FILES_IGNORE += \
-e "^Makefile" \
-e "/Makefile" \
SF_PATH_FILES_IGNORE += \
-e "^README" \
-e "/README" \
SF_PATH_FILES += $(shell $(GIT_LS) . | \
$(GREP) -Fvxf <($(GIT) config --file .gitmodules --get-regexp path | $(CUT) -d' ' -f2 || true) | \
$(GREP) -v $(SF_PATH_FILES_IGNORE) | \
$(SED) "s/^/'/g" | \
$(SED) "s/$$/'/g")
SF_CHECK_TARGETS += \
check-path \
# ------------------------------------------------------------------------------
.PHONY: check-path
check-path:
[[ "$(words $(SF_PATH_FILES))" = "0" ]] || { \
for f in $(SF_PATH_FILES); do \
$(ECHO) "$${f}" | $(GREP) -qv "$(SF_PATH_LINT_RE)" || continue; \
$(ECHO_ERR) "$${f} not following file/folder naming convention '$(SF_PATH_LINT_RE)'."; \
exit 1; \
done; \
}