@teambit/merge-lanes 1.0.240 → 1.0.241
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/__bit_junit.xml +4 -2
- package/artifacts/schema.json +557 -376
- package/dist/merge-lane.spec.d.ts +1 -0
- package/dist/merge-lane.spec.js +111 -0
- package/dist/merge-lane.spec.js.map +1 -0
- package/dist/merge-lanes.main.runtime.d.ts +12 -5
- package/dist/merge-lanes.main.runtime.js +53 -70
- package/dist/merge-lanes.main.runtime.js.map +1 -1
- package/package.json +18 -13
- /package/dist/{preview-1713277147086.js → preview-1713323989441.js} +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,111 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
function _chai() {
|
4
|
+
const data = require("chai");
|
5
|
+
_chai = function () {
|
6
|
+
return data;
|
7
|
+
};
|
8
|
+
return data;
|
9
|
+
}
|
10
|
+
function _harmonyTesting() {
|
11
|
+
const data = require("@teambit/harmony.testing.load-aspect");
|
12
|
+
_harmonyTesting = function () {
|
13
|
+
return data;
|
14
|
+
};
|
15
|
+
return data;
|
16
|
+
}
|
17
|
+
function _workspaceTesting() {
|
18
|
+
const data = require("@teambit/workspace.testing.mock-workspace");
|
19
|
+
_workspaceTesting = function () {
|
20
|
+
return data;
|
21
|
+
};
|
22
|
+
return data;
|
23
|
+
}
|
24
|
+
function _scope() {
|
25
|
+
const data = require("@teambit/scope");
|
26
|
+
_scope = function () {
|
27
|
+
return data;
|
28
|
+
};
|
29
|
+
return data;
|
30
|
+
}
|
31
|
+
function _export() {
|
32
|
+
const data = require("@teambit/export");
|
33
|
+
_export = function () {
|
34
|
+
return data;
|
35
|
+
};
|
36
|
+
return data;
|
37
|
+
}
|
38
|
+
function _componentTesting() {
|
39
|
+
const data = require("@teambit/component.testing.mock-components");
|
40
|
+
_componentTesting = function () {
|
41
|
+
return data;
|
42
|
+
};
|
43
|
+
return data;
|
44
|
+
}
|
45
|
+
function _mergeLanes() {
|
46
|
+
const data = require("./merge-lanes.aspect");
|
47
|
+
_mergeLanes = function () {
|
48
|
+
return data;
|
49
|
+
};
|
50
|
+
return data;
|
51
|
+
}
|
52
|
+
function _lanes() {
|
53
|
+
const data = _interopRequireDefault(require("@teambit/lanes"));
|
54
|
+
_lanes = function () {
|
55
|
+
return data;
|
56
|
+
};
|
57
|
+
return data;
|
58
|
+
}
|
59
|
+
function _snapping() {
|
60
|
+
const data = _interopRequireDefault(require("@teambit/snapping"));
|
61
|
+
_snapping = function () {
|
62
|
+
return data;
|
63
|
+
};
|
64
|
+
return data;
|
65
|
+
}
|
66
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
67
|
+
describe('MergeLane aspect', function () {
|
68
|
+
this.timeout(0);
|
69
|
+
describe('snap from scope an existing component with newDependencies prop populated', () => {
|
70
|
+
let workspaceData;
|
71
|
+
let harmonyBareScope;
|
72
|
+
let results;
|
73
|
+
before(async () => {
|
74
|
+
workspaceData = (0, _workspaceTesting().mockWorkspace)();
|
75
|
+
const {
|
76
|
+
workspacePath
|
77
|
+
} = workspaceData;
|
78
|
+
await (0, _componentTesting().mockComponents)(workspacePath, {
|
79
|
+
numOfComponents: 2
|
80
|
+
});
|
81
|
+
const harmony = await (0, _harmonyTesting().loadManyAspects)([_snapping().default, _export().ExportAspect, _lanes().default], workspacePath);
|
82
|
+
const lane = harmony.get(_lanes().default.id);
|
83
|
+
await lane.createLane('dev');
|
84
|
+
const snapping = harmony.get(_snapping().default.id);
|
85
|
+
await snapping.snap({
|
86
|
+
build: false,
|
87
|
+
message: 'first snap'
|
88
|
+
});
|
89
|
+
const exportMain = harmony.get(_export().ExportAspect.id);
|
90
|
+
await exportMain.export();
|
91
|
+
const bareScope = (0, _workspaceTesting().mockBareScope)(workspaceData.remoteScopePath, '-bare');
|
92
|
+
harmonyBareScope = await (0, _harmonyTesting().loadManyAspects)([_mergeLanes().MergeLanesAspect, _scope().ScopeAspect], bareScope.scopePath);
|
93
|
+
const mergeLaneMain = harmonyBareScope.get(_mergeLanes().MergeLanesAspect.id);
|
94
|
+
const remoteScopeName = workspaceData.remoteScopeName;
|
95
|
+
results = await mergeLaneMain.mergeFromScope(`${remoteScopeName}/dev`, 'main', {
|
96
|
+
pattern: `${remoteScopeName}/comp2`
|
97
|
+
});
|
98
|
+
});
|
99
|
+
it('should merge successfully the specified pattern only', async () => {
|
100
|
+
(0, _chai().expect)(results.mergedNow).to.have.lengthOf(1);
|
101
|
+
(0, _chai().expect)(results.mergedNow[0].fullName).to.equal('comp2');
|
102
|
+
(0, _chai().expect)(results.unmerged).to.have.lengthOf(1);
|
103
|
+
(0, _chai().expect)(results.unmerged[0].id.name).to.equal('comp1');
|
104
|
+
});
|
105
|
+
after(async () => {
|
106
|
+
await (0, _workspaceTesting().destroyWorkspace)(workspaceData);
|
107
|
+
});
|
108
|
+
});
|
109
|
+
});
|
110
|
+
|
111
|
+
//# sourceMappingURL=merge-lane.spec.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_chai","data","require","_harmonyTesting","_workspaceTesting","_scope","_export","_componentTesting","_mergeLanes","_lanes","_interopRequireDefault","_snapping","obj","__esModule","default","describe","timeout","workspaceData","harmonyBareScope","results","before","mockWorkspace","workspacePath","mockComponents","numOfComponents","harmony","loadManyAspects","SnappingAspect","ExportAspect","LanesAspect","lane","get","id","createLane","snapping","snap","build","message","exportMain","export","bareScope","mockBareScope","remoteScopePath","MergeLanesAspect","ScopeAspect","scopePath","mergeLaneMain","remoteScopeName","mergeFromScope","pattern","it","expect","mergedNow","to","have","lengthOf","fullName","equal","unmerged","name","after","destroyWorkspace"],"sources":["merge-lane.spec.ts"],"sourcesContent":["import { expect } from 'chai';\nimport { Harmony } from '@teambit/harmony';\nimport { loadManyAspects } from '@teambit/harmony.testing.load-aspect';\nimport {\n mockWorkspace,\n mockBareScope,\n destroyWorkspace,\n WorkspaceData,\n} from '@teambit/workspace.testing.mock-workspace';\nimport { ScopeAspect } from '@teambit/scope';\nimport { ExportAspect, ExportMain } from '@teambit/export';\nimport { mockComponents } from '@teambit/component.testing.mock-components';\nimport { MergeLanesAspect } from './merge-lanes.aspect';\nimport { MergeFromScopeResult, MergeLanesMain } from './merge-lanes.main.runtime';\nimport LanesAspect, { LanesMain } from '@teambit/lanes';\nimport SnappingAspect, { SnappingMain } from '@teambit/snapping';\n\ndescribe('MergeLane aspect', function () {\n this.timeout(0);\n\n describe('snap from scope an existing component with newDependencies prop populated', () => {\n let workspaceData: WorkspaceData;\n let harmonyBareScope: Harmony;\n let results: MergeFromScopeResult;\n before(async () => {\n workspaceData = mockWorkspace();\n const { workspacePath } = workspaceData;\n await mockComponents(workspacePath, { numOfComponents: 2 });\n const harmony = await loadManyAspects([SnappingAspect, ExportAspect, LanesAspect], workspacePath);\n const lane = harmony.get<LanesMain>(LanesAspect.id);\n await lane.createLane('dev');\n const snapping = harmony.get<SnappingMain>(SnappingAspect.id);\n await snapping.snap({ build: false, message: 'first snap' });\n const exportMain = harmony.get<ExportMain>(ExportAspect.id);\n await exportMain.export();\n\n const bareScope = mockBareScope(workspaceData.remoteScopePath, '-bare');\n harmonyBareScope = await loadManyAspects([MergeLanesAspect, ScopeAspect], bareScope.scopePath);\n const mergeLaneMain = harmonyBareScope.get<MergeLanesMain>(MergeLanesAspect.id);\n const remoteScopeName = workspaceData.remoteScopeName;\n results = await mergeLaneMain.mergeFromScope(`${remoteScopeName}/dev`, 'main', {\n pattern: `${remoteScopeName}/comp2`,\n });\n });\n it('should merge successfully the specified pattern only', async () => {\n expect(results.mergedNow).to.have.lengthOf(1);\n expect(results.mergedNow[0].fullName).to.equal('comp2');\n expect(results.unmerged).to.have.lengthOf(1);\n expect(results.unmerged[0].id.name).to.equal('comp1');\n });\n after(async () => {\n await destroyWorkspace(workspaceData);\n });\n });\n});\n"],"mappings":";;AAAA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,OA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ACX,EAAE,CAAC;MAC/E,MAAMe,eAAe,GAAG9B,aAAa,CAAC8B,eAAe;MACrD5B,OAAO,GAAG,MAAM2B,aAAa,CAACE,cAAc,CAAE,GAAED,eAAgB,MAAK,EAAE,MAAM,EAAE;QAC7EE,OAAO,EAAG,GAAEF,eAAgB;MAC9B,CAAC,CAAC;IACJ,CAAC,CAAC;IACFG,EAAE,CAAC,sDAAsD,EAAE,YAAY;MACrE,IAAAC,cAAM,EAAChC,OAAO,CAACiC,SAAS,CAAC,CAACC,EAAE,CAACC,IAAI,CAACC,QAAQ,CAAC,CAAC,CAAC;MAC7C,IAAAJ,cAAM,EAAChC,OAAO,CAACiC,SAAS,CAAC,CAAC,CAAC,CAACI,QAAQ,CAAC,CAACH,EAAE,CAACI,KAAK,CAAC,OAAO,CAAC;MACvD,IAAAN,cAAM,EAAChC,OAAO,CAACuC,QAAQ,CAAC,CAACL,EAAE,CAACC,IAAI,CAACC,QAAQ,CAAC,CAAC,CAAC;MAC5C,IAAAJ,cAAM,EAAChC,OAAO,CAACuC,QAAQ,CAAC,CAAC,CAAC,CAAC1B,EAAE,CAAC2B,IAAI,CAAC,CAACN,EAAE,CAACI,KAAK,CAAC,OAAO,CAAC;IACvD,CAAC,CAAC;IACFG,KAAK,CAAC,YAAY;MAChB,MAAM,IAAAC,oCAAgB,EAAC5C,aAAa,CAAC;IACvC,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
@@ -34,6 +34,13 @@ export type MergeLaneOptions = {
|
|
34
34
|
skipFetch?: boolean;
|
35
35
|
excludeNonLaneComps?: boolean;
|
36
36
|
shouldIncludeUpdateDependents?: boolean;
|
37
|
+
throwIfNotUpToDate?: boolean;
|
38
|
+
fetchCurrent?: boolean;
|
39
|
+
};
|
40
|
+
export type ConflictPerId = {
|
41
|
+
id: ComponentID;
|
42
|
+
files: string[];
|
43
|
+
config?: boolean;
|
37
44
|
};
|
38
45
|
export type MergeFromScopeResult = {
|
39
46
|
mergedNow: ComponentID[];
|
@@ -42,11 +49,7 @@ export type MergeFromScopeResult = {
|
|
42
49
|
id: ComponentID;
|
43
50
|
reason: string;
|
44
51
|
}[];
|
45
|
-
conflicts?:
|
46
|
-
id: ComponentID;
|
47
|
-
files: string[];
|
48
|
-
config?: boolean;
|
49
|
-
}>;
|
52
|
+
conflicts?: ConflictPerId[];
|
50
53
|
snappedIds?: ComponentID[];
|
51
54
|
mergedPreviously: ComponentID[];
|
52
55
|
mergeSnapError?: Error;
|
@@ -66,11 +69,15 @@ export declare class MergeLanesMain {
|
|
66
69
|
mergeResults: ApplyVersionResults;
|
67
70
|
deleteResults: any;
|
68
71
|
configMergeResults: ConfigMergeResult[];
|
72
|
+
mergedSuccessfullyIds: ComponentID[];
|
73
|
+
conflicts: ConflictPerId[];
|
69
74
|
}>;
|
70
75
|
mergeLane(otherLaneId: LaneId, currentLaneId: LaneId, options: MergeLaneOptions): Promise<{
|
71
76
|
mergeResults: ApplyVersionResults;
|
72
77
|
deleteResults: any;
|
73
78
|
configMergeResults: ConfigMergeResult[];
|
79
|
+
mergedSuccessfullyIds: ComponentID[];
|
80
|
+
conflicts: ConflictPerId[];
|
74
81
|
}>;
|
75
82
|
abortLaneMerge(checkoutProps: CheckoutProps, mergeAbortOpts: MergeAbortOpts): Promise<{
|
76
83
|
checkoutResults: ApplyVersionResults | undefined;
|
@@ -226,7 +226,9 @@ class MergeLanesMain {
|
|
226
226
|
ignoreConfigChanges,
|
227
227
|
skipFetch,
|
228
228
|
excludeNonLaneComps,
|
229
|
-
shouldIncludeUpdateDependents
|
229
|
+
shouldIncludeUpdateDependents,
|
230
|
+
throwIfNotUpToDate,
|
231
|
+
fetchCurrent
|
230
232
|
} = options;
|
231
233
|
const legacyScope = this.scope.legacyScope;
|
232
234
|
if (tag && !currentLaneId.isDefault()) {
|
@@ -238,6 +240,10 @@ class MergeLanesMain {
|
|
238
240
|
if (resolveUnrelated && currentLaneId.isDefault()) {
|
239
241
|
throw new (_bitError().BitError)(`unable to resolve unrelated when on main. switch to ${otherLaneId.toString()} and run "bit lane merge main --resolve-unrelated"`);
|
240
242
|
}
|
243
|
+
if (fetchCurrent && !currentLaneId.isDefault()) {
|
244
|
+
// if current is default, it'll be fetch later on
|
245
|
+
await this.lanes.fetchLaneWithItsComponents(currentLaneId);
|
246
|
+
}
|
241
247
|
const currentLane = currentLaneId.isDefault() ? null : await legacyScope.loadLane(currentLaneId);
|
242
248
|
const isDefaultLane = otherLaneId.isDefault();
|
243
249
|
if (isDefaultLane) {
|
@@ -253,16 +259,21 @@ class MergeLanesMain {
|
|
253
259
|
const shouldFetch = !lane || !skipFetch && !lane.isNew;
|
254
260
|
if (shouldFetch) {
|
255
261
|
// 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.
|
256
|
-
const otherLane = await this.lanes.fetchLaneWithItsComponents(otherLaneId);
|
262
|
+
const otherLane = await this.lanes.fetchLaneWithItsComponents(otherLaneId, shouldIncludeUpdateDependents);
|
257
263
|
laneToFetchArtifactsFrom = otherLane;
|
258
264
|
lane = await legacyScope.loadLane(otherLaneId);
|
259
265
|
}
|
260
266
|
return lane;
|
261
267
|
};
|
262
268
|
const otherLane = isDefaultLane ? undefined : await getOtherLane();
|
269
|
+
if (fetchCurrent && otherLane && currentLaneId.isDefault()) {
|
270
|
+
const ids = await this.getMainIdsToMerge(otherLane, false, shouldIncludeUpdateDependents);
|
271
|
+
const compIdList = _componentId().ComponentIdList.fromArray(ids).toVersionLatest();
|
272
|
+
await this.importer.importObjectsFromMainIfExist(compIdList);
|
273
|
+
}
|
263
274
|
const getBitIds = async () => {
|
264
275
|
if (isDefaultLane) {
|
265
|
-
const ids = await this.getMainIdsToMerge(currentLane, !excludeNonLaneComps);
|
276
|
+
const ids = await this.getMainIdsToMerge(currentLane, !excludeNonLaneComps, shouldIncludeUpdateDependents);
|
266
277
|
const modelComponents = await Promise.all(ids.map(id => this.scope.legacyScope.getModelComponent(id)));
|
267
278
|
return (0, _lodash().compact)(modelComponents.map(c => {
|
268
279
|
if (!c.head) return null; // probably the component was never merged to main
|
@@ -273,6 +284,7 @@ class MergeLanesMain {
|
|
273
284
|
return shouldIncludeUpdateDependents ? otherLane.toComponentIdsIncludeUpdateDependents() : otherLane.toComponentIds();
|
274
285
|
};
|
275
286
|
const idsToMerge = await getBitIds();
|
287
|
+
if (throwIfNotUpToDate) await this.throwIfNotUpToDate(otherLaneId, currentLaneId);
|
276
288
|
this.logger.debug(`merging the following ids: ${idsToMerge.toString()}`);
|
277
289
|
const shouldSquash = squash || currentLaneId.isDefault() && !noSquash;
|
278
290
|
let allComponentsStatus = await this.merging.getMergeStatus(idsToMerge, {
|
@@ -310,8 +322,9 @@ class MergeLanesMain {
|
|
310
322
|
});
|
311
323
|
}
|
312
324
|
(0, _checkout().throwForFailures)(allComponentsStatus);
|
325
|
+
const succeededComponents = allComponentsStatus.filter(c => !c.unchangedMessage);
|
313
326
|
if (shouldSquash) {
|
314
|
-
await squashSnaps(
|
327
|
+
await squashSnaps(succeededComponents, currentLaneId, otherLaneId, legacyScope, options.snapMessage);
|
315
328
|
}
|
316
329
|
if (laneToFetchArtifactsFrom) {
|
317
330
|
const ids = allComponentsStatus.map(c => c.id);
|
@@ -343,12 +356,28 @@ class MergeLanesMain {
|
|
343
356
|
readmeResult: ''
|
344
357
|
};
|
345
358
|
}
|
346
|
-
const configMergeResults = allComponentsStatus.map(c => c.configMergeResult);
|
359
|
+
const configMergeResults = (0, _lodash().compact)(allComponentsStatus.map(c => c.configMergeResult));
|
360
|
+
const componentsWithConfigConflicts = configMergeResults.filter(c => c.hasConflicts()).map(c => c.compIdStr);
|
361
|
+
const conflicts = [];
|
362
|
+
const mergedSuccessfullyIds = [];
|
363
|
+
mergeResults.components?.forEach(c => {
|
364
|
+
const files = Object.keys(c.filesStatus).filter(f => c.filesStatus[f] === _mergeVersion().FileStatus.manual || c.filesStatus[f] === _mergeVersion().FileStatus.binaryConflict);
|
365
|
+
const config = componentsWithConfigConflicts.includes(c.id.toStringWithoutVersion());
|
366
|
+
if (files.length || config) {
|
367
|
+
conflicts.push({
|
368
|
+
id: c.id,
|
369
|
+
files,
|
370
|
+
config
|
371
|
+
});
|
372
|
+
} else mergedSuccessfullyIds.push(c.id);
|
373
|
+
});
|
347
374
|
await this.workspace?.consumer.onDestroy(`lane-merge (${otherLaneId.name})`);
|
348
375
|
return {
|
349
376
|
mergeResults,
|
350
377
|
deleteResults,
|
351
|
-
configMergeResults
|
378
|
+
configMergeResults,
|
379
|
+
mergedSuccessfullyIds,
|
380
|
+
conflicts
|
352
381
|
};
|
353
382
|
}
|
354
383
|
async abortLaneMerge(checkoutProps, mergeAbortOpts) {
|
@@ -386,9 +415,9 @@ class MergeLanesMain {
|
|
386
415
|
checkoutError
|
387
416
|
};
|
388
417
|
}
|
389
|
-
async getMainIdsToMerge(lane, includeNonLaneComps = true) {
|
418
|
+
async getMainIdsToMerge(lane, includeNonLaneComps = true, includeUpdateDependents = false) {
|
390
419
|
if (!lane) throw new Error(`unable to merge ${_laneId().DEFAULT_LANE}, the current lane was not found`);
|
391
|
-
const laneIds = lane.
|
420
|
+
const laneIds = includeUpdateDependents ? lane.toComponentIdsIncludeUpdateDependents() : lane.toComponentIds();
|
392
421
|
const ids = laneIds.filter(id => this.scope.isExported(id));
|
393
422
|
if (includeNonLaneComps) {
|
394
423
|
if (!this.workspace) {
|
@@ -405,42 +434,11 @@ class MergeLanesMain {
|
|
405
434
|
throw new (_bitError().BitError)(`unable to run this command from a workspace, please create a new bare-scope and run it from there`);
|
406
435
|
}
|
407
436
|
const fromLaneId = await this.lanes.parseLaneId(fromLane);
|
408
|
-
const fromLaneObj = fromLaneId.isDefault() ? undefined : await this.lanes.importLaneObject(fromLaneId);
|
409
437
|
const toLaneId = toLane === _laneId().DEFAULT_LANE ? this.lanes.getDefaultLaneId() : _laneId().LaneId.parse(toLane);
|
410
|
-
const toLaneObj = toLaneId.isDefault() ? undefined : await this.lanes.importLaneObject(toLaneId);
|
411
438
|
const shouldIncludeUpdateDependents = toLaneId.isDefault();
|
412
|
-
const fromLaneBitIds = shouldIncludeUpdateDependents ? fromLaneObj?.toComponentIdsIncludeUpdateDependents() : fromLaneObj?.toComponentIds();
|
413
|
-
const toLaneCompIds = toLaneObj?.toComponentIds();
|
414
|
-
const laneIds = fromLaneBitIds || toLaneCompIds; // one of them must be defined.
|
415
|
-
const getIdsToMerge = async () => {
|
416
|
-
if (!options.pattern) return laneIds;
|
417
|
-
const ids = await this.scope.filterIdsFromPoolIdsByPattern(options.pattern, laneIds);
|
418
|
-
return _componentId().ComponentIdList.fromArray(ids);
|
419
|
-
};
|
420
|
-
const idsToMerge = await getIdsToMerge();
|
421
|
-
const scopeComponentsImporter = this.scope.legacyScope.scopeImporter;
|
422
|
-
await scopeComponentsImporter.importWithoutDeps(idsToMerge.toVersionLatest(), {
|
423
|
-
cache: false,
|
424
|
-
lane: fromLaneObj,
|
425
|
-
ignoreMissingHead: true,
|
426
|
-
includeVersionHistory: true,
|
427
|
-
includeUpdateDependents: shouldIncludeUpdateDependents,
|
428
|
-
reason: `of "from" lane (${fromLaneId.name}) for lane-merge to get all version-history`
|
429
|
-
});
|
430
|
-
|
431
|
-
// get their main/to-lane as well
|
432
|
-
await scopeComponentsImporter.importWithoutDeps(idsToMerge.toVersionLatest(), {
|
433
|
-
cache: false,
|
434
|
-
lane: toLaneObj,
|
435
|
-
ignoreMissingHead: true,
|
436
|
-
includeVersionHistory: true,
|
437
|
-
reason: `of "to" lane (${toLaneId.name}) for lane-merge to get all version-history`
|
438
|
-
});
|
439
|
-
await this.importer.importHeadArtifactsFromLane(fromLaneObj || toLaneObj, undefined, true);
|
440
|
-
const shouldSquash = !toLaneObj && !options.noSquash; // only when merging to main we squash.
|
441
|
-
|
442
439
|
const exportIfNeeded = async (idsToExport, laneToExport) => {
|
443
440
|
if (!options.push) return [];
|
441
|
+
const shouldSquash = toLaneId.isDefault() && !options.noSquash; // only when merging to main we squash.
|
444
442
|
const compIdsList = _componentId().ComponentIdList.fromArray(idsToExport);
|
445
443
|
const {
|
446
444
|
exported
|
@@ -464,9 +462,6 @@ class MergeLanesMain {
|
|
464
462
|
});
|
465
463
|
return exported;
|
466
464
|
};
|
467
|
-
if (!fromLaneId.isDefault()) {
|
468
|
-
await this.throwIfNotUpToDate(fromLaneId, toLaneId);
|
469
|
-
}
|
470
465
|
|
471
466
|
// current -> target (to)
|
472
467
|
// other -> source (from)
|
@@ -474,39 +469,28 @@ class MergeLanesMain {
|
|
474
469
|
options.excludeNonLaneComps = true;
|
475
470
|
options.skipDependencyInstallation = true;
|
476
471
|
options.shouldIncludeUpdateDependents = shouldIncludeUpdateDependents;
|
472
|
+
options.throwIfNotUpToDate = !fromLaneId.isDefault();
|
473
|
+
options.fetchCurrent = true;
|
477
474
|
this.scope.legacyScope.setCurrentLaneId(toLaneId);
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
475
|
+
const {
|
476
|
+
mergeResults,
|
477
|
+
configMergeResults,
|
478
|
+
conflicts,
|
479
|
+
mergedSuccessfullyIds
|
480
|
+
} = await this.mergeLane(fromLaneId, toLaneId, options);
|
483
481
|
const {
|
484
482
|
mergeSnapResults,
|
485
|
-
leftUnresolvedConflicts,
|
486
483
|
failedComponents,
|
487
|
-
components,
|
488
484
|
mergeSnapError
|
489
|
-
} =
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
const merged = [];
|
494
|
-
components?.forEach(c => {
|
495
|
-
const files = Object.keys(c.filesStatus).filter(f => c.filesStatus[f] === _mergeVersion().FileStatus.manual || c.filesStatus[f] === _mergeVersion().FileStatus.binaryConflict);
|
496
|
-
const config = componentsWithConfigConflicts.includes(c.id.toStringWithoutVersion());
|
497
|
-
if (files.length || config) {
|
498
|
-
conflicts.push({
|
499
|
-
id: c.id,
|
500
|
-
files,
|
501
|
-
config
|
502
|
-
});
|
503
|
-
} else merged.push(c.id);
|
504
|
-
});
|
485
|
+
} = mergeResults;
|
486
|
+
if (configMergeResults.length) {
|
487
|
+
this.logger.debug(`found the following config conflicts: ${configMergeResults.map(c => `\n${c.compIdStr}\n${c.generateMergeConflictFile()}`).join('\n')}`);
|
488
|
+
}
|
505
489
|
const snappedIds = mergeSnapResults?.snappedComponents.map(c => c.id) || [];
|
506
490
|
const laneToExport = toLaneId.isDefault() ? undefined : await this.lanes.loadLane(toLaneId); // needs to be loaded again after the merge as it changed
|
507
|
-
const exportedIds =
|
491
|
+
const exportedIds = conflicts.length || mergeSnapError ? [] : await exportIfNeeded(mergedSuccessfullyIds.map(id => id.changeVersion(undefined)), laneToExport || undefined);
|
508
492
|
return {
|
509
|
-
mergedNow:
|
493
|
+
mergedNow: mergedSuccessfullyIds,
|
510
494
|
mergedPreviously: failedComponents?.filter(({
|
511
495
|
unchangedMessage
|
512
496
|
}) => unchangedMessage === _merging().compIsAlreadyMergedMsg).map(c => c.id) || [],
|
@@ -661,9 +645,8 @@ async function getLogForSquash(otherLaneId) {
|
|
661
645
|
});
|
662
646
|
return log;
|
663
647
|
}
|
664
|
-
async function squashSnaps(
|
648
|
+
async function squashSnaps(succeededComponents, currentLaneId, otherLaneId, scope, messageTitle) {
|
665
649
|
const currentLaneName = currentLaneId.name;
|
666
|
-
const succeededComponents = allComponentsStatus.filter(c => !c.unchangedMessage);
|
667
650
|
const log = await getLogForSquash(otherLaneId);
|
668
651
|
await Promise.all(succeededComponents.map(async ({
|
669
652
|
id,
|