Skip to content

feat: add clone path and related test#752

Open
batleforc wants to merge 2 commits into
che-incubator:mainfrom
batleforc:clone-path
Open

feat: add clone path and related test#752
batleforc wants to merge 2 commits into
che-incubator:mainfrom
batleforc:clone-path

Conversation

@batleforc

@batleforc batleforc commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

In code-workspace, either use the clonePath if it exist or the project name to find the folder.

What issues does this PR fix?

eclipse-che/che#23909

How to test this PR?

Does this PR contain changes that override default upstream Code-OSS behavior?

  • the PR contains changes in the code folder (you can skip it if your changes are placed in a che extension )
  • the corresponding items were added to the CHANGELOG.md file
  • rules for automatic git rebase were added to the .rebase folder

Summary by CodeRabbit

  • New Features

    • Workspace generation now supports custom project clone paths, so workspace folder locations follow the configured directory layout.
  • Bug Fixes

    • Project synchronization now resolves paths using clonePath (fallback to project name), verifies they remain under the configured root, and safely skips invalid/out-of-root paths.
    • When the projects root is unset, synchronization now stops without changing the workspace.
    • Existing workspace entries/files are no longer duplicated or unnecessarily overwritten.
  • Tests

    • Added a flattened DevWorkspace fixture with clonePath and expanded coverage for generation and synchronization scenarios.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Click here to review and test in web IDE: Contribute

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR adds optional clonePath support to Project. Workspace generation and synchronization resolve project directories from clonePath or name, validate them under PROJECTS_ROOT, check existence, and avoid duplicate folders. Fixtures and tests cover these behaviors.

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

Sequence Diagram(s)

sequenceDiagram
  participant CodeWorkspace
  participant path
  participant FileSystem
  CodeWorkspace->>path: resolve(PROJECTS_ROOT, clonePath or name)
  CodeWorkspace->>CodeWorkspace: validate resolved path under PROJECTS_ROOT
  CodeWorkspace->>FileSystem: check resolved path exists
  CodeWorkspace->>CodeWorkspace: add workspace folder with resolved path
Loading

Suggested reviewers: azatsarynnyy, rgrunber, romannikitenko

🚥 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 is concise, imperative, and clearly describes the clonePath support plus related tests.
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.
Rebase Rules For Upstream Changes ✅ Passed Only launcher/* files changed; no files under code/ were modified, so .rebase rules and CHANGELOG updates are not required.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@launcher/src/code-workspace.ts`:
- Around line 156-161: `clonePath` in `code-workspace.ts` is being used directly
in `workspace.folders` path construction, which allows path traversal outside
`env.PROJECTS_ROOT`. Update the workspace-building logic around `pathProject` so
`clonePath` is validated/sanitized to ensure it stays relative to the projects
root before calling `fs.pathExists` or pushing a folder. Use the
`workspace.folders` append flow and the `project.clonePath || project.name`
assignment as the main place to enforce the check, and reject or ignore any
value that resolves outside `env.PROJECTS_ROOT`.

In `@launcher/tests/code-workspace.spec.ts`:
- Around line 525-557: Add a test in CodeWorkspace.generate() for the existing
single-project workspace case where the .code-workspace file already exists
under PROJECTS_ROOT using clonePath, not project.name. Update the
pathExists/readFile setup to return true for ${clonePath}/.code-workspace and
verify generate() looks up that exact location. This should cover the branch
that currently uses the wrong lookup key and ensure no writeFile occurs when the
workspace already exists.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 58ef240a-5a03-4d01-8b05-e7b1da04b9a5

📥 Commits

Reviewing files that changed from the base of the PR and between 828719e and f6e4d9f.

📒 Files selected for processing (4)
  • launcher/src/code-workspace.ts
  • launcher/src/flattened-devfile.ts
  • launcher/tests/_data/flattened.devworkspace.with-clone-path.yaml
  • launcher/tests/code-workspace.spec.ts

Comment thread launcher/src/code-workspace.ts Outdated
Comment thread launcher/tests/code-workspace.spec.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
launcher/src/code-workspace.ts (1)

162-162: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use const instead of let for pathProject.

pathProject is never reassigned.

♻️ Proposed fix
-      let pathProject = project.clonePath || project.name;
+      const pathProject = project.clonePath || project.name;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@launcher/src/code-workspace.ts` at line 162, Use const instead of let for
pathProject in the code-workspace logic because the value is never reassigned.
Update the declaration in the code that builds the workspace path (around the
pathProject assignment) so it remains immutable and matches the existing naming
in this section.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@launcher/src/code-workspace.ts`:
- Around line 163-167: The workspace-folder path validation in code-workspace.ts
is using a string-prefix check that can be bypassed by paths like sibling
directories with the same prefix. Update the fullPath validation in the
project-iteration logic to use a real path-boundary check based on path.relative
against env.PROJECTS_ROOT, and keep the existing skip/continue behavior when the
resolved path escapes the root.

---

Nitpick comments:
In `@launcher/src/code-workspace.ts`:
- Line 162: Use const instead of let for pathProject in the code-workspace logic
because the value is never reassigned. Update the declaration in the code that
builds the workspace path (around the pathProject assignment) so it remains
immutable and matches the existing naming in this section.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8bf1dbc1-438d-44fc-8113-055887b34452

📥 Commits

Reviewing files that changed from the base of the PR and between f6e4d9f and c991724.

📒 Files selected for processing (4)
  • launcher/src/code-workspace.ts
  • launcher/src/flattened-devfile.ts
  • launcher/tests/_data/flattened.devworkspace.with-clone-path.yaml
  • launcher/tests/code-workspace.spec.ts
✅ Files skipped from review due to trivial changes (1)
  • launcher/tests/_data/flattened.devworkspace.with-clone-path.yaml
🚧 Files skipped from review as they are similar to previous changes (2)
  • launcher/src/flattened-devfile.ts
  • launcher/tests/code-workspace.spec.ts

Comment thread launcher/src/code-workspace.ts Outdated
@batleforc
batleforc force-pushed the clone-path branch 2 times, most recently from d0cac29 to 11c0d7c Compare July 11, 2026 13:42
Signed-off-by: Max Batleforc <maxleriche.60@gmail.com>
Assisted-by: CodeRabbit review
@github-actions

Copy link
Copy Markdown
Contributor

@batleforc

Copy link
Copy Markdown
Contributor Author

Test looks ok, just fast forward to be in sync with main. OK for me @RomanNikitenko if you have time to review

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