@dev.fast/whiteboard 0.3.4 → 0.3.5-preview.20261021.131
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/{account-alias-CprZojXd.js → account-alias-CisiYUZT.js} +13 -8
- package/dist/agent-cli-BglNRDZN.js +2 -0
- package/dist/{agent-cli-CThN7Q59.js → agent-cli-TJ7_5_B3.js} +15 -10
- package/dist/{agent-client-BOOi7EUR.js → agent-client-H53ajvrm.js} +13 -3
- package/dist/{authoring-tools-BNwuMnz6.js → authoring-tools-BCquUsB3.js} +34 -27
- package/dist/{background-server-DLSDogkI.js → background-server-BSYXD9au.js} +1 -1
- package/dist/{background-server-CkvxA-6O.js → background-server-Xom8cA_u.js} +5 -5
- package/dist/build-info.json +1 -1
- package/dist/{cli-R4yfa5DT.js → cli-BOnV4cCh.js} +1 -1
- package/dist/{cli-runner-Cuc9FSzu.js → cli-runner-cRY5NOno.js} +70 -34
- package/dist/cli.js +4 -3
- package/dist/{client-BN_FDxFr.js → client-UH1bEG7Z.js} +260 -49
- package/dist/{fuzzy-match-BO9bK37N.js → fuzzy-match-D_x3wumC.js} +6 -4
- package/dist/{headless-host-CVBOQyRS.js → headless-host-BEe-aFtB.js} +1 -1
- package/dist/{headless-host-Cog6SpS9.js → headless-host-CEb5d-A0.js} +563 -175
- package/dist/lens-selection-BxPk53c8.js +214 -0
- package/dist/{local-data-D_9tvdsp.js → local-data-mbCb1HDH.js} +2448 -347
- package/dist/{mcp-D1hziANa.js → mcp-cBtzXsmN.js} +9 -12
- package/dist/{package-paths-C--__jEv.js → package-paths-BkeQsdaw.js} +1 -1
- package/dist/profile-Dbyidrcr.js +2 -0
- package/dist/{profile-DokFw782.js → profile-duqp5uPa.js} +20 -8
- package/dist/{remote-attach-CEJ-kvDY.js → remote-attach-BeKuMm_x.js} +4 -4
- package/dist/{remote-extensions-GN8Gf_qG.js → remote-extensions-CX2fAec1.js} +1 -1
- package/dist/{remote-extensions-Blcjr9Ze.js → remote-extensions-CYWNTVSf.js} +3 -3
- package/dist/{remote-language-server-BTKBQ7x4.js → remote-language-server-DLWluAeR.js} +5 -5
- package/dist/{remote-uninstall-DW7Gdryh.js → remote-uninstall-Y3S0YmJs.js} +6 -6
- package/dist/{request-origin-Zcn_CjX4.js → request-origin-icXPv6jh.js} +55 -18
- package/dist/{review-app-launcher-CkwLclzR.js → review-app-launcher-DZvG5ZAh.js} +2 -2
- package/dist/{review-home-paths-j2BRAaNv.js → review-home-paths-BwH08ihj.js} +19 -17
- package/dist/{review-telemetry-BLNwYnLV.js → review-telemetry-AZ0imsmJ.js} +6 -6
- package/dist/runtime-CF4JXdb8.js +27 -0
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.js +1 -1
- package/dist/{s3-DtJFWC0G.js → s3-CsG2EWED.js} +1 -1
- package/dist/{s3-config-BTO12tCC.js → s3-config-CjcLyFV5.js} +4 -2
- package/dist/{s3-config-CSy3fx8H.js → s3-config-zz4GWh2T.js} +1 -1
- package/dist/server/desktop-host.js +28 -104
- package/dist/{server-discovery-Bey8IqXH.js → server-discovery-DeVTdcqK.js} +3 -3
- package/dist/sharing/index.d.ts +484 -74
- package/dist/sharing/index.js +1 -1
- package/dist/{src-DsM3jO8G.js → src-DYZLCUP_.js} +98 -18
- package/dist/{src-BMPuxWv4.js → src-DtfSndqS.js} +269 -227
- package/dist/{stored-document-migration-CChxtFAy.js → stored-document-migration-B29lve9-.js} +318 -271
- package/dist/{thread-state-5pYr6_zM.js → thread-state-BPpvKFwQ.js} +12 -2
- package/dist/{tool-failure-C9MpbXJJ.js → tool-failure-CQhyLht3.js} +10 -3
- package/instructions/authoring.md +20 -5
- package/package.json +4 -4
- package/src/agent-selection.ts +6 -0
- package/src/ask/agents.ts +13 -1
- package/src/ask/checkout-files.ts +2 -5
- package/src/ask/thread-state.ts +4 -0
- package/src/ask/thread.ts +61 -31
- package/src/ask/threads.ts +24 -3
- package/src/cli-install.ts +13 -2
- package/src/cli-runner.ts +4 -1
- package/src/cli.ts +4 -1
- package/src/diff-selection-migration.ts +48 -34
- package/src/heading-anchors.ts +42 -0
- package/src/lens-selection.ts +38 -2
- package/src/markdown.ts +42 -0
- package/src/posthog-capture-client.ts +1 -1
- package/src/review-api/README.md +52 -13
- package/src/review-api/activity.ts +1 -4
- package/src/review-api/agent-cli.ts +9 -1
- package/src/review-api/anchor-quotes.ts +14 -7
- package/src/review-api/ask-history.ts +118 -51
- package/src/review-api/authoring-tools.ts +45 -30
- package/src/review-api/azure-devops-provider.ts +2 -20
- package/src/review-api/azure-remote.ts +21 -0
- package/src/review-api/blocks/definition.ts +1 -1
- package/src/review-api/blocks/markdown.ts +2 -2
- package/src/review-api/board-order.ts +144 -0
- package/src/review-api/checkout-groups.ts +586 -0
- package/src/review-api/document-headings.ts +58 -27
- package/src/review-api/document-text.ts +31 -2
- package/src/review-api/document.ts +362 -67
- package/src/review-api/foreign-references.ts +328 -0
- package/src/review-api/github-provider.ts +51 -13
- package/src/review-api/http.ts +734 -135
- package/src/review-api/instructions.ts +0 -19
- package/src/review-api/link-preview.ts +113 -0
- package/src/review-api/local-data.ts +310 -46
- package/src/review-api/mcp.ts +7 -13
- package/src/review-api/onboarding.ts +1 -1
- package/src/review-api/profile.ts +37 -6
- package/src/review-api/public-tools.ts +24 -2
- package/src/review-api/pull-request.ts +82 -49
- package/src/review-api/request-origin.ts +10 -0
- package/src/review-api/review-progress.ts +61 -27
- package/src/review-api/scratchpad-plan-upgrade.ts +250 -0
- package/src/review-api/store-migrations.ts +355 -0
- package/src/review-api/store-schema.ts +38 -29
- package/src/review-api/store.ts +2176 -495
- package/src/review-api/worktree-events.ts +3 -5
- package/src/review-api/worktree-source.ts +3 -7
- package/src/review-api/worktree-structural.integration.ts +72 -0
- package/src/review-stack.ts +15 -23
- package/src/runtime.ts +4 -30
- package/src/server/desktop-host.ts +6 -1
- package/src/server/desktop-server.ts +1 -36
- package/src/server/headless-host.ts +0 -2
- package/src/server/hono-http.ts +2 -1
- package/src/server/review-gateway-list.ts +3 -5
- package/src/server/review-gateway-memory.ts +1 -1
- package/src/server/review-lifecycle-telemetry.ts +2 -2
- package/src/server/review-server-core.ts +1 -5
- package/src/server/structural-comparisons.ts +47 -0
- package/src/sharing/export.ts +36 -7
- package/src/sharing/host.ts +34 -14
- package/src/sharing/import.ts +156 -24
- package/src/sharing/repository.ts +143 -24
- package/src/startup-trace.ts +3 -3
- package/src/stored-document-migration.ts +110 -19
- package/src/ui-telemetry-events.ts +44 -18
- package/dist/agent-cli-C6SPSII0.js +0 -2
- package/dist/profile-CYPmvBoA.js +0 -2
- package/dist/runtime-CKiWhGrf.js +0 -52
- package/instructions/scratchpad.md +0 -23
- package/src/review-preferences.ts +0 -88
- package/src/server/legacy-tutorial-cleanup.ts +0 -38
|
@@ -684,22 +684,182 @@ var import_lib = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((export
|
|
|
684
684
|
}
|
|
685
685
|
module.exports = gitUrlParse;
|
|
686
686
|
})))(), 1);
|
|
687
|
+
/** A quick query: a ref, a config value, a status. */
|
|
688
|
+
const QUICK_TIMEOUT_MS = 3e4;
|
|
689
|
+
/** A read that grows with the repository or a file in it, or a jj call. */
|
|
690
|
+
const LARGE_READ_TIMEOUT_MS = 3e5;
|
|
691
|
+
/** Talking to a remote. */
|
|
692
|
+
const NETWORK_TIMEOUT_MS = 6e5;
|
|
693
|
+
const NETWORK_COMMANDS = /* @__PURE__ */ new Set([
|
|
694
|
+
"fetch",
|
|
695
|
+
"clone",
|
|
696
|
+
"pull",
|
|
697
|
+
"push",
|
|
698
|
+
"ls-remote"
|
|
699
|
+
]);
|
|
700
|
+
const LARGE_READS = /* @__PURE__ */ new Set([
|
|
701
|
+
"archive",
|
|
702
|
+
"blame",
|
|
703
|
+
"cat-file",
|
|
704
|
+
"diff",
|
|
705
|
+
"diff-tree",
|
|
706
|
+
"format-patch",
|
|
707
|
+
"grep",
|
|
708
|
+
"log",
|
|
709
|
+
"ls-files",
|
|
710
|
+
"ls-tree",
|
|
711
|
+
"rev-list",
|
|
712
|
+
"show"
|
|
713
|
+
]);
|
|
714
|
+
const VALUED_OPTIONS = [
|
|
715
|
+
"-C",
|
|
716
|
+
"-c",
|
|
717
|
+
"--git-dir",
|
|
718
|
+
"--work-tree",
|
|
719
|
+
"-R"
|
|
720
|
+
];
|
|
721
|
+
/** The subcommand's index; `args.length` if none. */
|
|
722
|
+
function subcommandIndex(args) {
|
|
723
|
+
for (let i = 0; i < args.length; i++) {
|
|
724
|
+
const arg = args[i];
|
|
725
|
+
if (VALUED_OPTIONS.includes(arg)) i++;
|
|
726
|
+
else if (!arg.startsWith("-")) return i;
|
|
727
|
+
}
|
|
728
|
+
return args.length;
|
|
729
|
+
}
|
|
730
|
+
function talksToRemote(args) {
|
|
731
|
+
const command = args[subcommandIndex(args)];
|
|
732
|
+
return command !== void 0 && NETWORK_COMMANDS.has(command);
|
|
733
|
+
}
|
|
734
|
+
const namesRepository = (args) => args.slice(0, subcommandIndex(args)).some((arg) => arg === "-C" || arg === "--git-dir");
|
|
735
|
+
/** How long a call may run when its caller doesn't say. */
|
|
736
|
+
function defaultVcsTimeout(tool, args) {
|
|
737
|
+
if (talksToRemote(args)) return NETWORK_TIMEOUT_MS;
|
|
738
|
+
const command = args[subcommandIndex(args)];
|
|
739
|
+
if (tool === "jj" || command && LARGE_READS.has(command)) return LARGE_READ_TIMEOUT_MS;
|
|
740
|
+
return QUICK_TIMEOUT_MS;
|
|
741
|
+
}
|
|
742
|
+
const COMMIT_ID = /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/;
|
|
743
|
+
/** Thrown before anything runs when an operand could be misread. */
|
|
744
|
+
var VcsOperandError = class extends Error {};
|
|
745
|
+
function refused(kind, value) {
|
|
746
|
+
throw new VcsOperandError(`Refusing ${kind} ${JSON.stringify(value)}.`);
|
|
747
|
+
}
|
|
748
|
+
/** Whether a value could be read as an option, or carries a control
|
|
749
|
+
* character or a line break. */
|
|
750
|
+
const unsafe = (value) => !value || value.startsWith("-") || /[\0-\x1f\x7f]/.test(value);
|
|
751
|
+
const unsafeRef = (value) => unsafe(value) || /[\s:~^?*[\\]|\.\.|@\{/.test(value);
|
|
752
|
+
function checkRefSide(value) {
|
|
753
|
+
if (!COMMIT_ID.test(value) && unsafeRef(value)) refused("ref", value);
|
|
754
|
+
}
|
|
755
|
+
/** Operands are objects; flags written in the code are strings. */
|
|
756
|
+
const isOperand = (arg) => Object(arg) === arg;
|
|
757
|
+
/** The arguments as the process gets them: operands checked, so none can
|
|
758
|
+
* be read as an option, and paths after `--`. (`--end-of-options` would say
|
|
759
|
+
* the same to git, but older gits refuse it in some commands.) */
|
|
760
|
+
function renderVcsArgs(args) {
|
|
761
|
+
const out = [];
|
|
762
|
+
let paths = false;
|
|
763
|
+
for (const arg of args) {
|
|
764
|
+
if (!isOperand(arg)) {
|
|
765
|
+
if (arg === "--") paths = true;
|
|
766
|
+
out.push(arg);
|
|
767
|
+
continue;
|
|
768
|
+
}
|
|
769
|
+
if ("path" in arg) {
|
|
770
|
+
if (!arg.path || /\0/.test(arg.path)) refused("path", arg.path);
|
|
771
|
+
if (!paths) {
|
|
772
|
+
out.push("--");
|
|
773
|
+
paths = true;
|
|
774
|
+
}
|
|
775
|
+
out.push(arg.path);
|
|
776
|
+
continue;
|
|
777
|
+
}
|
|
778
|
+
let rendered;
|
|
779
|
+
if ("commit" in arg) {
|
|
780
|
+
if (!COMMIT_ID.test(arg.commit)) refused("commit", arg.commit);
|
|
781
|
+
rendered = arg.commit;
|
|
782
|
+
} else if ("rev" in arg) {
|
|
783
|
+
if (unsafe(arg.rev)) refused("revision", arg.rev);
|
|
784
|
+
rendered = arg.rev;
|
|
785
|
+
} else if ("ref" in arg) {
|
|
786
|
+
if (unsafeRef(arg.ref)) refused("ref", arg.ref);
|
|
787
|
+
rendered = arg.ref;
|
|
788
|
+
} else if ("refspec" in arg) {
|
|
789
|
+
checkRefSide(arg.refspec.from);
|
|
790
|
+
checkRefSide(arg.refspec.to);
|
|
791
|
+
rendered = `${arg.refspec.force ? "+" : ""}${arg.refspec.from}:${arg.refspec.to}`;
|
|
792
|
+
} else if ("remote" in arg) {
|
|
793
|
+
if (unsafe(arg.remote) || /\s/.test(arg.remote)) refused("remote", arg.remote);
|
|
794
|
+
rendered = arg.remote;
|
|
795
|
+
} else {
|
|
796
|
+
if (unsafe(arg.value)) refused("value", arg.value);
|
|
797
|
+
rendered = arg.value;
|
|
798
|
+
}
|
|
799
|
+
out.push(rendered);
|
|
800
|
+
}
|
|
801
|
+
return out;
|
|
802
|
+
}
|
|
803
|
+
const LOCAL_GIT_ENV_KEYS = [
|
|
804
|
+
"GIT_ALTERNATE_OBJECT_DIRECTORIES",
|
|
805
|
+
"GIT_COMMON_DIR",
|
|
806
|
+
"GIT_CONFIG",
|
|
807
|
+
"GIT_CONFIG_COUNT",
|
|
808
|
+
"GIT_CONFIG_PARAMETERS",
|
|
809
|
+
"GIT_DIR",
|
|
810
|
+
"GIT_GRAFT_FILE",
|
|
811
|
+
"GIT_IMPLICIT_WORK_TREE",
|
|
812
|
+
"GIT_INDEX_FILE",
|
|
813
|
+
"GIT_INTERNAL_SUPER_PREFIX",
|
|
814
|
+
"GIT_NO_REPLACE_OBJECTS",
|
|
815
|
+
"GIT_OBJECT_DIRECTORY",
|
|
816
|
+
"GIT_PREFIX",
|
|
817
|
+
"GIT_QUARANTINE_PATH",
|
|
818
|
+
"GIT_REPLACE_REF_BASE",
|
|
819
|
+
"GIT_SHALLOW_FILE",
|
|
820
|
+
"GIT_WORK_TREE"
|
|
821
|
+
];
|
|
822
|
+
/** The process environment without the variables that would redirect git
|
|
823
|
+
* to another repository's objects, index or work tree. */
|
|
824
|
+
function localGitEnvironment() {
|
|
825
|
+
const env = { ...process.env };
|
|
826
|
+
for (const key of LOCAL_GIT_ENV_KEYS) delete env[key];
|
|
827
|
+
return env;
|
|
828
|
+
}
|
|
829
|
+
/** The environment a version-control process runs with. A git call that
|
|
830
|
+
* names its repository (`-C`, `--git-dir`) and brings no environment of its
|
|
831
|
+
* own drops the variables that would redirect it to another. */
|
|
832
|
+
function vcsEnvironment(tool, args, env) {
|
|
833
|
+
const next = { ...env ?? (tool === "git" && namesRepository(args) ? localGitEnvironment() : process.env) };
|
|
834
|
+
if (!talksToRemote(args)) next.GIT_NO_LAZY_FETCH = "1";
|
|
835
|
+
next.GIT_TERMINAL_PROMPT = "0";
|
|
836
|
+
next.GH_PROMPT_DISABLED = "1";
|
|
837
|
+
return next;
|
|
838
|
+
}
|
|
687
839
|
let observer = null;
|
|
688
840
|
function setLocalVcsCommandObserver(next) {
|
|
689
841
|
observer = next;
|
|
690
842
|
}
|
|
691
843
|
const execFilePromise = promisify(execFile);
|
|
692
|
-
async function
|
|
844
|
+
async function runVcs(tool, vcsArgs, { input, ...options } = {}) {
|
|
845
|
+
const args = renderVcsArgs(vcsArgs);
|
|
693
846
|
const finish = observer?.start({
|
|
694
|
-
|
|
847
|
+
tool,
|
|
695
848
|
args,
|
|
696
849
|
cwd: options.cwd === void 0 ? void 0 : String(options.cwd)
|
|
697
850
|
});
|
|
698
851
|
try {
|
|
699
|
-
const
|
|
852
|
+
const running = execFilePromise(tool, args, {
|
|
700
853
|
...options,
|
|
854
|
+
env: vcsEnvironment(tool, args, options.env),
|
|
855
|
+
timeout: options.timeout ?? defaultVcsTimeout(tool, args),
|
|
701
856
|
encoding: options.encoding ?? "utf8"
|
|
702
857
|
});
|
|
858
|
+
if (input !== void 0) {
|
|
859
|
+
running.child.stdin?.on("error", () => {});
|
|
860
|
+
running.child.stdin?.end(input);
|
|
861
|
+
}
|
|
862
|
+
const result = await running;
|
|
703
863
|
finish?.({ ok: true });
|
|
704
864
|
return {
|
|
705
865
|
stdout: String(result.stdout),
|
|
@@ -710,14 +870,19 @@ async function execFileAsync(file, args, options = {}) {
|
|
|
710
870
|
throw error;
|
|
711
871
|
}
|
|
712
872
|
}
|
|
713
|
-
function
|
|
873
|
+
function runVcsSync(tool, vcsArgs, options) {
|
|
874
|
+
const args = renderVcsArgs(vcsArgs);
|
|
714
875
|
const finish = observer?.start({
|
|
715
|
-
|
|
876
|
+
tool,
|
|
716
877
|
args,
|
|
717
878
|
cwd: options.cwd === void 0 ? void 0 : String(options.cwd)
|
|
718
879
|
});
|
|
719
880
|
try {
|
|
720
|
-
const output = execFileSync(
|
|
881
|
+
const output = execFileSync(tool, args, {
|
|
882
|
+
...options,
|
|
883
|
+
env: vcsEnvironment(tool, args, options.env),
|
|
884
|
+
timeout: options.timeout ?? defaultVcsTimeout(tool, args)
|
|
885
|
+
});
|
|
721
886
|
finish?.({ ok: true });
|
|
722
887
|
return String(output);
|
|
723
888
|
} catch (error) {
|
|
@@ -726,14 +891,18 @@ function execFileSyncObserved(file, args, options) {
|
|
|
726
891
|
}
|
|
727
892
|
}
|
|
728
893
|
/** Long-lived child; the observer sees one spawn, completed once the process is up. */
|
|
729
|
-
function spawnObserved(
|
|
894
|
+
function spawnObserved(tool, vcsArgs, options) {
|
|
895
|
+
const args = renderVcsArgs(vcsArgs);
|
|
730
896
|
const finish = observer?.start({
|
|
731
|
-
|
|
897
|
+
tool,
|
|
732
898
|
args,
|
|
733
899
|
cwd: options.cwd === void 0 ? void 0 : String(options.cwd)
|
|
734
900
|
});
|
|
735
901
|
try {
|
|
736
|
-
const child = spawn(
|
|
902
|
+
const child = spawn(tool, args, {
|
|
903
|
+
...options,
|
|
904
|
+
env: vcsEnvironment(tool, args, options.env)
|
|
905
|
+
});
|
|
737
906
|
let finished = false;
|
|
738
907
|
const complete = (ok) => {
|
|
739
908
|
if (finished) return;
|
|
@@ -1013,25 +1182,6 @@ function normalizeEntry(entry) {
|
|
|
1013
1182
|
}
|
|
1014
1183
|
//#endregion
|
|
1015
1184
|
//#region ../local-vcs/src/vcs.ts
|
|
1016
|
-
const LOCAL_GIT_ENV_KEYS = [
|
|
1017
|
-
"GIT_ALTERNATE_OBJECT_DIRECTORIES",
|
|
1018
|
-
"GIT_COMMON_DIR",
|
|
1019
|
-
"GIT_CONFIG",
|
|
1020
|
-
"GIT_CONFIG_COUNT",
|
|
1021
|
-
"GIT_CONFIG_PARAMETERS",
|
|
1022
|
-
"GIT_DIR",
|
|
1023
|
-
"GIT_GRAFT_FILE",
|
|
1024
|
-
"GIT_IMPLICIT_WORK_TREE",
|
|
1025
|
-
"GIT_INDEX_FILE",
|
|
1026
|
-
"GIT_INTERNAL_SUPER_PREFIX",
|
|
1027
|
-
"GIT_NO_REPLACE_OBJECTS",
|
|
1028
|
-
"GIT_OBJECT_DIRECTORY",
|
|
1029
|
-
"GIT_PREFIX",
|
|
1030
|
-
"GIT_QUARANTINE_PATH",
|
|
1031
|
-
"GIT_REPLACE_REF_BASE",
|
|
1032
|
-
"GIT_SHALLOW_FILE",
|
|
1033
|
-
"GIT_WORK_TREE"
|
|
1034
|
-
];
|
|
1035
1185
|
/** Neither git nor jj could be started, so no folder can be recognized as a repository. */
|
|
1036
1186
|
var LocalVcsToolsMissingError = class extends Error {
|
|
1037
1187
|
constructor() {
|
|
@@ -1139,29 +1289,6 @@ async function resolveRepoContext(rootPath) {
|
|
|
1139
1289
|
githubSlug: (resolvedOriginUrl ? parseGitRemoteSlug(resolvedOriginUrl) : null) ?? (originUrl ? parseGitRemoteSlug(originUrl) : null)
|
|
1140
1290
|
};
|
|
1141
1291
|
}
|
|
1142
|
-
function resolveRepoContextSync(rootPath) {
|
|
1143
|
-
const commonDir = gitCommonDirSync(path.resolve(rootPath));
|
|
1144
|
-
if (!commonDir) return null;
|
|
1145
|
-
const originUrl = commandOutputSync("git", [
|
|
1146
|
-
"--git-dir",
|
|
1147
|
-
commonDir,
|
|
1148
|
-
"config",
|
|
1149
|
-
"--get",
|
|
1150
|
-
"remote.origin.url"
|
|
1151
|
-
]) || null;
|
|
1152
|
-
const resolvedOriginUrl = commandOutputSync("git", [
|
|
1153
|
-
"--git-dir",
|
|
1154
|
-
commonDir,
|
|
1155
|
-
"remote",
|
|
1156
|
-
"get-url",
|
|
1157
|
-
"origin"
|
|
1158
|
-
]) || null;
|
|
1159
|
-
return {
|
|
1160
|
-
commonDir,
|
|
1161
|
-
originUrl,
|
|
1162
|
-
githubSlug: (resolvedOriginUrl ? parseGitRemoteSlug(resolvedOriginUrl) : null) ?? (originUrl ? parseGitRemoteSlug(originUrl) : null)
|
|
1163
|
-
};
|
|
1164
|
-
}
|
|
1165
1292
|
/** git argv for the object store: a jj workspace reads through its backing store. */
|
|
1166
1293
|
async function objectStoreArgs(input) {
|
|
1167
1294
|
if (input.kind === "git") return ["-C", input.rootPath];
|
|
@@ -1185,10 +1312,19 @@ async function gitArgs(rootPath, args) {
|
|
|
1185
1312
|
...args
|
|
1186
1313
|
];
|
|
1187
1314
|
}
|
|
1315
|
+
/** A timed-out child said nothing, so report the kill. */
|
|
1316
|
+
function failure(cause) {
|
|
1317
|
+
const error = cause;
|
|
1318
|
+
return {
|
|
1319
|
+
ok: false,
|
|
1320
|
+
stdout: error.stdout ?? "",
|
|
1321
|
+
stderr: error.stderr || (error.killed ? `git timed out and was killed (${error.signal ?? "SIGTERM"})` : String(error))
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1188
1324
|
/** Run git against the repo's shared git dir, optionally tolerating failure. */
|
|
1189
1325
|
async function git(rootPath, args, options = {}) {
|
|
1190
1326
|
try {
|
|
1191
|
-
const { stdout, stderr } = await
|
|
1327
|
+
const { stdout, stderr } = await runVcs("git", await gitArgs(rootPath, args), {
|
|
1192
1328
|
maxBuffer: 67108864,
|
|
1193
1329
|
signal: options.signal
|
|
1194
1330
|
});
|
|
@@ -1198,14 +1334,7 @@ async function git(rootPath, args, options = {}) {
|
|
|
1198
1334
|
stderr
|
|
1199
1335
|
};
|
|
1200
1336
|
} catch (error) {
|
|
1201
|
-
if (options.allowFailure)
|
|
1202
|
-
const err = error;
|
|
1203
|
-
return {
|
|
1204
|
-
ok: false,
|
|
1205
|
-
stdout: err.stdout ?? "",
|
|
1206
|
-
stderr: err.stderr ?? String(error)
|
|
1207
|
-
};
|
|
1208
|
-
}
|
|
1337
|
+
if (options.allowFailure) return failure(error);
|
|
1209
1338
|
throw error;
|
|
1210
1339
|
}
|
|
1211
1340
|
}
|
|
@@ -1216,7 +1345,7 @@ async function git(rootPath, args, options = {}) {
|
|
|
1216
1345
|
*/
|
|
1217
1346
|
async function gitAt(cwd, args, options = {}) {
|
|
1218
1347
|
try {
|
|
1219
|
-
const { stdout, stderr } = await
|
|
1348
|
+
const { stdout, stderr } = await runVcs("git", [
|
|
1220
1349
|
"-C",
|
|
1221
1350
|
cwd,
|
|
1222
1351
|
...args
|
|
@@ -1232,14 +1361,7 @@ async function gitAt(cwd, args, options = {}) {
|
|
|
1232
1361
|
stderr
|
|
1233
1362
|
};
|
|
1234
1363
|
} catch (error) {
|
|
1235
|
-
if (options.allowFailure)
|
|
1236
|
-
const err = error;
|
|
1237
|
-
return {
|
|
1238
|
-
ok: false,
|
|
1239
|
-
stdout: err.stdout ?? "",
|
|
1240
|
-
stderr: err.stderr ?? String(error)
|
|
1241
|
-
};
|
|
1242
|
-
}
|
|
1364
|
+
if (options.allowFailure) return failure(error);
|
|
1243
1365
|
throw error;
|
|
1244
1366
|
}
|
|
1245
1367
|
}
|
|
@@ -1256,17 +1378,19 @@ function createLocalVcs(kind, rootPath) {
|
|
|
1256
1378
|
headRef,
|
|
1257
1379
|
kind
|
|
1258
1380
|
}),
|
|
1259
|
-
listTrackedFiles: (revision) =>
|
|
1381
|
+
listTrackedFiles: (revision) => listTrackedFilesOf({
|
|
1260
1382
|
rootPath,
|
|
1261
|
-
ref: revision,
|
|
1262
1383
|
kind
|
|
1263
|
-
})
|
|
1264
|
-
readFileAtRef: (ref, relativePath) =>
|
|
1265
|
-
rootPath,
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1384
|
+
}, revision),
|
|
1385
|
+
readFileAtRef: async (ref, relativePath) => {
|
|
1386
|
+
const commit = await resolveRevisionCommitByPreference(rootPath, ref, kind);
|
|
1387
|
+
return commit ? readFileAtCommit({
|
|
1388
|
+
rootPath,
|
|
1389
|
+
kind,
|
|
1390
|
+
commit,
|
|
1391
|
+
relativePath
|
|
1392
|
+
}) : null;
|
|
1393
|
+
},
|
|
1270
1394
|
diff: (input) => diffForKind({
|
|
1271
1395
|
rootPath,
|
|
1272
1396
|
baseRef: input.base,
|
|
@@ -1302,10 +1426,10 @@ function createLocalVcs(kind, rootPath) {
|
|
|
1302
1426
|
async function jjRevisionIsConflicted(rootPath, revision) {
|
|
1303
1427
|
if ((await detectLocalVcs(rootPath))?.kind !== "jj") return null;
|
|
1304
1428
|
try {
|
|
1305
|
-
const { stdout } = await
|
|
1429
|
+
const { stdout } = await runVcs("jj", [
|
|
1306
1430
|
"log",
|
|
1307
1431
|
"-r",
|
|
1308
|
-
revision,
|
|
1432
|
+
{ rev: revision },
|
|
1309
1433
|
"--no-graph",
|
|
1310
1434
|
"-T",
|
|
1311
1435
|
"if(conflict, \"true\", \"false\")",
|
|
@@ -1355,61 +1479,67 @@ async function mergeBaseForKind(input) {
|
|
|
1355
1479
|
const commit = await mergeBaseByPreference(input.rootPath, input.baseRef, input.headRef, input.kind);
|
|
1356
1480
|
return commit ? { commit } : null;
|
|
1357
1481
|
}
|
|
1358
|
-
async function
|
|
1359
|
-
|
|
1360
|
-
|
|
1482
|
+
async function listTrackedFilesOf(vcs, ref) {
|
|
1483
|
+
const run = (command, args) => commandOutput(command, args, { cwd: vcs.rootPath }).catch(() => null);
|
|
1484
|
+
if (vcs.kind === "jj") {
|
|
1485
|
+
const args = [
|
|
1361
1486
|
"-R",
|
|
1362
|
-
|
|
1487
|
+
vcs.rootPath,
|
|
1363
1488
|
"file",
|
|
1364
1489
|
"list",
|
|
1365
|
-
"--ignore-working-copy"
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1490
|
+
"--ignore-working-copy"
|
|
1491
|
+
];
|
|
1492
|
+
if (ref) args.push("-r", { rev: ref });
|
|
1493
|
+
const output = await run("jj", args);
|
|
1369
1494
|
if (output !== null) return splitLines(output);
|
|
1370
|
-
|
|
1495
|
+
const gitRoot = await run("git", [
|
|
1496
|
+
"-C",
|
|
1497
|
+
vcs.rootPath,
|
|
1498
|
+
"rev-parse",
|
|
1499
|
+
"--show-toplevel"
|
|
1500
|
+
]);
|
|
1501
|
+
if (gitRoot === null || canonicalPath(gitRoot) !== canonicalPath(vcs.rootPath)) return [];
|
|
1371
1502
|
}
|
|
1372
|
-
const output = await
|
|
1503
|
+
const output = await run("git", ref ? [
|
|
1373
1504
|
"-C",
|
|
1374
|
-
|
|
1505
|
+
vcs.rootPath,
|
|
1375
1506
|
"ls-tree",
|
|
1376
1507
|
"-r",
|
|
1377
1508
|
"-z",
|
|
1378
1509
|
"--name-only",
|
|
1379
|
-
|
|
1380
|
-
]
|
|
1510
|
+
{ rev: ref }
|
|
1511
|
+
] : [
|
|
1512
|
+
"-C",
|
|
1513
|
+
vcs.rootPath,
|
|
1514
|
+
"ls-files",
|
|
1515
|
+
"-z"
|
|
1516
|
+
]);
|
|
1381
1517
|
return output === null ? [] : output.split("\0").filter(Boolean);
|
|
1382
1518
|
}
|
|
1383
|
-
function
|
|
1519
|
+
async function listTrackedFilesAtCommit(input) {
|
|
1384
1520
|
if (input.kind === "jj") {
|
|
1385
|
-
const
|
|
1521
|
+
const output = await commandOutput("jj", [
|
|
1386
1522
|
"-R",
|
|
1387
1523
|
input.rootPath,
|
|
1388
1524
|
"file",
|
|
1389
1525
|
"list",
|
|
1390
|
-
"--ignore-working-copy"
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1526
|
+
"--ignore-working-copy",
|
|
1527
|
+
"-r",
|
|
1528
|
+
{ rev: input.commit }
|
|
1529
|
+
], { cwd: input.rootPath }).catch(() => null);
|
|
1394
1530
|
if (output !== null) return splitLines(output);
|
|
1395
|
-
if (!
|
|
1531
|
+
if (!await canUseGitFallback(input.rootPath, input.kind)) return [];
|
|
1396
1532
|
}
|
|
1397
|
-
const output =
|
|
1533
|
+
const output = await commandOutput("git", [
|
|
1398
1534
|
"-C",
|
|
1399
1535
|
input.rootPath,
|
|
1400
1536
|
"ls-tree",
|
|
1401
1537
|
"-r",
|
|
1402
1538
|
"-z",
|
|
1403
1539
|
"--name-only",
|
|
1404
|
-
input.
|
|
1405
|
-
], { cwd: input.rootPath })
|
|
1406
|
-
|
|
1407
|
-
input.rootPath,
|
|
1408
|
-
"ls-files",
|
|
1409
|
-
"-z"
|
|
1410
|
-
], { cwd: input.rootPath });
|
|
1411
|
-
if (output === null) return [];
|
|
1412
|
-
return output.split("\0").filter(Boolean);
|
|
1540
|
+
{ rev: input.commit }
|
|
1541
|
+
], { cwd: input.rootPath }).catch(() => null);
|
|
1542
|
+
return output === null ? [] : output.split("\0").filter(Boolean);
|
|
1413
1543
|
}
|
|
1414
1544
|
/**
|
|
1415
1545
|
* Read a blob at a resolved commit through the caller's batch reader.
|
|
@@ -1442,7 +1572,7 @@ async function readJjFileAtCommit(input) {
|
|
|
1442
1572
|
"file",
|
|
1443
1573
|
"show",
|
|
1444
1574
|
"-r",
|
|
1445
|
-
input.commit,
|
|
1575
|
+
{ rev: input.commit },
|
|
1446
1576
|
"--ignore-working-copy",
|
|
1447
1577
|
"--",
|
|
1448
1578
|
toJjRootFilePattern(input.relativePath)
|
|
@@ -1467,9 +1597,6 @@ async function jjCommitIsConflicted(reader, commit) {
|
|
|
1467
1597
|
known.set(commit, probe);
|
|
1468
1598
|
return probe;
|
|
1469
1599
|
}
|
|
1470
|
-
function readFileAtRevisionForKind(input) {
|
|
1471
|
-
return input.kind === "jj" ? readJjFileAtRevisionSync(input) ?? (canUseGitFallbackSync(input.rootPath, input.kind) ? readGitFileAtRevisionSync(input) : null) : readGitFileAtRevisionSync(input) ?? readJjFileAtRevisionSync(input);
|
|
1472
|
-
}
|
|
1473
1600
|
async function diff(input) {
|
|
1474
1601
|
const vcs = await knownOrDetectedVcs(input.rootPath, input.kind);
|
|
1475
1602
|
if (!vcs) throw new Error(`No Git or jj repository found for ${input.rootPath}.`);
|
|
@@ -1518,7 +1645,7 @@ async function withWorkingTreeIndex(input, read) {
|
|
|
1518
1645
|
env.GIT_WORK_TREE = input.rootPath;
|
|
1519
1646
|
}
|
|
1520
1647
|
await fs.promises.mkdir(path.join(scratch, "objects"));
|
|
1521
|
-
const git = (args) =>
|
|
1648
|
+
const git = (args) => runVcs("git", [
|
|
1522
1649
|
"-c",
|
|
1523
1650
|
"core.splitIndex=false",
|
|
1524
1651
|
"-C",
|
|
@@ -1530,7 +1657,7 @@ async function withWorkingTreeIndex(input, read) {
|
|
|
1530
1657
|
maxBuffer: 33554432
|
|
1531
1658
|
});
|
|
1532
1659
|
if (input.kind === "git") {
|
|
1533
|
-
const index = (await
|
|
1660
|
+
const index = (await runVcs("git", [
|
|
1534
1661
|
"-C",
|
|
1535
1662
|
input.rootPath,
|
|
1536
1663
|
"rev-parse",
|
|
@@ -1600,7 +1727,7 @@ async function listCommitRange(input) {
|
|
|
1600
1727
|
const vcs = await knownOrDetectedVcs(input.rootPath, input.kind);
|
|
1601
1728
|
if (!vcs) throw new Error(`No Git or jj repository found for ${input.rootPath}.`);
|
|
1602
1729
|
try {
|
|
1603
|
-
const { stdout } = await
|
|
1730
|
+
const { stdout } = await runVcs("git", [
|
|
1604
1731
|
"-C",
|
|
1605
1732
|
vcs.rootPath,
|
|
1606
1733
|
"log",
|
|
@@ -1608,7 +1735,7 @@ async function listCommitRange(input) {
|
|
|
1608
1735
|
"--format=%H%x00%P%x00%an%x00%aI%x00%s%x00",
|
|
1609
1736
|
"--numstat",
|
|
1610
1737
|
"-z",
|
|
1611
|
-
`${input.baseRef}..${input.headRef}`
|
|
1738
|
+
{ rev: `${input.baseRef}..${input.headRef}` }
|
|
1612
1739
|
], {
|
|
1613
1740
|
cwd: vcs.rootPath,
|
|
1614
1741
|
maxBuffer: 26214400
|
|
@@ -1668,7 +1795,7 @@ async function readJjCommitRange(rootPath, baseRef, headRef) {
|
|
|
1668
1795
|
"log",
|
|
1669
1796
|
"--no-graph",
|
|
1670
1797
|
"-r",
|
|
1671
|
-
`::${headRef} ~ ::${baseRef}
|
|
1798
|
+
{ rev: `::${headRef} ~ ::${baseRef}` },
|
|
1672
1799
|
"-T",
|
|
1673
1800
|
"commit_id ++ \"\\0\" ++ parents.map(|p| p.commit_id()).join(\" \") ++ \"\\0\" ++ author.name() ++ \"\\0\" ++ author.timestamp().format(\"%+\") ++ \"\\0\" ++ description.first_line() ++ \"\\0\"",
|
|
1674
1801
|
"--ignore-working-copy"
|
|
@@ -1718,8 +1845,8 @@ async function diffFileSummariesTrees(input) {
|
|
|
1718
1845
|
});
|
|
1719
1846
|
}
|
|
1720
1847
|
async function diffForKind(input) {
|
|
1721
|
-
if (input.kind === "jj") return readJjDiff(input).catch((cause) => {
|
|
1722
|
-
if (!
|
|
1848
|
+
if (input.kind === "jj") return readJjDiff(input).catch(async (cause) => {
|
|
1849
|
+
if (!await canUseGitFallback(input.rootPath, input.kind)) throw cause;
|
|
1723
1850
|
return readGitDiff(input);
|
|
1724
1851
|
});
|
|
1725
1852
|
return readGitDiff(input).catch(() => readJjDiff(input));
|
|
@@ -1732,7 +1859,7 @@ async function diffFileSummariesForKind(input) {
|
|
|
1732
1859
|
};
|
|
1733
1860
|
let summaries;
|
|
1734
1861
|
if (input.kind === "jj") {
|
|
1735
|
-
if (
|
|
1862
|
+
if (await canUseGitFallback(input.rootPath, input.kind)) try {
|
|
1736
1863
|
summaries = await readGitDiffFileSummaries(unfilteredInput);
|
|
1737
1864
|
return filterDiffFileSummaries(summaries, requestedPaths);
|
|
1738
1865
|
} catch {}
|
|
@@ -1743,8 +1870,8 @@ async function diffFileSummariesForKind(input) {
|
|
|
1743
1870
|
return filterDiffFileSummaries(summaries, requestedPaths);
|
|
1744
1871
|
}
|
|
1745
1872
|
async function diffNameStatusForKind(input) {
|
|
1746
|
-
if (input.kind === "jj") return readJjDiffNameStatus(input).catch((cause) => {
|
|
1747
|
-
if (!
|
|
1873
|
+
if (input.kind === "jj") return readJjDiffNameStatus(input).catch(async (cause) => {
|
|
1874
|
+
if (!await canUseGitFallback(input.rootPath, input.kind)) throw cause;
|
|
1748
1875
|
return readGitDiffNameStatus(input);
|
|
1749
1876
|
});
|
|
1750
1877
|
return readGitDiffNameStatus(input).catch(() => readJjDiffNameStatus(input));
|
|
@@ -1841,7 +1968,7 @@ function toNameStatusEntries(summary) {
|
|
|
1841
1968
|
}))].sort((left, right) => left.path.localeCompare(right.path));
|
|
1842
1969
|
}
|
|
1843
1970
|
async function readGitDiffNameStatus(input) {
|
|
1844
|
-
const refRange = input.mergeBase === false ? [input.baseRef, input.headRef] : [`${input.baseRef}...${input.headRef}`];
|
|
1971
|
+
const refRange = input.mergeBase === false ? [{ rev: input.baseRef }, { rev: input.headRef }] : [{ rev: `${input.baseRef}...${input.headRef}` }];
|
|
1845
1972
|
return parseGitDiffNameStatus(await commandOutput("git", [
|
|
1846
1973
|
"-C",
|
|
1847
1974
|
input.rootPath,
|
|
@@ -1862,9 +1989,9 @@ async function readJjDiffNameStatus(input) {
|
|
|
1862
1989
|
"diff",
|
|
1863
1990
|
"--summary",
|
|
1864
1991
|
"--from",
|
|
1865
|
-
input.baseRef,
|
|
1992
|
+
{ rev: input.baseRef },
|
|
1866
1993
|
"--to",
|
|
1867
|
-
input.headRef,
|
|
1994
|
+
{ rev: input.headRef },
|
|
1868
1995
|
"--ignore-working-copy"
|
|
1869
1996
|
], {
|
|
1870
1997
|
cwd: input.rootPath,
|
|
@@ -1893,12 +2020,12 @@ async function defaultBranchCandidates(rootPath) {
|
|
|
1893
2020
|
async function resolveRevisionCommitByPreference(rootPath, revision, preferred) {
|
|
1894
2021
|
const primary = preferred === "jj" ? resolveJjRevisionCommit : resolveGitRevisionCommit;
|
|
1895
2022
|
const secondary = preferred === "jj" ? resolveGitRevisionCommit : resolveJjRevisionCommit;
|
|
1896
|
-
return await primary(rootPath, revision).catch(() => null) ?? (
|
|
2023
|
+
return await primary(rootPath, revision).catch(() => null) ?? (await canUseGitFallback(rootPath, preferred) ? await secondary(rootPath, revision).catch(() => null) : null);
|
|
1897
2024
|
}
|
|
1898
2025
|
async function mergeBaseByPreference(rootPath, baseRef, headRef, preferred) {
|
|
1899
2026
|
const primary = preferred === "jj" ? resolveJjMergeBase : resolveGitMergeBase;
|
|
1900
2027
|
const secondary = preferred === "jj" ? resolveGitMergeBase : resolveJjMergeBase;
|
|
1901
|
-
return await primary(rootPath, baseRef, headRef).catch(() => null) ?? (
|
|
2028
|
+
return await primary(rootPath, baseRef, headRef).catch(() => null) ?? (await canUseGitFallback(rootPath, preferred) ? await secondary(rootPath, baseRef, headRef).catch(() => null) : null);
|
|
1902
2029
|
}
|
|
1903
2030
|
async function resolveGitRevisionCommit(rootPath, revision) {
|
|
1904
2031
|
return commandOutput("git", [
|
|
@@ -1906,16 +2033,7 @@ async function resolveGitRevisionCommit(rootPath, revision) {
|
|
|
1906
2033
|
rootPath,
|
|
1907
2034
|
"rev-parse",
|
|
1908
2035
|
"--verify",
|
|
1909
|
-
`${revision}^{commit}`
|
|
1910
|
-
]);
|
|
1911
|
-
}
|
|
1912
|
-
function resolveGitRevisionCommitSync(rootPath, revision) {
|
|
1913
|
-
return commandOutputSync("git", [
|
|
1914
|
-
"-C",
|
|
1915
|
-
rootPath,
|
|
1916
|
-
"rev-parse",
|
|
1917
|
-
"--verify",
|
|
1918
|
-
`${revision}^{commit}`
|
|
2036
|
+
{ rev: `${revision}^{commit}` }
|
|
1919
2037
|
]);
|
|
1920
2038
|
}
|
|
1921
2039
|
async function resolveJjRevisionCommit(rootPath, revision) {
|
|
@@ -1925,26 +2043,12 @@ async function resolveJjRevisionCommit(rootPath, revision) {
|
|
|
1925
2043
|
"log",
|
|
1926
2044
|
"--no-graph",
|
|
1927
2045
|
"-r",
|
|
1928
|
-
revision,
|
|
2046
|
+
{ rev: revision },
|
|
1929
2047
|
"-T",
|
|
1930
2048
|
"commit_id ++ \"\\n\"",
|
|
1931
2049
|
"--ignore-working-copy"
|
|
1932
2050
|
], { cwd: rootPath }), revision);
|
|
1933
2051
|
}
|
|
1934
|
-
function resolveJjRevisionCommitSync(rootPath, revision) {
|
|
1935
|
-
const output = commandOutputSync("jj", [
|
|
1936
|
-
"-R",
|
|
1937
|
-
rootPath,
|
|
1938
|
-
"log",
|
|
1939
|
-
"--no-graph",
|
|
1940
|
-
"-r",
|
|
1941
|
-
revision,
|
|
1942
|
-
"-T",
|
|
1943
|
-
"commit_id ++ \"\\n\"",
|
|
1944
|
-
"--ignore-working-copy"
|
|
1945
|
-
], { cwd: rootPath });
|
|
1946
|
-
return output ? oneResolvedCommit(output, revision) : null;
|
|
1947
|
-
}
|
|
1948
2052
|
function oneResolvedCommit(output, revision) {
|
|
1949
2053
|
const commits = output.split("\n").filter(Boolean);
|
|
1950
2054
|
if (commits.length !== 1 || !/^[0-9a-f]{40}$/.test(commits[0])) throw new Error(`Revision ${revision} does not resolve to one Git commit.`);
|
|
@@ -1955,8 +2059,8 @@ async function resolveGitMergeBase(rootPath, baseRef, headRef) {
|
|
|
1955
2059
|
"-C",
|
|
1956
2060
|
rootPath,
|
|
1957
2061
|
"merge-base",
|
|
1958
|
-
baseRef,
|
|
1959
|
-
headRef
|
|
2062
|
+
{ rev: baseRef },
|
|
2063
|
+
{ rev: headRef }
|
|
1960
2064
|
]);
|
|
1961
2065
|
}
|
|
1962
2066
|
async function resolveJjMergeBase(rootPath, baseRef, headRef) {
|
|
@@ -1966,56 +2070,16 @@ async function resolveJjMergeBase(rootPath, baseRef, headRef) {
|
|
|
1966
2070
|
"log",
|
|
1967
2071
|
"--no-graph",
|
|
1968
2072
|
"-r",
|
|
1969
|
-
`heads(::${baseRef} & ::${headRef})
|
|
2073
|
+
{ rev: `heads(::${baseRef} & ::${headRef})` },
|
|
1970
2074
|
"-T",
|
|
1971
2075
|
"commit_id ++ \"\n\"",
|
|
1972
2076
|
"--ignore-working-copy"
|
|
1973
2077
|
], { cwd: rootPath }))[0] ?? null;
|
|
1974
2078
|
}
|
|
1975
|
-
function readGitFileAtRevisionSync(input) {
|
|
1976
|
-
const commit = resolveGitRevisionCommitSync(input.rootPath, input.ref);
|
|
1977
|
-
if (!commit) return null;
|
|
1978
|
-
const source = commandOutputSync("git", [
|
|
1979
|
-
"-C",
|
|
1980
|
-
input.rootPath,
|
|
1981
|
-
"show",
|
|
1982
|
-
`${commit}:${input.relativePath}`
|
|
1983
|
-
], {
|
|
1984
|
-
maxBuffer: 10485760,
|
|
1985
|
-
trim: false
|
|
1986
|
-
});
|
|
1987
|
-
return source === null ? null : {
|
|
1988
|
-
commit,
|
|
1989
|
-
source
|
|
1990
|
-
};
|
|
1991
|
-
}
|
|
1992
|
-
function readJjFileAtRevisionSync(input) {
|
|
1993
|
-
const commit = resolveJjRevisionCommitSync(input.rootPath, input.ref);
|
|
1994
|
-
if (!commit) return null;
|
|
1995
|
-
const source = commandOutputSync("jj", [
|
|
1996
|
-
"-R",
|
|
1997
|
-
input.rootPath,
|
|
1998
|
-
"file",
|
|
1999
|
-
"show",
|
|
2000
|
-
"-r",
|
|
2001
|
-
input.ref,
|
|
2002
|
-
"--ignore-working-copy",
|
|
2003
|
-
"--",
|
|
2004
|
-
toJjRootFilePattern(input.relativePath)
|
|
2005
|
-
], {
|
|
2006
|
-
cwd: input.rootPath,
|
|
2007
|
-
maxBuffer: 10485760,
|
|
2008
|
-
trim: false
|
|
2009
|
-
});
|
|
2010
|
-
return source === null ? null : {
|
|
2011
|
-
commit,
|
|
2012
|
-
source
|
|
2013
|
-
};
|
|
2014
|
-
}
|
|
2015
2079
|
async function readGitDiff(input) {
|
|
2016
2080
|
const paths = input.literalPaths ? input.paths ?? [] : normalizeDiffPaths(input.paths);
|
|
2017
|
-
const diffRefs = input.headRef ? input.mergeBase === false ? [input.baseRef, input.headRef] : [`${input.baseRef}...${input.headRef}`] : [input.baseRef];
|
|
2018
|
-
const { stdout } = await
|
|
2081
|
+
const diffRefs = input.headRef ? input.mergeBase === false ? [{ rev: input.baseRef }, { rev: input.headRef }] : [{ rev: `${input.baseRef}...${input.headRef}` }] : [{ rev: input.baseRef }];
|
|
2082
|
+
const { stdout } = await runVcs("git", [
|
|
2019
2083
|
...input.literalPaths ? ["--literal-pathspecs"] : [],
|
|
2020
2084
|
"-C",
|
|
2021
2085
|
input.rootPath,
|
|
@@ -2038,8 +2102,8 @@ async function readGitDiff(input) {
|
|
|
2038
2102
|
}
|
|
2039
2103
|
async function readGitDiffFileSummaries(input) {
|
|
2040
2104
|
const paths = normalizeDiffPaths(input.paths);
|
|
2041
|
-
const diffRefs = input.headRef ? input.mergeBase === false ? [input.baseRef, input.headRef] : [`${input.baseRef}...${input.headRef}`] : [input.baseRef];
|
|
2042
|
-
const { stdout } = await
|
|
2105
|
+
const diffRefs = input.headRef ? input.mergeBase === false ? [{ rev: input.baseRef }, { rev: input.headRef }] : [{ rev: `${input.baseRef}...${input.headRef}` }] : [{ rev: input.baseRef }];
|
|
2106
|
+
const { stdout } = await runVcs("git", [
|
|
2043
2107
|
"-C",
|
|
2044
2108
|
input.rootPath,
|
|
2045
2109
|
"diff",
|
|
@@ -2062,7 +2126,7 @@ async function readGitDiffFileSummaries(input) {
|
|
|
2062
2126
|
}
|
|
2063
2127
|
async function readJjDiff(input) {
|
|
2064
2128
|
const paths = input.literalPaths ? input.paths ?? [] : normalizeDiffPaths(input.paths);
|
|
2065
|
-
const { stdout } = await
|
|
2129
|
+
const { stdout } = await runVcs("jj", [
|
|
2066
2130
|
"-R",
|
|
2067
2131
|
input.rootPath,
|
|
2068
2132
|
"--color",
|
|
@@ -2266,16 +2330,6 @@ async function canUseGitFallback(rootPath, preferred) {
|
|
|
2266
2330
|
], { cwd: rootPath }).catch(() => null);
|
|
2267
2331
|
return gitRoot !== null && canonicalPath(gitRoot) === canonicalPath(rootPath);
|
|
2268
2332
|
}
|
|
2269
|
-
function canUseGitFallbackSync(rootPath, preferred) {
|
|
2270
|
-
if (preferred !== "jj") return true;
|
|
2271
|
-
const gitRoot = commandOutputSync("git", [
|
|
2272
|
-
"-C",
|
|
2273
|
-
rootPath,
|
|
2274
|
-
"rev-parse",
|
|
2275
|
-
"--show-toplevel"
|
|
2276
|
-
], { cwd: rootPath });
|
|
2277
|
-
return gitRoot !== null && canonicalPath(gitRoot) === canonicalPath(rootPath);
|
|
2278
|
-
}
|
|
2279
2333
|
function isInsideDirectory(filePath, directoryPath) {
|
|
2280
2334
|
const relative = path.relative(canonicalPath(directoryPath), canonicalPath(filePath));
|
|
2281
2335
|
return relative === "" || !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
@@ -2294,18 +2348,16 @@ function commandOutputSync(command, args, options = {}) {
|
|
|
2294
2348
|
return runCommandOutputSync(command, args, options);
|
|
2295
2349
|
}
|
|
2296
2350
|
function runCommandOutput(command, args, options) {
|
|
2297
|
-
return
|
|
2351
|
+
return runVcs(command, args, {
|
|
2298
2352
|
cwd: options.cwd,
|
|
2299
|
-
env: commandEnvironment(command, args),
|
|
2300
2353
|
maxBuffer: options.maxBuffer
|
|
2301
2354
|
}).then(({ stdout }) => options.trim === false ? stdout : stdout.trim());
|
|
2302
2355
|
}
|
|
2303
2356
|
function runCommandOutputSync(command, args, options) {
|
|
2304
2357
|
try {
|
|
2305
|
-
const output =
|
|
2358
|
+
const output = runVcsSync(command, args, {
|
|
2306
2359
|
cwd: options.cwd,
|
|
2307
2360
|
encoding: "utf8",
|
|
2308
|
-
env: commandEnvironment(command, args),
|
|
2309
2361
|
maxBuffer: options.maxBuffer,
|
|
2310
2362
|
stdio: [
|
|
2311
2363
|
"ignore",
|
|
@@ -2318,16 +2370,6 @@ function runCommandOutputSync(command, args, options) {
|
|
|
2318
2370
|
return null;
|
|
2319
2371
|
}
|
|
2320
2372
|
}
|
|
2321
|
-
function commandEnvironment(command, args) {
|
|
2322
|
-
if (command !== "git" || args[0] !== "-C" && args[0] !== "--git-dir") return;
|
|
2323
|
-
return localGitEnvironment();
|
|
2324
|
-
}
|
|
2325
|
-
/** Drop per-repository git env vars that would redirect an explicit object store. */
|
|
2326
|
-
function localGitEnvironment() {
|
|
2327
|
-
const env = { ...process.env };
|
|
2328
|
-
for (const key of LOCAL_GIT_ENV_KEYS) delete env[key];
|
|
2329
|
-
return env;
|
|
2330
|
-
}
|
|
2331
2373
|
//#endregion
|
|
2332
2374
|
//#region ../../node_modules/graceful-fs/polyfills.js
|
|
2333
2375
|
var require_polyfills = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
@@ -3678,4 +3720,4 @@ var require_adapter = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3678
3720
|
module.exports.checkSync = checkSync;
|
|
3679
3721
|
})))();
|
|
3680
3722
|
//#endregion
|
|
3681
|
-
export {
|
|
3723
|
+
export { renderVcsArgs as C, __commonJSMin as D, setLocalVcsCommandObserver as E, __require as O, splitGitPatchFiles as S, runVcsSync as T, listTrackedFilesAtCommit as _, diff as a, resolveRepoContext as b, diffFileSummariesWorkingTree as c, git as d, gitAt as f, listCommitRange as g, jjRevisionIsConflicted as h, detectLocalVcs as i, __toESM as k, diffTrees as l, gitCommonDirSync as m, createBlobBatchReader as n, diffFileSummaries as o, gitCommonDir as p, defaultBranch as r, diffFileSummariesTrees as s, LocalVcsToolsMissingError as t, diffWorkingTree as u, parseGitRemote as v, runVcs as w, resolveRevision as x, readFileAtCommit as y };
|