← Back to Pull requests

fix(file): preserve directory contents when a copy source ends in a dot #4193

Merged
oodadoudou merged 2 files (18 lines) on Nov 29, 2026 22:58 UTC
View on GitHub
oodadoudou oodadoudou commented on Nov 29, 2026 19:58 UTC
Author

What a user gets

rig file copy ./source/. ./destination put the files under destination/source/ when the destination already existed. With the same arguments, rsync puts them directly in destination/. Preserve that directory-content meaning when normalizing local and remote operands.

How you verified it

Reproduced the extra directory with a real local transfer. The native rsync test now checks the resulting file tree for source, source/ and source/.. A separate assertion checks the rsync argument for a registered SSH source ending in /..

At 422b32bdd, vitest run packages/cli/test/file-transfer.test.ts packages/cli/test/file-command.test.ts: 64 passed. The workspace build and typecheck passed with the five changes together. I did not run the full npm test locally.

Anything you were unsure about

The remote case checks the planned arguments; the actual transfer ran locally.

  • One concern per PR; no version bump; no CHANGELOG.md edit

  • Tests added or updated where the change is testable

  • I listed the checks I ran, their results, and any checks I could not run
  • <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    Bug Fixes
    Directory transfers now consistently copy a directory’s contents when the source path ends with /., matching the behavior for paths ending in a separator.
    * Remote transfer planning and command construction now preserve this directory-copy behavior.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 18 lines (+13 / -5) across 2 files Reviewer: openrig-review Review duration: 179m
    All Vouch review confidence checks passed
    Residual risk 0.02 = Change Risk (0.22) × (1 − Review Confidence (0.91)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.22 · 18 lines diff across 2 files
    0.22
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.93 · 3 substantive comment(s)
    0.93
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    90%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.176
    Real PR Conversation Timeline
    5 items
    coderabbitai[bot] coderabbitai[bot] commented on Nov 29, 2026 19:59 UTC
    Bot

    <!-- coderabbit-ai-generated:v1 -->

    <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
    <!-- review_stack_entry_start -->

    <a href="https://app.coderabbit.ai/change-stack/mvschwarz/openrig/pull/4193?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg" alt="Explain Change →" height="32"></picture></a>

    <!-- review_stack_entry_end -->
    <!-- recent_review_status_start -->

    No actionable comments were generated in the recent review.

    <!-- recent_review_status_end -->
    <!-- walkthrough_start -->

    <details>
    <summary><strong>Walkthrough</strong></summary>
    <dl>
    <dd>
    <br>

    Local and remote path checks now preserve trailing-slash semantics for paths ending in /.. Tests cover planned rsync operands and native rsync behavior for the supported source suffixes.

    Changes: Directory path handling

    |Layer / File(s)|Summary|
    |:---|:---|
    |Preserve directory path semantics <br> packages/cli/src/lib/file-transfer.ts, packages/cli/test/file-transfer.test.ts|Local and remote path checks preserve trailing separators for paths ending in /.. Tests cover planned rsync operands and native rsync behavior for empty, /, and /. suffixes.|

    <!-- change_assessment_start -->
    Estimated code review effort: 2 (Simple) | ~10 minutes

    <!-- change_assessment_commit:"422b32bddf008a335f0483fd4485417d753174f9" -->
    <!-- change_assessment_priority:{"version":1,"urgency":"p2","manual":false} -->
    Change: Bug fix
    <!-- change_assessment_end -->

    Suggested reviewers: vaishnavi220506

    </dd>
    </dl>
    </details>

    <!-- walkthrough_end -->
    <details>
    <summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · up to <code>422b3</code></summary>
    <dl>
    <dd>
    <br>

    <!-- final_review_risk_start -->
    <!-- final_review_risk_label
    Merge Risk: ⚪ Minimal · up to 422b3
    -->
    <!-- final_review_risk_coverage:{"sourceCommitId":"422b32bddf008a335f0483fd4485417d753174f9","coveredCommitId":"422b32bddf008a335f0483fd4485417d753174f9","kind":"reviewed"} -->

    This change makes copying a source ending in /. place its contents directly in the destination, as rsync does. Tests cover the changed behavior and no merge-blocking concerns were found.
    <!-- final_review_risk_end -->

    </dd>
    </dl>
    </details>
    <!-- pre_merge_checks_walkthrough_start -->

    <details>
    <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4</strong></summary>
    <dl>
    <dd>
    <br>

    | Check name | Status | Explanation |
    | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | Description Check | !Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
    | Title check | !Passed | The title names the change: copying a directory's contents when a copy source ends in a dot. The raw summary says checkLocalPath and checkRemotePath now treat a final '.' component as a request to cop… |
    | 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. |

    <details>
    <summary><strong>Full details: Title check</strong></summary>
    <dl>
    <dd>
    <br>

    Explanation

    The title names the change: copying a directory's contents when a copy source ends in a dot. The raw summary says checkLocalPath and checkRemotePath now treat a final '.' component as a request to copy directory contents, and the tests cover remote sources ending in '/.'. The title states the main change and the fix type. It does not mention the remote path handling or the test changes, which the title does not need to cover.

    </dd>
    </dl>
    </details>

    </dd>
    </dl>
    </details>

    <!-- pre_merge_checks_walkthrough_end -->
    <!-- finishing_touch_checkbox_start -->

    <details>
    <summary><strong>Finishing Touches</strong></summary>
    <dl>
    <dd>
    <br>

    <details open>
    <summary><strong>Generate unit tests (beta)</strong></summary>
    <dl>
    <dd>
    <br>

  • <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Create a new PR
  • </dd>
    </dl>
    </details>

    </dd>
    </dl>
    </details>

    <!-- finishing_touch_checkbox_end -->

    <!-- autopilot:start -->

  • <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

  • <!-- autopilot:end -->
    <!-- tips_start -->

    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.

    <details>
    <summary><strong>Share</strong></summary>
    <dl>
    <dd>
    <br>

  • X

  • Mastodon

  • Reddit

  • LinkedIn
  • </dd>
    </dl>
    </details>

    <!-- tips_end -->
    <!-- recent_review_start -->

    <h6>
    <details>
    <summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Recent review info</strong></summary>
    <dl>
    <dd>
    <br>

    <!-- review_info_content -->
    <details>
    <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</strong></summary>
    <dl>
    <dd>
    <br>

  • Source mode: Auto

  • Repository: Unavailable

  • Branch: Unavailable

  • File: No configuration file from this repository applied

  • Commit: Unavailable

  • Layers: defaults

  • Review profile: CHILL

  • Plan: Advanced

  • Run ID: 961aca76-15b1-4cd7-a18c-122e22b4935b
  • </dd>
    </dl>
    </details>

    <details>
    <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</strong></summary>
    <dl>
    <dd>
    <br>

    Reviewing files that changed from the base of the PR and between 68e44f77b808b3242ced5f7d7191d3bf545e7c33 and 422b32bddf008a335f0483fd4485417d753174f9.

    </dd>
    </dl>
    </details>

    <details>
    <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 2</strong></summary>
    <dl>
    <dd>
    <br>

    packages/cli/src/lib/file-transfer.ts
    packages/cli/test/file-transfer.test.ts

    </dd>
    </dl>
    </details>

    Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 0 remain after this review.

    </dd>
    </dl>
    </details>
    </h6>

    <!-- recent_review_end -->

    openrig-review openrig-review approved these changes on Nov 29, 2026 20:44 UTC
    Approved Reviewer

    Approving the reviewed head 422b32bd to start the macOS package tests. A copy source ending in /. copies the directory's contents, as rsync does, for local and remote sources. Thank you, @oodadoudou.

    mvschwarz mvschwarz commented on Nov 29, 2026 23:14 UTC
    Contributor

    Thanks, @oodadoudou, this is merged into main now. A rig file copy source ending in /. copies the folder's contents, as rsync does, instead of creating a folder of that name inside the destination. A bare . follows the same rule, so rig file copy . <dest> copies the current folder's contents. If you ever feel like adding a test for that bare . case, it would be welcome. It's on main and not yet in a published release.

    oodadoudou oodadoudou commented on Nov 30, 2026 22:07 UTC
    Author

    Covered the bare . source in #4236. I also ran the built command against macOS rsync from a temporary directory and the file landed directly in the destination.

    Assignees
    oodadoudou oodadoudou
    Labels
    risk: low confidence: 90.6% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 22.1% (LOW) · Higher = larger blast radius
    22.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 90.6% · Lower = rushed or shallow review
    90.6%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 2.1% · Safe to merge
    2.1%