@teambit/objects 0.0.0-5be319555d98d49c2099758655937e7c2e6411f9 → 0.0.0-5c0883ce645072cbf1658815bbb0aa5cd9cc9bda

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.
@@ -80,7 +80,7 @@ export default class Lane extends BitObject {
80
80
  profileImage?: string;
81
81
  }): Lane;
82
82
  static parse(contents: string, hash: string): Lane;
83
- toBuffer(pretty?: boolean): Buffer;
83
+ toBuffer(pretty?: boolean): Buffer<ArrayBuffer>;
84
84
  addComponent(component: LaneComponent): void;
85
85
  removeComponentFromUpdateDependentsIfExist(componentId: ComponentID): void;
86
86
  addComponentToUpdateDependents(componentId: ComponentID): void;
@@ -268,7 +268,7 @@ export default class Component extends BitObject {
268
268
  private addDepsInfoFromDepsResolver;
269
269
  refs(): Ref[];
270
270
  validateBeforePersisting(componentStr: string): void;
271
- toBuffer(pretty: boolean): Buffer;
271
+ toBuffer(pretty: boolean): Buffer<ArrayBuffer>;
272
272
  /**
273
273
  * Clear data that is relevant only for the local scope and should not be moved to the remote scope
274
274
  */
@@ -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
  }