@ericrisco/rsc 3.0.7 → 3.0.9

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.
@@ -143,7 +143,11 @@ const HAS_INLINE_M = /(?:^|\s)(?:-[a-zA-Z]*m|--message)(?:=|\s|$)/;
143
143
  // `git` must be the command being RUN, not text inside someone else's argument —
144
144
  // otherwise `echo "git commit -m x"` or `grep "git commit -m"` gets denied, and a guard
145
145
  // that blocks the discussion of commits is exactly the kind that gets switched off.
146
- const RUNS_GIT = /^\s*(?:sudo\s+)?(?:[A-Za-z_][A-Za-z0-9_]*=\S*\s+)*git\b/;
146
+ const RUNS_GIT = /^\s*(?:(?:sudo|env|command|exec|nohup)\s+|[A-Za-z_][A-Za-z0-9_]*=\S*\s+)*git\b/;
147
+
148
+ // A commit handed to a shell as a string (`bash -c "git commit -m …"`, `eval …`) is read inside
149
+ // that string (E2E defect 15). shell-unwrap.mjs is a sibling under `.rsc/`; without it, as before.
150
+ const SH = await import(new URL('./shell-unwrap.mjs', import.meta.url)).catch(() => null);
147
151
 
148
152
  const SEPARATORS = /&&|\|\||[;\n]/;
149
153
 
@@ -174,6 +178,15 @@ function inlineMessage(segment) {
174
178
  export function commitMessages(command) {
175
179
  const cmd = String(command ?? '');
176
180
  if (!COMMIT.test(cmd)) return [];
181
+ const inner = SH ? SH.innerScripts(cmd) : [];
182
+ if (!inner.length) return directMessages(cmd);
183
+ // The wrapped strings are read on their own; the rest of the chain without them, so a commit is
184
+ // never read twice (once naively through the quotes, once unwrapped).
185
+ const rest = SH.segments(SH.withoutHeredocs(cmd)).filter((seg) => SH.unwrap(seg)?.inner === undefined).join('\n');
186
+ return [...directMessages(rest), ...inner.flatMap(commitMessages)];
187
+ }
188
+
189
+ function directMessages(cmd) {
177
190
 
178
191
  // The heredoc form must be handled before any splitting: its body is the message and
179
192
  // may legitimately contain && or ;. The command that owns it is whatever runs just