@cratis/pi 7.178.2 → 7.178.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -66,22 +66,28 @@ else
|
|
|
66
66
|
fi
|
|
67
67
|
|
|
68
68
|
# One record per line. Fields separated by US (0x1f); list members inside a field by SOH (0x01).
|
|
69
|
-
#
|
|
70
|
-
|
|
69
|
+
# Raw output preserves regex backslashes (@tsv would escape them). Emit list members separately:
|
|
70
|
+
# jq join repeatedly copies its growing string, making large glob lists quadratic.
|
|
71
|
+
records="$(printf '%s' "$merged" | jq -j '
|
|
72
|
+
def emit_joined($separator):
|
|
73
|
+
. as $items
|
|
74
|
+
| range(0; length) as $index
|
|
75
|
+
| (if $index > 0 then $separator else "" end),
|
|
76
|
+
([$items[$index]] | join(""));
|
|
71
77
|
.patterns // []
|
|
72
78
|
| map(select((.enabled // true) == true))
|
|
73
79
|
| .[]
|
|
74
|
-
| [ .id,
|
|
75
|
-
.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
((.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
|
80
|
+
| [ ([ .id, .pattern, .message, (.rule // "") ] | join("")),
|
|
81
|
+
([ (.paths // ["**/*"]),
|
|
82
|
+
(.exclude_paths // []),
|
|
83
|
+
(.requires_in_file // []),
|
|
84
|
+
(.absent_in_file // []) ]
|
|
85
|
+
| .[] | "", emit_joined("")),
|
|
86
|
+
"",
|
|
87
|
+
([ (.within_type_attribute // ""),
|
|
88
|
+
((.join_lines // 1) | tostring) ] | join("")),
|
|
89
|
+
"\n" ]
|
|
90
|
+
| .[]
|
|
85
91
|
' 2>/dev/null || true)"
|
|
86
92
|
[ -n "$records" ] || exit 0
|
|
87
93
|
|
|
@@ -114,19 +114,21 @@ hook_glob_awk_lib='
|
|
|
114
114
|
'
|
|
115
115
|
|
|
116
116
|
# Does path $1 match any of the newline-separated globs on stdin?
|
|
117
|
+
# Drain stdin after a match: under pipefail, an upstream SIGPIPE would turn success into failure.
|
|
117
118
|
hook_glob_match() {
|
|
118
119
|
CRATIS_GLOB_PATH="$1" awk "$hook_glob_awk_lib"'
|
|
119
120
|
BEGIN { p = ENVIRON["CRATIS_GLOB_PATH"]; found = 0 }
|
|
121
|
+
found { next }
|
|
120
122
|
{ g = $0; sub(/^[ \t]+/, "", g); sub(/[ \t\r]+$/, "", g) }
|
|
121
123
|
g == "" { next }
|
|
122
|
-
{ if (p ~ g2re(g))
|
|
124
|
+
{ if (p ~ g2re(g)) found = 1 }
|
|
123
125
|
END { exit(found ? 0 : 1) }
|
|
124
126
|
'
|
|
125
127
|
}
|
|
126
128
|
|
|
127
129
|
# The other direction: print the FIRST newline-separated path on stdin matching any of the
|
|
128
130
|
# newline-separated globs in $1, and exit 0. Prints nothing and exits 1 when none matches,
|
|
129
|
-
# or when $1 holds no glob.
|
|
131
|
+
# or when $1 holds no glob. Like hook_glob_match, it drains stdin instead of exiting early.
|
|
130
132
|
#
|
|
131
133
|
# hook_glob_match answers "does this one path match?" and costs a process per path, which is
|
|
132
134
|
# right for the handful of changed files a hook sees. Discovery asks the mirror question over
|
|
@@ -142,12 +144,12 @@ hook_glob_first_match() {
|
|
|
142
144
|
}
|
|
143
145
|
found = 0
|
|
144
146
|
}
|
|
145
|
-
count == 0 {
|
|
147
|
+
count == 0 || found { next }
|
|
146
148
|
{ p = $0; sub(/[ \t\r]+$/, "", p) }
|
|
147
149
|
p == "" { next }
|
|
148
150
|
{
|
|
149
151
|
for (i = 1; i <= count; i++) {
|
|
150
|
-
if (p ~ res[i]) { print p; found = 1;
|
|
152
|
+
if (p ~ res[i]) { print p; found = 1; break }
|
|
151
153
|
}
|
|
152
154
|
}
|
|
153
155
|
END { exit(found ? 0 : 1) }
|