@teambit/objects 0.0.0-f70eb3b53cf2be945104bfeaf684354316483c7b → 0.0.0-f7b8b14fb84a78baac6620ecbc7826e37516dad0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -56,10 +56,10 @@ export default class Lane extends BitObject {
56
56
  changeScope(scope: string): void;
57
57
  refs(): Ref[];
58
58
  validateBeforePersisting(str: string): void;
59
- toObject(): import("lodash").Dictionary<string | boolean | string[] | Log | {
59
+ toObject(): import("lodash").Dictionary<string | boolean | string[] | {
60
60
  scope: string;
61
61
  name: string;
62
- } | {
62
+ } | Log | {
63
63
  isDeleted?: true | undefined;
64
64
  id: {
65
65
  scope: string;
@@ -770,8 +770,8 @@ class Component extends _objects().BitObject {
770
770
  if (parent && head && !parent.isEqual(head) && !overrideHead) {
771
771
  if (detachHead) this.detachedHeads.setHead(version.hash());else throw new Error(`unable to add a new version for "${this.id()}" on main.
772
772
  this version started from an older version (${previouslyUsedVersion}), and not from the head (${head}).
773
- if this is done intentionally, please re-run with --detach-head (or --override-head if available).
774
- otherwise, please run "bit checkout head" to be up to date, then snap/tag your changes.`);
773
+ please run "bit checkout head" to be up to date, then snap/tag your changes.
774
+ if this is done intentionally, you can use --detach-head (or --override-head if available), but make sure you understand the implications as this is an experimental feature that may not be fully stable.`);
775
775
  } else {
776
776
  this.setHead(version.hash());
777
777
  this.detachedHeads.clearCurrent();
@@ -1199,6 +1199,26 @@ consider using --ignore-missing-artifacts flag if you're sure the artifacts are
1199
1199
  await this.setDivergeData(repo, undefined, undefined, workspaceId);
1200
1200
  const divergeData = this.getDivergeData();
1201
1201
  const localHashes = divergeData.snapsOnSourceOnly;
1202
+
1203
+ // When there's a detached head, divergeData only includes the detached head lineage.
1204
+ // We also need to include unexported versions from the main head lineage.
1205
+ const hasDetachedHead = this.detachedHeads && this.detachedHeads.getAllHeads().length > 0;
1206
+ if (hasDetachedHead && this.head) {
1207
+ // Calculate divergence from the main head as well
1208
+ const mainHeadDivergeData = await (0, _component2().getDivergeData)({
1209
+ repo,
1210
+ modelComponent: this,
1211
+ targetHead: (this.laneId ? this.calculatedRemoteHeadWhenOnLane : this.remoteHead) || null,
1212
+ sourceHead: this.head,
1213
+ throws: false
1214
+ });
1215
+ // Add main head local versions that aren't already in localHashes
1216
+ for (const hash of mainHeadDivergeData.snapsOnSourceOnly) {
1217
+ if (!localHashes.find(h => h.isEqual(hash))) {
1218
+ localHashes.push(hash);
1219
+ }
1220
+ }
1221
+ }
1202
1222
  if (!localHashes.length) return [];
1203
1223
  return localHashes.reverse(); // reverse to get the older first
1204
1224
  }