Skip to content

Commit a558c81

Browse files
committed
fix(core): keep generated entrypoint heredoc shell-valid
- remove problematic indentation around EOFMOVE block in agent entrypoint template - add regression checks for EOFMOVE layout and bash -n syntax validation
1 parent 8393213 commit a558c81

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

packages/lib/src/core/templates-entrypoint/agent.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ const renderAgentIssueReview = (config: TemplateConfig): string =>
163163
String.raw`if [[ "$AGENT_OK" -eq 1 && "$AGENT_AUTO" == "1" && -n "$ISSUE_NUM" ]]; then`,
164164
indentBlock(renderAgentIssueComment(config)),
165165
"",
166-
indentBlock(renderAgentIssueMove(config)),
166+
renderAgentIssueMove(config),
167167
"fi"
168168
].join("\n")
169169

@@ -184,7 +184,7 @@ if [[ "$CLONE_OK" -eq 1 && -n "$AGENT_MODE" ]]; then`,
184184
"",
185185
indentBlock(renderAgentModeCase(config)),
186186
"",
187-
indentBlock(renderAgentIssueReview(config)),
187+
renderAgentIssueReview(config),
188188
"",
189189
indentBlock(renderAgentFinalize()),
190190
"fi"

packages/lib/tests/usecases/prepare-files.test.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { describe, expect, it } from "@effect/vitest"
55
import { Effect } from "effect"
66

77
import type { TemplateConfig } from "../../src/core/domain.js"
8+
import { runCommandExitCode } from "../../src/shell/command-runner.js"
89
import { prepareProjectFiles } from "../../src/usecases/actions/prepare-files.js"
910

1011
const withTempDir = <A, E, R>(
@@ -113,8 +114,17 @@ describe("prepareProjectFiles", () => {
113114
)
114115

115116
const dockerfile = yield* _(fs.readFileString(path.join(outDir, "Dockerfile")))
116-
const entrypoint = yield* _(fs.readFileString(path.join(outDir, "entrypoint.sh")))
117+
const entrypointPath = path.join(outDir, "entrypoint.sh")
118+
const entrypoint = yield* _(fs.readFileString(entrypointPath))
117119
const composeBefore = yield* _(fs.readFileString(path.join(outDir, "docker-compose.yml")))
120+
const entrypointSyntaxExitCode = yield* _(
121+
runCommandExitCode({
122+
cwd: outDir,
123+
command: "bash",
124+
args: ["-n", entrypointPath]
125+
})
126+
)
127+
expect(entrypointSyntaxExitCode).toBe(0)
118128
expect(dockerfile).toContain("docker-compose-v2")
119129
expect(dockerfile).toContain("gitleaks version")
120130
expect(dockerfile).toContain(
@@ -130,6 +140,9 @@ describe("prepareProjectFiles", () => {
130140
expect(entrypoint).toContain('"plugin": ["oh-my-opencode"]')
131141
expect(entrypoint).toContain("branch '$REPO_REF' missing; retrying without --branch")
132142
expect(entrypoint).not.toContain("git ls-remote --symref")
143+
expect(entrypoint).toContain("cat > \"$MOVE_SCRIPT\" << 'EOFMOVE'")
144+
expect(entrypoint).toMatch(/\nEOFMOVE\n\s*chmod \+x "\$MOVE_SCRIPT"/)
145+
expect(entrypoint).not.toContain("\n EOFMOVE\n")
133146
expect(composeBefore).toContain("container_name: dg-test")
134147
expect(composeBefore).toContain("restart: unless-stopped")
135148
expect(composeBefore).toContain(":/home/dev/.docker-git")

0 commit comments

Comments
 (0)