diff --git a/scopes/lanes/merge-lanes/merge-lanes.main.runtime.ts b/scopes/lanes/merge-lanes/merge-lanes.main.runtime.ts index f8e3a8896e30..54fd650df897 100644 --- a/scopes/lanes/merge-lanes/merge-lanes.main.runtime.ts +++ b/scopes/lanes/merge-lanes/merge-lanes.main.runtime.ts @@ -19,10 +19,11 @@ import ScopeComponentsImporter from '@teambit/legacy/dist/scope/component-ops/sc import { ComponentID } from '@teambit/component-id'; import { DEFAULT_LANE, LaneId } from '@teambit/lane-id'; import { Lane, Version } from '@teambit/legacy/dist/scope/models'; +import { getRefsFromExtensions } from '@teambit/legacy/dist/consumer/component/sources/artifact-files'; import { Logger, LoggerAspect, LoggerMain } from '@teambit/logger'; import { SnapsDistance } from '@teambit/legacy/dist/scope/component-ops/snaps-distance'; import { RemoveAspect, RemoveMain } from '@teambit/remove'; -import { compact } from 'lodash'; +import { compact, uniq } from 'lodash'; import { ExportAspect, ExportMain } from '@teambit/export'; import { BitObject } from '@teambit/legacy/dist/scope/objects'; import { getDivergeData } from '@teambit/legacy/dist/scope/component-ops/get-diverge-data'; @@ -107,7 +108,19 @@ export class MergeLanesMain { const shouldFetch = !lane || (!skipFetch && !lane.isNew); if (shouldFetch) { // don't assign `lane` to the result of this command. otherwise, if you have local snaps, it'll ignore them and use the remote-lane. - await this.lanes.fetchLaneWithItsComponents(otherLaneId); + const otherLane = await this.lanes.fetchLaneWithItsComponents(otherLaneId); + + // get all artifacts + const allIds = otherLane.toBitIds(); + const laneComps = await consumer.scope.getManyConsumerComponents(allIds); + const allRefs = laneComps.map((comp) => getRefsFromExtensions(comp.extensions)).flat(); + const allRefsUniq = uniq(allRefs.map((r) => r.toString())); + try { + await consumer.scope.scopeImporter.importManyObjects({ [otherLaneId.scope]: allRefsUniq }); + } catch (err) { + this.logger.error(`failed fetching artifacts for lane ${otherLaneId.toString()}`, err); + } + lane = await consumer.scope.loadLane(otherLaneId); } return lane; diff --git a/src/scope/component-ops/scope-components-importer.ts b/src/scope/component-ops/scope-components-importer.ts index 7d385e9d3a81..eaa952fac147 100644 --- a/src/scope/component-ops/scope-components-importer.ts +++ b/src/scope/component-ops/scope-components-importer.ts @@ -210,7 +210,7 @@ export default class ScopeComponentsImporter { /** * an efficient way to verify that all history exists locally. - * instead of all versions objects, load only the VersionHistory, get the graph from head, then only check whether + * instead of loading all versions objects, load only the VersionHistory, get the graph from head, then only check whether * the objects exist in the filesystem. */ private async importMissingHistoryOne(id: BitId) {