bstack 0.1.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.
- package/dist/bstack.js +19 -0
- package/package.json +1 -1
package/dist/bstack.js
CHANGED
|
@@ -4,6 +4,9 @@ import { spawnSync } from "node:child_process";
|
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { dirname } from "node:path";
|
|
7
|
+
//#region package.json
|
|
8
|
+
var version = "0.2.1";
|
|
9
|
+
//#endregion
|
|
7
10
|
//#region src/command.ts
|
|
8
11
|
var CommandError = class extends Error {
|
|
9
12
|
command;
|
|
@@ -594,6 +597,7 @@ function analyzeEvolution(previous, changes, github) {
|
|
|
594
597
|
if (!previous) return { kind: "full" };
|
|
595
598
|
const previousIds = previous.changes.map((change) => change.id);
|
|
596
599
|
const currentIds = changes.map((change) => change.id);
|
|
600
|
+
if (isSubsequence(previousIds, currentIds)) return { kind: "full" };
|
|
597
601
|
const firstCurrentIndex = previousIds.indexOf(currentIds[0]);
|
|
598
602
|
if (firstCurrentIndex === -1) throw new Error("The current commits do not continue the previously submitted stack");
|
|
599
603
|
const removedPrefix = previous.changes.slice(0, firstCurrentIndex);
|
|
@@ -615,6 +619,11 @@ function analyzeEvolution(previous, changes, github) {
|
|
|
615
619
|
branches: appended.map((change) => change.remoteBranch)
|
|
616
620
|
};
|
|
617
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
|
+
}
|
|
618
627
|
function writeUpdatedState(store, state, previous, updated) {
|
|
619
628
|
const stacks = previous ? state.stacks.map((stack) => stack === previous ? updated : stack) : [...state.stacks, updated];
|
|
620
629
|
store.write({
|
|
@@ -637,6 +646,7 @@ Options:
|
|
|
637
646
|
--dry-run Inspect the stack without rewriting commits or pushing
|
|
638
647
|
--quiet Hide progress logs; the final summary is still printed
|
|
639
648
|
--same-base Refuse checkout if it would change the current merge base
|
|
649
|
+
-v, --version Show the installed version
|
|
640
650
|
-h, --help Show this help
|
|
641
651
|
`;
|
|
642
652
|
function main() {
|
|
@@ -662,6 +672,11 @@ function main() {
|
|
|
662
672
|
type: "boolean",
|
|
663
673
|
default: false
|
|
664
674
|
},
|
|
675
|
+
version: {
|
|
676
|
+
type: "boolean",
|
|
677
|
+
short: "v",
|
|
678
|
+
default: false
|
|
679
|
+
},
|
|
665
680
|
help: {
|
|
666
681
|
type: "boolean",
|
|
667
682
|
short: "h",
|
|
@@ -673,6 +688,10 @@ function main() {
|
|
|
673
688
|
process.stdout.write(help);
|
|
674
689
|
return;
|
|
675
690
|
}
|
|
691
|
+
if (values.version) {
|
|
692
|
+
console.log(version);
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
676
695
|
const runner = new NodeCommandRunner();
|
|
677
696
|
const cwd = process.cwd();
|
|
678
697
|
const repository = new GitRepository(cwd, runner);
|