bstack 0.2.0 → 0.2.1

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.
Files changed (2) hide show
  1. package/dist/bstack.js +7 -1
  2. package/package.json +1 -1
package/dist/bstack.js CHANGED
@@ -5,7 +5,7 @@ import { randomUUID } from "node:crypto";
5
5
  import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
6
6
  import { dirname } from "node:path";
7
7
  //#region package.json
8
- var version = "0.2.0";
8
+ var version = "0.2.1";
9
9
  //#endregion
10
10
  //#region src/command.ts
11
11
  var CommandError = class extends Error {
@@ -597,6 +597,7 @@ function analyzeEvolution(previous, changes, github) {
597
597
  if (!previous) return { kind: "full" };
598
598
  const previousIds = previous.changes.map((change) => change.id);
599
599
  const currentIds = changes.map((change) => change.id);
600
+ if (isSubsequence(previousIds, currentIds)) return { kind: "full" };
600
601
  const firstCurrentIndex = previousIds.indexOf(currentIds[0]);
601
602
  if (firstCurrentIndex === -1) throw new Error("The current commits do not continue the previously submitted stack");
602
603
  const removedPrefix = previous.changes.slice(0, firstCurrentIndex);
@@ -618,6 +619,11 @@ function analyzeEvolution(previous, changes, github) {
618
619
  branches: appended.map((change) => change.remoteBranch)
619
620
  };
620
621
  }
622
+ function isSubsequence(expected, actual) {
623
+ let expectedIndex = 0;
624
+ for (const value of actual) if (value === expected[expectedIndex]) expectedIndex++;
625
+ return expectedIndex === expected.length;
626
+ }
621
627
  function writeUpdatedState(store, state, previous, updated) {
622
628
  const stacks = previous ? state.stacks.map((stack) => stack === previous ? updated : stack) : [...state.stacks, updated];
623
629
  store.write({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bstack",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "packageManager": "pnpm@11.5.1",
5
5
  "description": "Create native GitHub stacked pull requests from a linear series of commits",
6
6
  "repository": {