Skip to content

Commit

Permalink
fix(bit-tag-snap): avoid saving duplicate aspects to the model (#6567)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfirst authored Oct 19, 2022
1 parent 85cee56 commit ec12b51
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,9 @@ export class WorkspaceComponentLoader {
}

private async upsertExtensionData(component: Component, extension: string, data: any) {
if (!data) return;
const existingExtension = component.state.config.extensions.findExtension(extension);
if (existingExtension && data) {
if (existingExtension) {
// Only merge top level of extension data
Object.assign(existingExtension.data, data);
return;
Expand Down
9 changes: 7 additions & 2 deletions src/scope/version-validator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { PJV } from 'package-json-validator';
import R from 'ramda';
import { lt } from 'semver';
import packageNameValidate from 'validate-npm-package-name';

import { BitId, BitIds } from '../bit-id';
Expand Down Expand Up @@ -100,7 +101,6 @@ export default function validateVersionInstance(version: Version): void {
});
};

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const validateNoDuplicateExtensionEntry = (extensions: ExtensionDataList) => {
const existingMap = new Map();
const duplications: string[] = [];
Expand All @@ -116,13 +116,18 @@ export default function validateVersionInstance(version: Version): void {
}
});
if (duplications.length) {
// a bug causing duplicate aspects was fixed in https://github.com/teambit/bit/pull/6567
// all Version objects snapped before 0.0.882 might have this bug. ignore them.
if (!version.bitVersion || lt(version.bitVersion, '0.0.882')) {
return;
}
throw new VersionInvalid(`${message} the following extensions entries are duplicated ${duplications.join(', ')}`);
}
};

const _validateExtensions = (extensions: ExtensionDataList) => {
if (extensions) {
// validateNoDuplicateExtensionEntry(extensions);
validateNoDuplicateExtensionEntry(extensions);
extensions.map(_validateExtension);
validateArtifacts(extensions);
}
Expand Down

0 comments on commit ec12b51

Please sign in to comment.