Skip to content

refactor: end generated files with a newline - #7437

Merged
viceice merged 1 commit into
mainfrom
refactor/file-content-tag
Sep 23, 2026
Merged

viceice merged 1 commit into
mainfrom
refactor/file-content-tag

Conversation

@viceice

@viceice viceice commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Adds a fileContent tag — codeBlock plus the trailing newline every common-tags tag trims — and uses it wherever content is written to a file: apt sources, conan profile, maven and gradle settings, mono scripts, node env and shell wrappers.

exportToolEnvContent no longer trims its input, and the shell wrapper is built from a single template. The generated wrapper is unchanged.

First of the #7436 follow-ups.

🤖 Generated with Claude Code

Adds a `fileContent` tag, which is `codeBlock` from common-tags plus the
trailing newline every common-tags tag trims away, and uses it wherever the
content is written to a file: the apt sources, the conan profile, the maven and
gradle settings, the mono scripts, the node tool env and the shell wrappers.

`PathService.exportToolEnvContent` no longer trims the content it appends, so
the caller decides how the block ends, and the shell wrapper is built from a
single template plus pieces which each end with a newline. The wrapper itself
is unchanged.

Co-Authored-By: Claude Opus 5 <michael.kriese+claude-code@mend.io>
@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 03cdfe84-e7a8-4d90-a55d-551dd45f475f

📥 Commits

Reviewing files that changed from the base of the PR and between 3ccff09 and 37d9ccc.

📒 Files selected for processing (12)
  • src/cli/services/link-tool.service.ts
  • src/cli/services/path.service.ts
  • src/cli/tools/dotnet/mono.spec.ts
  • src/cli/tools/dotnet/mono.ts
  • src/cli/tools/git/index.spec.ts
  • src/cli/tools/git/index.ts
  • src/cli/tools/java/utils.ts
  • src/cli/tools/node/index.ts
  • src/cli/tools/python/conan.ts
  • src/cli/utils/index.ts
  • src/cli/utils/tags.spec.ts
  • src/cli/utils/tags.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The change adds and exports a fileContent template tag that strips indentation, trims content, and appends a trailing newline. Tool file generators and shell script construction now use it. Environment content appending no longer trims the supplied content or adds a trailing newline.

Changes

File Content Formatting

Layer / File(s) Summary
Add and export fileContent
src/cli/utils/tags.ts, src/cli/utils/index.ts, src/cli/utils/tags.spec.ts
Adds and exports fileContent. Tests cover indentation removal, interpolation, and trailing newlines.
Use fileContent in tool generators
src/cli/tools/dotnet/mono.ts, src/cli/tools/dotnet/mono.spec.ts, src/cli/tools/git/index.ts, src/cli/tools/git/index.spec.ts, src/cli/tools/java/utils.ts, src/cli/tools/node/index.ts, src/cli/tools/python/conan.ts
Mono, Git, Java, Node, and Conan generated content now uses fileContent. The Mono wrapper expectation includes a trailing newline.
Build shell and environment content
src/cli/services/link-tool.service.ts, src/cli/services/path.service.ts
LinkToolService uses fileContent for its initial shell template and appends later content as newline-terminated strings. exportToolEnvContent appends supplied content unchanged.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 37d9c

The generated files now consistently end with a newline without changing their established content or shell-wrapper ordering. No actionable merge risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 12 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: generated files now end with a newline.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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

@gitar-bot

gitar-bot Bot commented Sep 23, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

🟡 Medium risk · Generated configuration and script files now consistently end with a newline.

Refactors generated file output to consistently end with a newline by introducing a fileContent template tag that combines stripIndentTransformer, trimResultTransformer, and a custom newline appender. Converts all file-writing call sites to use the new tag, ensuring consistent formatting across apt sources, Conan profiles, Maven settings, Gradle properties, shell scripts, and tool wrappers. All tests pass with 100% code coverage.

Review coverage

📋 Rules No rules evaluated

🧪 Functional validation Not enabled · Set up

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Counting what did not apply, without listing it.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Important

Your trial ends in 2 days — upgrade now to keep code review, CI analysis, auto-apply, custom automations, and more.

Was this helpful? React with 👍 / 👎 | Gitar

@viceice
viceice added this pull request to stack #7439 September 23, 2026 11:29
@viceice
viceice added this pull request to the merge queue Sep 23, 2026
Merged via the queue into main with commit 1344d3d Sep 23, 2026
62 checks passed
@viceice
viceice deleted the refactor/file-content-tag branch September 23, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant