Skip to content

Commit 75ae718

Browse files
authored
fix(component-graph): support hashes when calculating version map (teambit#5558)
Co-authored-by: Luv Kapur <[email protected]>
1 parent 7b62986 commit 75ae718

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

scopes/component/graph/component-graph/component-graph.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,17 @@ export class ComponentGraph extends Graph<Component, Dependency> {
120120
if (Object.prototype.hasOwnProperty.call(value, 'allVersionNodes')) {
121121
value.allVersionNodes.push(compKey);
122122
}
123-
const currentCompVersion = this.node(compKey)?.attr.id._legacy.getVersion();
124-
const latestCompVersion = this.node(value.latestVersionNode)?.attr.id._legacy.getVersion();
125-
if (!!currentCompVersion && !!latestCompVersion && currentCompVersion.isLaterThan(latestCompVersion)) {
123+
const currentComp = this.node(compKey)?.attr;
124+
const latestComp = this.node(value.latestVersionNode)?.attr;
125+
const isLegacy = !currentComp?.head || !latestComp?.head;
126+
127+
if (isLegacy) {
128+
const currentCompVersion = currentComp?.id._legacy.getVersion();
129+
const latestCompVersion = latestComp?.id._legacy.getVersion();
130+
if (!!currentCompVersion && !!latestCompVersion && currentCompVersion.isLaterThan(latestCompVersion)) {
131+
value.latestVersionNode = compKey;
132+
}
133+
} else if (new Date(currentComp.head.timestamp) > new Date(latestComp.head.timestamp)) {
126134
value.latestVersionNode = compKey;
127135
}
128136
}

0 commit comments

Comments
 (0)