Skip to content
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

fix(merge): import snaps that exist on remote-lane during lane-merge #7178

Merged
merged 3 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions e2e/harmony/lanes/merge-lanes.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -959,4 +959,41 @@ describe('merge lanes', function () {
expect(() => helper.command.status()).to.not.throw();
});
});
describe('merging from a lane to main when it has a long history which does not exist locally', () => {
let beforeMerge: string;
before(() => {
helper.scopeHelper.setNewLocalAndRemoteScopes();
helper.fixtures.populateComponents();
helper.command.tagAllWithoutBuild();
helper.command.export();
helper.command.createLane();
helper.command.snapAllComponentsWithoutBuild('--unmodified');
helper.command.snapAllComponentsWithoutBuild('--unmodified');
helper.command.snapAllComponentsWithoutBuild('--unmodified');
helper.command.export();

helper.scopeHelper.reInitLocalScope();
helper.scopeHelper.addRemoteScope();
helper.command.importComponent('comp3');
beforeMerge = helper.scopeHelper.cloneLocalScope();
});
describe('merging one component', () => {
// previously it was throwing VersionNotFound
it('should not throw', () => {
expect(() =>
helper.command.mergeLane(`${helper.scopes.remote}/dev`, `${helper.scopes.remote}/comp3 --no-squash -x`)
).to.not.throw();
});
});
describe('merging the entire lane', () => {
before(() => {
helper.scopeHelper.getClonedLocalScope(beforeMerge);
helper.command.mergeLane(`${helper.scopes.remote}/dev`, `--no-squash -x`);
});
// previously it was throwing VersionNotFound
it('bit export should not throw', () => {
expect(() => helper.command.export()).to.not.throw();
});
});
});
});
8 changes: 6 additions & 2 deletions scopes/component/merging/merging.main.runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,12 @@ export class MergingMain {
);
const toImport = componentStatusBeforeMergeAttempt
.map((compStatus) => {
if (!compStatus.divergeData || !compStatus.divergeData.commonSnapBeforeDiverge) return [];
return [compStatus.id.changeVersion(compStatus.divergeData.commonSnapBeforeDiverge.toString())];
if (!compStatus.divergeData) return [];
const versionsToImport = compact([
...compStatus.divergeData.snapsOnTargetOnly,
compStatus.divergeData.commonSnapBeforeDiverge,
]);
return versionsToImport.map((v) => compStatus.id.changeVersion(v.toString()));
})
.flat();

Expand Down