-
Notifications
You must be signed in to change notification settings - Fork 946
fix: preserve force:true dependencies during lane merge #10057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
davidfirst
merged 12 commits into
master
from
fix/preserve-scope-specific-policy-during-merge
Oct 29, 2025
Merged
fix: preserve force:true dependencies during lane merge #10057
davidfirst
merged 12 commits into
master
from
fix/preserve-scope-specific-policy-during-merge
Oct 29, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…re-scope merge Fixes an issue where scope-specific dependencies (set via `bit dependencies set`) were being lost during bare-scope lane merges when the merge introduced dependency changes. ## Changes ### Scope-specific policy preservation - Added logic in `merging.main.runtime.ts:applyVersion()` to merge scope-specific dependencies into merged config right before saving to unmergedComponents - Scope-specific dependencies (marked with `__specific: true`) are preserved with `force: true` flag - Merge config takes precedence when dependencies exist in both sources ### Deleted dependency handling - Added detection in `component-config-merger.ts` for dependencies deleted via `bit dependencies unset` - When a dependency exists in base and current but not in other (main), it's marked with `version: '-'` - Deletion markers are filtered out before saving to ensure clean config ### Architecture - Processing happens in ONE place: when mergedConfig is created and saved to unmergedComponents - Both workspace and bare-scope merges read the already-processed config - No code duplication - single source of truth for merge logic - Only stores manually-set dependencies (`force: true`) in config; auto-detected deps are recalculated ## Test Scenarios 1. **Scope-specific dep preserved**: Dependency set via `bit dependencies set` on lane is preserved when main is merged to lane 2. **Deleted dep respected**: Dependency unset on main via `bit dependencies unset` is properly removed during merge, even if it was set on lane 3. **Auto-detected dep updated**: Regular dependencies are updated to versions from merged branch as expected This ensures scope-specific policy is preserved while respecting explicit deletions during lane merges.
When merging scope-specific dependencies into merged config, convert object format to array format to match config-merger expectations. Also ensure empty arrays/objects are deleted to prevent downstream errors.
…format consistency - Remove __specific check to handle all force:true dependencies (both from 'bit deps set' and workspace variants) - Convert object format to array format when merging policies to maintain consistency expected by config-merger - Ensures all dependency types use array format after merge to prevent 'forEach is not a function' errors
- Export PolicyDependency type from config-merger - Use typed PolicyDependency[] instead of any[] in addScopePolicyToMergedArray - Remove dependencyId fallback (only use name field) - Add explicit types to mergedPolicy and conflictedPolicy objects
Explain why this method is necessary - without it, explicitly set dependencies from the model would be ignored when mergeConfig has a policy. This is similar to how 'bit deps set' preserves previous dependencies by copying them to .bitmap.
…ergeScopeSpecificDepsPolicy Update comments that referenced the old method name to reference the new method that handles the same functionality in merging.main.runtime
…sPolicy The config-merger always returns policy in array format (Record<string, PolicyDependency[]>), so the else branch handling object format was unreachable dead code. Removed it to match the actual behavior and fix TypeScript errors with the typed mergeConfigPolicy.
… arrays Remove dead code that handled object format and null checks. The policy is always in array format (Record<string, PolicyDependency[]>) after config-merger, so we only need to filter the arrays for deletion markers.
GiladShoham
approved these changes
Oct 29, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes an issue where force:true dependencies were being lost during bare-scope lane merges.
When merging lanes in bare-scope with dependency updates, dependencies with force:true (whether set via
bit dependencies setor workspace variants) were not being preserved in the merged config. This only affected merges that introduced dependency changes.Additionally, handles the case where a dependency was explicitly removed on main via
bit dependencies unset- ensuring it's properly removed during merge even if it was set on the lane. E2E tests confirm this works for both bare-scope and workspace merges.Changes
Architecture
merging.main.runtime.ts:applyVersion()mergedConfigis created from config merger, we immediately:__specific: true)version: '-')unmergedComponentsunmerged.json. During snap, this config is used directly without reprocessing. Previously,unmerged.jsonlacked scope data, making dependency deletion handling complex and requiring separate logic for workspace vs bare-scope merges.Force:true policy preservation
mergeScopeSpecificDepsPolicy()to handle ALL dependencies with force:true__specific: truecheck to include workspace variant dependencies (per PR fix(config-merger): preserve force:true deps when merging unchanged config with auto deps #10049)Deleted dependency handling
component-config-merger.tsfor dependencies deleted viabit dependencies unsetversion: '-'filterDeletedDependenciesFromConfig()to remove deletion markers before savingunmerged.json file size
force: true) from scope in merged configforce: false) are not stored inunmerged.jsonunmerged.jsonsize reasonable