Skip to content

refactor(devcontainer): flatten shell commands - #1052

Merged
skevetter merged 2 commits into
mainfrom
refactor/flatten-shell-commands
Aug 18, 2026
Merged

skevetter merged 2 commits into
mainfrom
refactor/flatten-shell-commands

Conversation

@skevetter

@skevetter skevetter commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Why

Devcontainer entrypoint scripts were built as multi-line Go string literals joined
with \n. In the generated docker-compose.devcontainer.*.yml files this forces
yaml.v3 into block-scalar (|) style, so the entrypoint shows up as several
log lines (with stray blank lines) instead of one, and is more prone to
newline/formatting issues when passed through sh -c.

What

  • Added joinShellStatements(...string) string (pkg/devcontainer/single.go),
    joining shell statements with ; instead of embedded newlines.
  • DefaultEntrypoint, GetStartScript (single.go), and
    buildOverrideEntrypoint (compose_up.go) now build their scripts from an
    explicit []string of statements and flatten them with the helper, so the
    scripts — and therefore the compose YAML entrypoint field — render on a
    single line.
  • Factored the shared "echo Container started" / trap "exit 0" 15 /
    /bin/sh literals into package constants (startScriptEchoStatement,
    startScriptTrapStatement, shShellPath) to avoid duplicating them across
    single.go and compose_up.go.
  • Preserved the "$$@" compose-escaping in buildOverrideEntrypoint: the
    compose CLI interpolates $VAR/${VAR} when it parses the override file,
    so the literal $@ passthrough must stay doubled to survive that
    round-trip (see composeLabelEscaper in the same file). The result is
    behavior-preserving, single-line output.

Tests

  • single_test.go: TestDefaultEntrypointSingleLine,
    TestGetStartScriptSingleLine, TestGetStartScriptPreservesStatementOrder,
    TestGetStartScriptOmitsEmptyStatementForNoCustomEntrypoints.
  • compose_test.go: TestBuildOverrideEntrypointSingleLine,
    TestBuildOverrideEntrypointComposeEscapesExecPassthrough (regression test
    for the $$@ escaping), TestBuildOverrideEntrypointAppendsUserEntrypoint,
    TestBuildOverrideEntrypointKeepsDefaultEntrypointReachable.

Signed-off-by: Samuel K skevetter@pm.me

@netlify

netlify Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for images-devsy-sh canceled.

Name Link
🔨 Latest commit 9b60368
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a838947ed268900085fdd4f

@netlify

netlify Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit 9b60368
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a83894737721e00089bfb64

@coderabbitai

coderabbitai Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@skevetter, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 56 seconds

Limit details: You’ve used all 1 included review currently available under your plan.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 49c3f5ec-eb49-4f6a-bbbd-987230f53e5c

📥 Commits

Reviewing files that changed from the base of the PR and between b357a95 and 9b60368.

📒 Files selected for processing (4)
  • pkg/devcontainer/compose_test.go
  • pkg/devcontainer/compose_up.go
  • pkg/devcontainer/single.go
  • pkg/devcontainer/single_test.go

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codacy-production

codacy-production Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 33 complexity · 0 duplication

Metric Results
Complexity 33
Duplication 0

View in Codacy

AI Reviewer: run a review on demand. To trigger the first review automatically, go to your organization or repository integration settings. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

Build entrypoint scripts by joining statements with '; ' instead of
embedded newlines. Single-line scripts survive log lines and YAML
string scalars intact (no more block-scalar '|' with blank lines).

Preserves the '$$@' compose-YAML escaping required by docker
compose's variable interpolation on the entrypoint round-trip; the
prior draft of this refactor had regressed that to a single '$',
which would break exec passthrough under compose.

Signed-off-by: Samuel K <skevetter@pm.me>
@skevetter
skevetter force-pushed the refactor/flatten-shell-commands branch from 3b82954 to ea1c06c Compare August 17, 2026 18:20
@github-actions github-actions Bot added size/l and removed size/m labels Aug 17, 2026
@skevetter
skevetter marked this pull request as ready for review August 17, 2026 22:20
@mergify

mergify Bot commented Aug 17, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@skevetter
skevetter merged commit 4fc4340 into main Aug 18, 2026
136 of 138 checks passed
@skevetter
skevetter deleted the refactor/flatten-shell-commands branch August 18, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant