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(export): do not try to export snaps existing on main #7036

Merged
merged 3 commits into from
Feb 14, 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
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