Skip to content

Commit 1982ac5

Browse files
t3dotggclaude
andcommitted
fix(server): an empty heredoc ends at its terminator
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 9dee784 commit 1982ac5

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎apps/server/src/orchestration-v2/PullRequestSyncReactor.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,6 +1574,12 @@ describe("PullRequestSyncReactor", () => {
15741574
output: "https://github.com/owner/repository/pull/124",
15751575
linked: [],
15761576
},
1577+
{
1578+
name: "a create after an empty heredoc",
1579+
input: "cat > /tmp/notes.md <<'EOF'\nEOF\ngh pr create --fill",
1580+
output: "https://github.com/owner/repository/pull/124",
1581+
linked: [124],
1582+
},
15771583
{
15781584
name: "a read with no create",
15791585
input: "gh pr view 124 --json url --jq .url",

‎apps/server/src/orchestration-v2/PullRequestSyncReactor.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ const createCommandCount = (code: string) =>
7575
const SHELL_WRAPPER = /^\s*(?:\S*\/)?(?:ba|z|da|k)?sh\s+-l?c\s+(?=["'])([\s\S]*)$/u;
7676
const SHELL_WORD_PIECE = /"((?:\\[\s\S]|[^"\\])*)"|'([^']*)'|\\([\s\S])|(\S)/gu;
7777
// Heredoc bodies, quoted strings and comments are text a command carries, not commands it runs.
78-
const HEREDOC_BODY = /<<-?[ \t]*(['"]?)(\w+)\1[^\n]*\n[\s\S]*?(?:\n[ \t]*\2[ \t]*(?=\n|$)|$)/gu;
78+
const HEREDOC_BODY =
79+
/<<-?[ \t]*(['"]?)(\w+)\1[^\n]*\n(?:(?:[\s\S]*?\n)?[ \t]*\2[ \t]*(?=\n|$)|[\s\S]*$)/gu;
7980
const QUOTED_OR_COMMENT = /'[^']*'|"(?:\\[\s\S]|[^"\\])*"|(?<=^|[\s;&|(])#[^\n]*/gmu;
8081
const COMMAND_SEPARATOR = /&&|\|\||[;|\n]/u;
8182
// Commands that print other change requests' URLs, so output beside them proves nothing.

0 commit comments

Comments
 (0)