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, fix error "exists in flattenedEdges but not in flattened" #7107

Merged
merged 4 commits into from
Mar 1, 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
20 changes: 20 additions & 0 deletions e2e/harmony/lanes/merge-lanes.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -939,4 +939,24 @@ describe('merge lanes', function () {
expect(list).to.have.lengthOf(1);
});
});
describe('merge from main when a component head is a tag on main and was not changed on lane', () => {
before(() => {
helper.scopeHelper.setNewLocalAndRemoteScopes();
helper.command.createLane();
helper.fixtures.populateComponents(3);
helper.command.snapAllComponentsWithoutBuild();
helper.command.export();
helper.command.switchLocalLane('main', '-x');
helper.command.mergeLane('dev', '-x');
helper.command.tagAllWithoutBuild();
helper.command.export();
helper.command.switchLocalLane('dev', '-x');
helper.command.mergeLane('main', '-x');
});
// previously, it was throwing an error
// id o5kaxkjd-remote/comp1@0.0.1 exists in flattenedEdges but not in flattened of o5kaxkjd-remote/comp1@6f820556b472253cd08331b20e704fe74217fd31
it('bit status should not throw', () => {
expect(() => helper.command.status()).to.not.throw();
});
});
});
13 changes: 12 additions & 1 deletion scopes/workspace/workspace/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import { Lane, Version } from '@teambit/legacy/dist/scope/models';
import { LaneNotFound } from '@teambit/legacy/dist/api/scope/lib/exceptions/lane-not-found';
import { ScopeNotFoundOrDenied } from '@teambit/legacy/dist/remotes/exceptions/scope-not-found-or-denied';
import { linkToNodeModulesByIds } from '@teambit/workspace.modules.node-modules-linker';
import { isHash } from '@teambit/component-version';
import { ComponentLoadOptions } from '@teambit/legacy/dist/consumer/component/component-loader';
import { ComponentConfigFile } from './component-config-file';
import {
Expand Down Expand Up @@ -451,7 +452,17 @@ export class Workspace implements ComponentFactory {
return null;
}
const flattenedBitIdCompIdMap: { [bitIdStr: string]: ComponentID } = {};
flattenedBitIdCompIdMap[component.id._legacy.toString()] = component.id;
const getCurrentVersionAsTagIfPossible = (): string | undefined => {
const currentVer = component.id.version;
if (!currentVer) return undefined;
const isCurrentVerAHash = isHash(currentVer);
if (!isCurrentVerAHash) return currentVer;
const tag = component.tags.byHash(currentVer)?.version.raw;
return tag || currentVer;
};
const currentVersion = getCurrentVersionAsTagIfPossible();

flattenedBitIdCompIdMap[component.id._legacy.changeVersion(currentVersion).toString()] = component.id;
await Promise.all(
versionObj.flattenedDependencies.map(async (bitId) => {
flattenedBitIdCompIdMap[bitId.toString()] = await this.resolveComponentId(bitId);
Expand Down