Skip to content

fix: only reuse existing folders in createDir - #7485

Merged
viceice merged 1 commit into
mainfrom
fix/create-dir-real-dirs
Sep 24, 2026
Merged

viceice merged 1 commit into
mainfrom
fix/create-dir-real-dirs

Conversation

@viceice

@viceice viceice commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Changes

PathService.createDir checks an existing path with lstat and only leaves it as is when it is a real folder. A symlink or a file at that path now throws instead of being treated as an existing folder.

Context

  • This closes an existing Issue, Closes: #
  • This doesn't close an Issue, but I accept the risk that this PR may be closed if maintainers disagree with its opening or implementation

AI assistance disclosure

Did you use AI tools to create any part of this pull request?

  • No — I did not use AI for this contribution.
  • Yes — minimal assistance (e.g., IDE autocomplete, small code completions, grammar fixes).
  • Yes — substantive assistance (AI-generated non‑trivial portions of code, tests, or documentation).
  • Yes — other (please describe):

Code and tests were written by Claude Opus 5.5 in Claude Code.

Use of AI in replying to PR comments

Who answers review comments:

  • @username will read and reply directly. Name the account.
  • An agent will draft replies and @viceice will read them before they are posted.
  • Nobody has explicitly committed to replying.

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified tests

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Directory creation now reports an error when the target path is an existing file or symlink, instead of silently succeeding.

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

coderabbitai Bot commented Sep 24, 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: d3ada7b4-c143-4e3c-8ef1-b84057e72190

📥 Commits

Reviewing files that changed from the base of the PR and between fb6acd9 and 0fed40c.

📒 Files selected for processing (2)
  • src/cli/services/path.service.spec.ts
  • src/cli/services/path.service.ts

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


📝 Walkthrough

Walkthrough

PathService.createDir now checks the type of an existing path. It returns for directories and rejects symlinks, files, and other non-directory entries. Tests cover existing symlink and file paths.

Changes

createDir path validation

Layer / File(s) Summary
Existing path type check
src/cli/services/path.service.ts, src/cli/services/path.service.spec.ts
createDir uses lstat to distinguish directories from other existing paths. It throws Path exists and is not a directory: <path> for non-directories. Tests assert rejection for a symlink and a file.

Priority: ⬇️ Low

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

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 0fed4

The change rejects file and symlink targets instead of treating them as directories, and no in-repository workflow was found to rely on that prior behavior. No actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: createDir now reuses only existing folders.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
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.
✨ Finishing Touches
📝 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 24, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

🟡 Medium risk · createDir now rejects existing symlinks and files instead of reusing them

Adds validation to PathService.createDir to only reuse existing directories, now throwing an error if the path is a symlink or file instead of silently treating it as an existing folder. No issues found.

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 1 day — 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 the merge queue Sep 24, 2026
Merged via the queue into main with commit 70e8f77 Sep 24, 2026
62 checks passed
@viceice
viceice deleted the fix/create-dir-real-dirs branch September 24, 2026 13:43
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