Skip to content

Commit

Permalink
fix(export): do not try to export snaps existing on main (#7036)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfirst authored Feb 14, 2023
1 parent 4bc18ee commit a13fdfb
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
39 changes: 39 additions & 0 deletions e2e/harmony/lanes/lanes.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,45 @@ describe('bit lane command', function () {
expect(getFirstTagFromRemote).to.not.throw();
});
});
describe('multiple scopes - lane-scope does not have main tags', () => {
let anotherRemote: string;
before(() => {
helper.scopeHelper.setNewLocalAndRemoteScopes();
const { scopeName, scopePath } = helper.scopeHelper.getNewBareScope();
anotherRemote = scopeName;
helper.scopeHelper.addRemoteScope(scopePath);
helper.scopeHelper.addRemoteScope(scopePath, helper.scopes.remotePath);
helper.scopeHelper.addRemoteScope(helper.scopes.remotePath, scopePath);
helper.fixtures.populateComponents(1, false);
helper.command.setScope(scopeName, 'comp1');
helper.command.tagAllWithoutBuild();
// snap multiple times on main. these snaps will be missing locally during the snap-from-scope
helper.command.tagAllWithoutBuild('--unmodified');
helper.command.tagAllWithoutBuild('--unmodified');
helper.command.export();

helper.scopeHelper.reInitLocalScope();
helper.scopeHelper.addRemoteScope();
helper.scopeHelper.addRemoteScope(scopePath);
helper.command.createLane();
helper.fixtures.createComponentBarFoo();
helper.fixtures.addComponentBarFooAsDir();
helper.command.snapAllComponentsWithoutBuild();
helper.command.export();

helper.command.import(`${anotherRemote}/comp1`);
helper.command.snapAllComponentsWithoutBuild('--unmodified');
});
it('bit status should show only the last snap of the imported component as staged', () => {
const status = helper.command.statusJson();
status.stagedComponents.forEach((comp) => {
expect(comp.versions).to.have.lengthOf(1);
});
});
it('bit export should not throw an error', () => {
expect(() => helper.command.export()).to.not.throw();
});
});
describe('snapping and un-tagging on a lane', () => {
let afterFirstSnap: string;
before(() => {
Expand Down
4 changes: 3 additions & 1 deletion src/scope/models/model-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,9 @@ export default class Component extends BitObject {
return LaneId.from(DEFAULT_LANE, this.scope as string);
};
const remoteToCheck = getRemoteToCheck();
this.laneHeadRemote = await repo.remoteLanes.getRef(remoteToCheck, this.toBitId());
// if no remote-ref was found, because it's checked out to a lane, it's safe to assume that
// this.head should be on the original-remote. hence, FetchMissingHistory will retrieve it on lane-remote
this.laneHeadRemote = (await repo.remoteLanes.getRef(remoteToCheck, this.toBitId())) || this.head;
}
// we need also the remote head of main, otherwise, the diverge-data assumes all versions are local
this.remoteHead = await repo.remoteLanes.getRef(LaneId.from(DEFAULT_LANE, this.scope), this.toBitId());
Expand Down

0 comments on commit a13fdfb

Please sign in to comment.