@teambit/ci 1.0.495 → 1.0.497

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.
package/ci.docs.mdx CHANGED
@@ -297,14 +297,15 @@ that commit. A narrow refspec is acceptable, and a cold local scope is acceptabl
297
297
  For each mapped lane, the command compares the remote head of the lane with the state that the committed
298
298
  `.bitmap` of the branch records. The command then picks one action:
299
299
 
300
- | Situation | Action | Effect |
301
- | -------------------------------------------------------------------- | ---------------- | -------------------------------------------------------------------------------------------------------------- |
302
- | the lane moved, the branch did not | `import-lane` | The command puts the lane on the branch, pushes, and opens the pull request if it is absent. |
303
- | the branch got dev commits, the lane did not move | `export-branch` | The command snaps and exports the tree of the branch onto the lane. |
304
- | both moved | `merge-diverged` | The command merges the lane into the tree of the branch, then snaps and exports. |
305
- | bit.cloud removed the lane, and the branch is ours | `close-pr` | The command closes the pull request. The command deletes the branch, unless the branch holds unmerged commits. |
306
- | no lane, and the branch is not ours | `noop` | Nothing. Read [when the command deletes a branch](#when-the-command-deletes-a-branch). |
307
- | nothing moved, or the pull request has the `bit-sync-conflict` label | `noop` | Nothing. |
300
+ | Situation | Action | Effect |
301
+ | ----------------------------------------------------------------------------------------- | ---------------- | -------------------------------------------------------------------------------------------------------------- |
302
+ | the lane moved, the branch did not | `import-lane` | The command puts the lane on the branch, pushes, and opens the pull request if it is absent. |
303
+ | the branch got dev commits, the lane did not move | `export-branch` | The command snaps and exports the tree of the branch onto the lane. |
304
+ | both moved | `merge-diverged` | The command merges the lane into the tree of the branch, then snaps and exports. |
305
+ | the lane exists, the branch has dev commits, but the branch never recorded a lane pointer | `adopt-branch` | First contact. Read [Adopting a branch on first contact](#adopting-a-branch-on-first-contact). |
306
+ | bit.cloud removed the lane, and the branch is ours | `close-pr` | The command closes the pull request. The command deletes the branch, unless the branch holds unmerged commits. |
307
+ | no lane, and the branch is not ours | `noop` | Nothing. Read [when the command deletes a branch](#when-the-command-deletes-a-branch). |
308
+ | nothing moved, or the pull request has the `bit-sync-conflict` label | `noop` | Nothing. |
308
309
 
309
310
  An `--all` run visits two sets of targets: the lanes that match the `lanes` patterns, and the lane-mapped
310
311
  branches on `origin`. The second set makes the cleanup possible. A lane that bit.cloud deleted is absent from
@@ -323,6 +324,31 @@ pull request, the command does nothing for that lane. Remove the label to sync t
323
324
  component granularity: every file of a conflicted component takes the winning side. The summary names what
324
325
  the command rewrote.
325
326
 
327
+ ### Adopting a branch on first contact
328
+
329
+ A lane can exist on bit.cloud before its branch ever records a pointer to it — for example, a pull request
330
+ that `bit ci pr --keep-lane` turned into a lane, on a branch a developer pushed with plain git. The branch
331
+ has dev commits, and the lane exists, but the committed `.bitmap` of the branch holds no state for it: a
332
+ first-contact pair, not a conflict. `adopt-branch` handles it, PROVIDED the branch would not change the lane.
333
+ The command switches onto the lane, keeping the files of the branch, and asks `bit status` whether anything
334
+ is new or modified relative to the lane — a read, never a snap. Two outcomes:
335
+
336
+ - **Nothing changed.** The content of the branch already matches the lane's — the common shape, since
337
+ `bit ci pr --keep-lane` exported that very content already. The command records the lane pointer on the
338
+ branch (the same commit every other action pushes) and moves on. The next run reads a converged pair.
339
+ - **Something changed.** The two sides genuinely disagree, with no known common history to merge from.
340
+ The command halts, the same way it halted before this action existed: it cannot tell which side is
341
+ newer. Nothing is snapped or exported; the lane is untouched, and the workspace is left clean.
342
+
343
+ Adoption never touches a branch whose `.bitmap` asserts a DIFFERENT lane's claim of its own.
344
+ A different-lane pointer the branch merely inherited — its `.bitmap` is unchanged since the branch forked
345
+ from the default branch, the ordinary shape of a branch cut after some other lane's sync pull request
346
+ landed — is history, not a claim, and does not block adoption.
347
+
348
+ A pointer Bit marked **not exported**, same as for [deletion attribution](#when-the-command-deletes-a-branch),
349
+ does not count as state either: it is intentional, not a gap. Nothing was ever proven about that lane, so
350
+ there is nothing to protect, and the branch is a first-contact candidate exactly as if no pointer existed.
351
+
326
352
  ### When the command deletes a branch
327
353
 
328
354
  With the default empty `branchPrefix`, every branch maps to a lane of the same name. The command therefore
@@ -337,7 +363,11 @@ judges all three from the git history alone:
337
363
  it, or the branch **tip** is already in the default branch. In the second case the deletion loses nothing.
338
364
  3. **Authorship** — for a live branch, the tip must carry the `[bit-sync]` marker on its own line. A
339
365
  developer commits `.bitmap` too, so this test is necessary and never sufficient. The test can withhold a
340
- deletion, and it can never authorize one.
366
+ deletion, and it can never authorize one. A tip from [adopting a branch on first
367
+ contact](#adopting-a-branch-on-first-contact) carries the marker too, but never authorizes a deletion
368
+ either, while the state commit is not yet reachable from the default branch: adoption proved the content
369
+ of the branch matched the lane's, never that the pre-existing history of the branch is disposable. Once
370
+ the branch is genuinely merged, reachability alone is enough, exactly as for any other branch.
341
371
 
342
372
  If the attribution test fails, the action is a plain `noop` and the command writes nothing. The command
343
373
  reports a **kept** branch on every later run, until a person deletes the branch, or until its commits reach
package/dist/ci.docs.mdx CHANGED
@@ -297,14 +297,15 @@ that commit. A narrow refspec is acceptable, and a cold local scope is acceptabl
297
297
  For each mapped lane, the command compares the remote head of the lane with the state that the committed
298
298
  `.bitmap` of the branch records. The command then picks one action:
299
299
 
300
- | Situation | Action | Effect |
301
- | -------------------------------------------------------------------- | ---------------- | -------------------------------------------------------------------------------------------------------------- |
302
- | the lane moved, the branch did not | `import-lane` | The command puts the lane on the branch, pushes, and opens the pull request if it is absent. |
303
- | the branch got dev commits, the lane did not move | `export-branch` | The command snaps and exports the tree of the branch onto the lane. |
304
- | both moved | `merge-diverged` | The command merges the lane into the tree of the branch, then snaps and exports. |
305
- | bit.cloud removed the lane, and the branch is ours | `close-pr` | The command closes the pull request. The command deletes the branch, unless the branch holds unmerged commits. |
306
- | no lane, and the branch is not ours | `noop` | Nothing. Read [when the command deletes a branch](#when-the-command-deletes-a-branch). |
307
- | nothing moved, or the pull request has the `bit-sync-conflict` label | `noop` | Nothing. |
300
+ | Situation | Action | Effect |
301
+ | ----------------------------------------------------------------------------------------- | ---------------- | -------------------------------------------------------------------------------------------------------------- |
302
+ | the lane moved, the branch did not | `import-lane` | The command puts the lane on the branch, pushes, and opens the pull request if it is absent. |
303
+ | the branch got dev commits, the lane did not move | `export-branch` | The command snaps and exports the tree of the branch onto the lane. |
304
+ | both moved | `merge-diverged` | The command merges the lane into the tree of the branch, then snaps and exports. |
305
+ | the lane exists, the branch has dev commits, but the branch never recorded a lane pointer | `adopt-branch` | First contact. Read [Adopting a branch on first contact](#adopting-a-branch-on-first-contact). |
306
+ | bit.cloud removed the lane, and the branch is ours | `close-pr` | The command closes the pull request. The command deletes the branch, unless the branch holds unmerged commits. |
307
+ | no lane, and the branch is not ours | `noop` | Nothing. Read [when the command deletes a branch](#when-the-command-deletes-a-branch). |
308
+ | nothing moved, or the pull request has the `bit-sync-conflict` label | `noop` | Nothing. |
308
309
 
309
310
  An `--all` run visits two sets of targets: the lanes that match the `lanes` patterns, and the lane-mapped
310
311
  branches on `origin`. The second set makes the cleanup possible. A lane that bit.cloud deleted is absent from
@@ -323,6 +324,31 @@ pull request, the command does nothing for that lane. Remove the label to sync t
323
324
  component granularity: every file of a conflicted component takes the winning side. The summary names what
324
325
  the command rewrote.
325
326
 
327
+ ### Adopting a branch on first contact
328
+
329
+ A lane can exist on bit.cloud before its branch ever records a pointer to it — for example, a pull request
330
+ that `bit ci pr --keep-lane` turned into a lane, on a branch a developer pushed with plain git. The branch
331
+ has dev commits, and the lane exists, but the committed `.bitmap` of the branch holds no state for it: a
332
+ first-contact pair, not a conflict. `adopt-branch` handles it, PROVIDED the branch would not change the lane.
333
+ The command switches onto the lane, keeping the files of the branch, and asks `bit status` whether anything
334
+ is new or modified relative to the lane — a read, never a snap. Two outcomes:
335
+
336
+ - **Nothing changed.** The content of the branch already matches the lane's — the common shape, since
337
+ `bit ci pr --keep-lane` exported that very content already. The command records the lane pointer on the
338
+ branch (the same commit every other action pushes) and moves on. The next run reads a converged pair.
339
+ - **Something changed.** The two sides genuinely disagree, with no known common history to merge from.
340
+ The command halts, the same way it halted before this action existed: it cannot tell which side is
341
+ newer. Nothing is snapped or exported; the lane is untouched, and the workspace is left clean.
342
+
343
+ Adoption never touches a branch whose `.bitmap` asserts a DIFFERENT lane's claim of its own.
344
+ A different-lane pointer the branch merely inherited — its `.bitmap` is unchanged since the branch forked
345
+ from the default branch, the ordinary shape of a branch cut after some other lane's sync pull request
346
+ landed — is history, not a claim, and does not block adoption.
347
+
348
+ A pointer Bit marked **not exported**, same as for [deletion attribution](#when-the-command-deletes-a-branch),
349
+ does not count as state either: it is intentional, not a gap. Nothing was ever proven about that lane, so
350
+ there is nothing to protect, and the branch is a first-contact candidate exactly as if no pointer existed.
351
+
326
352
  ### When the command deletes a branch
327
353
 
328
354
  With the default empty `branchPrefix`, every branch maps to a lane of the same name. The command therefore
@@ -337,7 +363,11 @@ judges all three from the git history alone:
337
363
  it, or the branch **tip** is already in the default branch. In the second case the deletion loses nothing.
338
364
  3. **Authorship** — for a live branch, the tip must carry the `[bit-sync]` marker on its own line. A
339
365
  developer commits `.bitmap` too, so this test is necessary and never sufficient. The test can withhold a
340
- deletion, and it can never authorize one.
366
+ deletion, and it can never authorize one. A tip from [adopting a branch on first
367
+ contact](#adopting-a-branch-on-first-contact) carries the marker too, but never authorizes a deletion
368
+ either, while the state commit is not yet reachable from the default branch: adoption proved the content
369
+ of the branch matched the lane's, never that the pre-existing history of the branch is disposable. Once
370
+ the branch is genuinely merged, reachability alone is enough, exactly as for any other branch.
341
371
 
342
372
  If the attribution test fails, the action is a plain `noop` and the command writes nothing. The command
343
373
  reports a **kept** branch on every later run, until a person deletes the branch, or until its commits reach
@@ -171,6 +171,12 @@ export declare class CiMain {
171
171
  * `.bitmap` loaded at startup — and the next write would persist that stale state.
172
172
  */
173
173
  reloadWorkspaceFromDisk(): Promise<void>;
174
+ /**
175
+ * Whether the workspace has anything the current lane doesn't reflect, per `bit status`. Read-only:
176
+ * adoption uses this instead of a probe snap, which writes even under dryRun. Every signal a later
177
+ * snap/export would push counts — including soft removals, hidden pending exports, and merge state.
178
+ */
179
+ hasUnsyncedWorkChanges(): Promise<boolean>;
174
180
  /** `bit ci sync` — reconcile Bit lanes and the main scope with git branches and PRs (see `SyncOrchestrator`). */
175
181
  sync(opts?: {
176
182
  lane?: string;
@@ -263,6 +263,13 @@ function _syncConfig() {
263
263
  };
264
264
  return data;
265
265
  }
266
+ function _syncState() {
267
+ const data = require("./sync/sync-state");
268
+ _syncState = function () {
269
+ return data;
270
+ };
271
+ return data;
272
+ }
266
273
  const _excluded = ["writeAdoptedFiles"];
267
274
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
268
275
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -603,6 +610,19 @@ class CiMain {
603
610
  await this.workspace._reloadConsumer();
604
611
  }
605
612
 
613
+ /**
614
+ * Whether the workspace has anything the current lane doesn't reflect, per `bit status`. Read-only:
615
+ * adoption uses this instead of a probe snap, which writes even under dryRun. Every signal a later
616
+ * snap/export would push counts — including soft removals, hidden pending exports, and merge state.
617
+ */
618
+ async hasUnsyncedWorkChanges() {
619
+ const status = await this.status.status({
620
+ lanes: true
621
+ });
622
+ const divergence = [status.newComponents, status.modifiedComponents, status.stagedComponents, status.locallySoftRemoved, status.pendingUpdateDependents, status.mergePendingComponents, status.componentsDuringMergeState];
623
+ return divergence.some(components => components.length > 0);
624
+ }
625
+
606
626
  /** `bit ci sync` — reconcile Bit lanes and the main scope with git branches and PRs (see `SyncOrchestrator`). */
607
627
  async sync(opts = {}) {
608
628
  return new (_syncOrchestrator().SyncOrchestrator)({
@@ -647,6 +667,7 @@ class CiMain {
647
667
  // lane head differs from it (the rest have nothing to sync). This single pass feeds both the
648
668
  // pre-fetch below and the merge loop, so we never load the same ModelComponent twice.
649
669
  const componentsToSync = (0, _lodash().compact)(await Promise.all(currentLane.components.map(async laneComp => {
670
+ if (!workspaceIds.hasWithoutVersion(laneComp.id)) return undefined; // not tracked = not snappable
650
671
  try {
651
672
  const modelComponent = await legacyScope.getModelComponentIfExist(laneComp.id);
652
673
  const mainHead = modelComponent?.head; // the component's head on main
@@ -1136,8 +1157,8 @@ class CiMain {
1136
1157
  skipTasks
1137
1158
  });
1138
1159
  if (!results) {
1139
- this.logger.console(_chalk().default.yellow('No changes detected, nothing to snap'));
1140
- return 'No changes detected, nothing to snap';
1160
+ this.logger.console(_chalk().default.yellow(_syncState().NO_CHANGES_TO_SNAP));
1161
+ return _syncState().NO_CHANGES_TO_SNAP;
1141
1162
  }
1142
1163
  const {
1143
1164
  snappedComponents
@@ -1208,7 +1229,7 @@ class CiMain {
1208
1229
  remote: false,
1209
1230
  force: true
1210
1231
  });
1211
- return 'No changes detected, nothing to snap';
1232
+ return _syncState().NO_CHANGES_TO_SNAP;
1212
1233
  }
1213
1234
  const {
1214
1235
  snappedComponents