Skip to content

fix: clone collection#6322

Merged
bijin-bruno merged 3 commits intousebruno:mainfrom
naman-bruno:bufix/clone-collection
Dec 5, 2025
Merged

fix: clone collection#6322
bijin-bruno merged 3 commits intousebruno:mainfrom
naman-bruno:bufix/clone-collection

Conversation

@naman-bruno
Copy link
Collaborator

@naman-bruno naman-bruno commented Dec 5, 2025

Description

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability of collection cloning, renaming, and file-copying by resolving configuration paths from the source, consistently honoring config file formats, and skipping root-level configuration files during replication—applied across all collection operations for more predictable behavior.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 5, 2025

Walkthrough

Resolves collection file paths from the source collection directory (using previousPath) instead of the process CWD, passes explicit { format } options to YAML/BRU parse and stringify calls, and expands root-config skip logic to treat both opencollection.yml and bruno.json as root config files during clone/rename and file-copy operations.

Changes

Cohort / File(s) Change Summary
Collection IPC updates
packages/bruno-electron/src/ipc/collection.js
Replace CWD-based reads with path.join(previousPath, ...) resolved paths; introduce configFilePath variables for YAML/BRU handling; pass explicit { format } / { format: 'yml' } to parseCollection, stringifyCollection, and collectionPathname calls; extend root-config skip checks to include both opencollection.yml and bruno.json; adjust file-copy and relative-path calculations to use resolved configFilePath; apply consistent behavior across clone-collection and rename-collection flows.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Single file but multiple, similar edits across different control paths.
  • Review focus:
    • Verify every occurrence of collection config reads/writes now uses previousPath-based resolution.
    • Confirm the correct { format } value is passed (e.g., 'yml' vs bruno) in each parse/stringify call.
    • Ensure isRootConfigFile / root-skip logic correctly matches both opencollection.yml and bruno.json only at the collection root.
    • Check relative-path calculations and copy logic use the resolved configFilePath consistently.

Poem

Files once tied to the working tree, now find their way,
previousPath lights the path where configs stay.
YAML and BRU wear formats plain,
Root files skipped, no duplicate pain—
Small, tidy steps for a steadier day. 🌟

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: clone collection' directly corresponds to the main changes in the PR, which focus on fixing collection cloning logic by improving path resolution and format handling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/bruno-electron/src/ipc/collection.js (1)

218-224: Consider improving multiline condition formatting.

The logic correctly skips both opencollection.yml and bruno.json at the collection root. However, the multiline boolean expression could be more readable.

Apply this diff for improved readability:

-    // skip if the file is opencollection.yml or bruno.json at the root of the collection
-    const isRootConfigFile = (path.basename(sourceFilePath) === 'opencollection.yml' || path.basename(sourceFilePath) === 'bruno.json')
-      && path.dirname(sourceFilePath) === previousPath;
+    // skip if the file is opencollection.yml or bruno.json at the root of the collection
+    const basename = path.basename(sourceFilePath);
+    const isRootConfigFile = 
+      (basename === 'opencollection.yml' || basename === 'bruno.json') &&
+      path.dirname(sourceFilePath) === previousPath;
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 80b017f and 49a569d.

📒 Files selected for processing (1)
  • packages/bruno-electron/src/ipc/collection.js (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation, never tabs
Use single quotes for strings instead of double quotes
Always add semicolons at the end of statements
No trailing commas in code
Always use parentheses around parameters in arrow functions, even for single parameters
For multiline constructs, put opening braces on the same line with a minimum of 2 elements for multiline formatting
No newlines inside function parentheses
Space before and after the arrow in arrow functions: () => {}
No space between function name and parentheses: func() not func ()
Semicolons should go at the end of the line, not on a new line
Function names should be concise and descriptive
Add JSDoc comments to provide details to abstractions
Avoid single-line abstractions where all that is being done is increasing the call stack with one additional function
Add meaningful comments to explain complex code flow instead of obvious comments

Files:

  • packages/bruno-electron/src/ipc/collection.js
🧬 Code graph analysis (1)
packages/bruno-electron/src/ipc/collection.js (1)
packages/bruno-filestore/src/index.ts (2)
  • parseCollection (77-84)
  • stringifyCollection (86-93)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Unit Tests
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: CLI Tests
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: SSL Tests - Linux
  • GitHub Check: SSL Tests - Windows
🔇 Additional comments (4)
packages/bruno-electron/src/ipc/collection.js (4)

188-199: LGTM: Dynamic path resolution and explicit format handling.

The changes correctly resolve file paths from the source collection and explicitly specify the YAML format during parsing and stringification, aligning with the parseCollection and stringifyCollection APIs.


201-206: LGTM: Consistent path resolution for bruno.json.

Correctly applies the same dynamic path resolution pattern for bruno.json files.


246-256: LGTM: Consistent implementation in rename-collection handler.

Applies the same dynamic path resolution and explicit format specification pattern for YAML collections.


258-263: LGTM: Consistent bruno.json handling in rename-collection.

Correctly applies dynamic path resolution for bruno.json configuration files.

@pull-request-size pull-request-size bot added size/M and removed size/S labels Dec 5, 2025
@pull-request-size pull-request-size bot added size/S and removed size/M labels Dec 5, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/bruno-electron/src/ipc/collection.js (1)

241-264: Rename collection: configFilePath handling is solid; consider keeping YAML meta in sync

Resolving opencollection.yml / bruno.json via collectionPathname and using explicit YAML format in the parse/stringify calls makes rename independent of the process CWD and consistent with how collections are created/imported.

One small optional improvement: if collectionRoot.meta.name is used anywhere for YAML collections, you may want to update it alongside brunoConfig.name before stringifying so both sources of the name stay in sync.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aa9c1e7 and 7cbf141.

📒 Files selected for processing (1)
  • packages/bruno-electron/src/ipc/collection.js (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation, never tabs
Use single quotes for strings instead of double quotes
Always add semicolons at the end of statements
No trailing commas in code
Always use parentheses around parameters in arrow functions, even for single parameters
For multiline constructs, put opening braces on the same line with a minimum of 2 elements for multiline formatting
No newlines inside function parentheses
Space before and after the arrow in arrow functions: () => {}
No space between function name and parentheses: func() not func ()
Semicolons should go at the end of the line, not on a new line
Function names should be concise and descriptive
Add JSDoc comments to provide details to abstractions
Avoid single-line abstractions where all that is being done is increasing the call stack with one additional function
Add meaningful comments to explain complex code flow instead of obvious comments

Files:

  • packages/bruno-electron/src/ipc/collection.js
🧬 Code graph analysis (1)
packages/bruno-electron/src/ipc/collection.js (1)
packages/bruno-filestore/src/index.ts (2)
  • parseCollection (77-84)
  • stringifyCollection (86-93)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: SSL Tests - Linux
  • GitHub Check: SSL Tests - Windows
  • GitHub Check: CLI Tests
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: Unit Tests
🔇 Additional comments (1)
packages/bruno-electron/src/ipc/collection.js (1)

169-238: Clone collection: config resolution and root-config skip look correct

Reading the root config from previousPath (opencollection.yml / bruno.json) and passing the detected format into parseCollection/stringifyCollection, plus explicitly skipping those root config files in the copy loop, fixes the previous overwrite risk and keeps the cloned collection’s config consistent with the new name. I don’t see any correctness or edge‑case issues here.

@bijin-bruno bijin-bruno merged commit 5302add into usebruno:main Dec 5, 2025
8 checks passed
naman-bruno added a commit to naman-bruno/bruno that referenced this pull request Dec 6, 2025
* fix: clone collection
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.

2 participants