@workit-dev/pi 2.28.0 → 2.29.0
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/worker.js +83 -14
- package/dist/workit.js +55 -19
- package/package.json +1 -1
package/dist/worker.js
CHANGED
|
@@ -5860,12 +5860,13 @@ var COMMIT_PRESETS = [
|
|
|
5860
5860
|
];
|
|
5861
5861
|
|
|
5862
5862
|
// packages/workit-core/src/core/workspaces.ts
|
|
5863
|
-
import { spawnSync as
|
|
5863
|
+
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
5864
5864
|
import { existsSync as existsSync3, lstatSync as lstatSync3, readFileSync as readFileSync3, realpathSync as realpathSync4 } from "node:fs";
|
|
5865
5865
|
import path6 from "node:path";
|
|
5866
5866
|
|
|
5867
5867
|
// packages/workit-core/src/core/remotes.ts
|
|
5868
5868
|
import { lstatSync as lstatSync2, readFileSync as readFileSync2, realpathSync as realpathSync3, statSync } from "node:fs";
|
|
5869
|
+
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
5869
5870
|
import path5 from "node:path";
|
|
5870
5871
|
|
|
5871
5872
|
// packages/workit-core/src/git/rev.ts
|
|
@@ -6413,6 +6414,51 @@ var remotePattern = (pattern) => {
|
|
|
6413
6414
|
const key = remoteKey(owner ? trimmed.slice(0, -2) : trimmed);
|
|
6414
6415
|
return key ? { key, owner } : null;
|
|
6415
6416
|
};
|
|
6417
|
+
var remoteMatches = (pattern, key) => {
|
|
6418
|
+
const parsed = remotePattern(pattern);
|
|
6419
|
+
if (!parsed)
|
|
6420
|
+
return false;
|
|
6421
|
+
return parsed.owner ? key.startsWith(`${parsed.key}/`) : key === parsed.key;
|
|
6422
|
+
};
|
|
6423
|
+
var checkoutRemotes = (cwd) => {
|
|
6424
|
+
const env = { ...process.env };
|
|
6425
|
+
for (const name of ["GIT_DIR", "GIT_WORK_TREE", "GIT_COMMON_DIR", "GIT_INDEX_FILE"])
|
|
6426
|
+
delete env[name];
|
|
6427
|
+
const git = (args) => spawnSync4("git", args, {
|
|
6428
|
+
cwd,
|
|
6429
|
+
env,
|
|
6430
|
+
encoding: "utf8",
|
|
6431
|
+
timeout: 5000,
|
|
6432
|
+
windowsHide: true
|
|
6433
|
+
});
|
|
6434
|
+
const listed = git(["remote", "-v"]);
|
|
6435
|
+
if (listed.status !== 0) {
|
|
6436
|
+
if (/not a git repository/iu.test(listed.stderr ?? ""))
|
|
6437
|
+
return [];
|
|
6438
|
+
return Error(`git could not list the remotes of ${cwd}`);
|
|
6439
|
+
}
|
|
6440
|
+
let top;
|
|
6441
|
+
const base = () => {
|
|
6442
|
+
if (top === undefined) {
|
|
6443
|
+
const run = git(["rev-parse", "--show-toplevel"]);
|
|
6444
|
+
top = run.status === 0 && run.stdout.trim() ? run.stdout.trim() : cwd;
|
|
6445
|
+
}
|
|
6446
|
+
return top;
|
|
6447
|
+
};
|
|
6448
|
+
const out = [];
|
|
6449
|
+
for (const line of listed.stdout.split(/\r?\n/u)) {
|
|
6450
|
+
const match = /^([^\t]+)\t(.*) \((?:fetch|push)\)$/u.exec(line);
|
|
6451
|
+
if (!match)
|
|
6452
|
+
continue;
|
|
6453
|
+
const [, name, url] = match;
|
|
6454
|
+
const key = remoteKey(url, base);
|
|
6455
|
+
if (key === null)
|
|
6456
|
+
return Error(`remote ${name} of ${cwd} has a URL workit cannot read: ${url}`);
|
|
6457
|
+
if (!out.some((item) => item.key === key))
|
|
6458
|
+
out.push({ name, url, key });
|
|
6459
|
+
}
|
|
6460
|
+
return out;
|
|
6461
|
+
};
|
|
6416
6462
|
|
|
6417
6463
|
// packages/workit-core/src/core/workspaces.ts
|
|
6418
6464
|
var nonBlank = string2().check(refine((value) => value.trim().length > 0, "must not be blank"));
|
|
@@ -6520,7 +6566,7 @@ var workspaceConfigSchema = looseObject({
|
|
|
6520
6566
|
})),
|
|
6521
6567
|
models: optional(looseObject({ roles: modelRoles })),
|
|
6522
6568
|
resources: optional(unknown()),
|
|
6523
|
-
remotes: optional(array(nonBlank.check(refine((pattern) =>
|
|
6569
|
+
remotes: optional(array(nonBlank.check(refine((pattern) => isRemotePattern(pattern), "is not a remote URL (https://host/owner/repo, git@host:owner/repo, a path, or owner/*)")))),
|
|
6524
6570
|
externalRepos: optional(array(nonBlank.check(_regex(/^[\w-]+(?:\/\w[\w.-]*)*\/(?:\w[\w.-]*|\*)$/u, "is owner/name, group/project or owner/* on the checkout's forge host, without the host")))),
|
|
6525
6571
|
additiveRiskPaths: optional(array(nonBlank)),
|
|
6526
6572
|
autonomy: optional(looseObject(Object.fromEntries(["push", "pr", "merge", "release", "rerun"].map((kind) => [
|
|
@@ -6665,7 +6711,7 @@ var probeCheckout = (cwd) => {
|
|
|
6665
6711
|
for (const name of ["GIT_DIR", "GIT_WORK_TREE", "GIT_COMMON_DIR", "GIT_INDEX_FILE"])
|
|
6666
6712
|
delete env[name];
|
|
6667
6713
|
const git = (args) => {
|
|
6668
|
-
const run =
|
|
6714
|
+
const run = spawnSync5("git", args, {
|
|
6669
6715
|
cwd,
|
|
6670
6716
|
env,
|
|
6671
6717
|
encoding: "utf8",
|
|
@@ -6812,6 +6858,27 @@ var selectWorkspaceMatch = (matches, cwd, workspaceName) => {
|
|
|
6812
6858
|
}
|
|
6813
6859
|
return mostSpecific[0];
|
|
6814
6860
|
};
|
|
6861
|
+
var HOSTLESS_REMOTE = /^[\w-]+\/\*$/u;
|
|
6862
|
+
var expandRemotePattern = (entry, pattern) => {
|
|
6863
|
+
if (!HOSTLESS_REMOTE.test(pattern.trim()))
|
|
6864
|
+
return pattern;
|
|
6865
|
+
const vcs = entry.vcs ?? {};
|
|
6866
|
+
const host = typeof vcs.host === "string" && vcs.host.trim().replace(/^https?:\/\/|\/.*$/giu, "") || `${vcs.provider === "gitlab" ? "gitlab" : "github"}.com`;
|
|
6867
|
+
return `https://${host}/${pattern.trim()}`;
|
|
6868
|
+
};
|
|
6869
|
+
var isRemotePattern = (pattern) => !!remotePattern(expandRemotePattern({}, pattern));
|
|
6870
|
+
var remoteClaimOf = (entry, key, exact = false) => (Array.isArray(entry.remotes) ? entry.remotes : []).find((pattern) => typeof pattern === "string" && !(exact && pattern.trim().endsWith("/*")) && remoteMatches(expandRemotePattern(entry, pattern), key));
|
|
6871
|
+
var resolveWorkspaceFromEntries = (cwd, entries, workspaceName, remotes) => {
|
|
6872
|
+
const globbed = matchingEntries(cwd, entries);
|
|
6873
|
+
const listed = !remotes || globbed.length || !entries.some((entry) => entry.remotes) ? [] : checkoutRemotes(cwd);
|
|
6874
|
+
const origin = listed instanceof Error ? [] : listed.filter((item) => item.name === "origin");
|
|
6875
|
+
const hits = entries.filter((entry) => origin.length && origin.every((item) => remoteClaimOf(entry, item.key)));
|
|
6876
|
+
const exact = hits.filter((entry) => origin.every((item) => remoteClaimOf(entry, item.key, true)));
|
|
6877
|
+
const ranked = exact.length ? exact : hits;
|
|
6878
|
+
if (workspaceName === undefined && ranked.length > 1)
|
|
6879
|
+
return null;
|
|
6880
|
+
return selectWorkspaceMatch(hits.length ? workspaceName ? hits : ranked : globbed, cwd, workspaceName) ?? null;
|
|
6881
|
+
};
|
|
6815
6882
|
var runtimeWorkspaceIndexSchema = looseObject({
|
|
6816
6883
|
workspaces: optional(array(looseObject({ name: nonBlank, glob: nonBlank })))
|
|
6817
6884
|
});
|
|
@@ -6842,10 +6909,12 @@ var matchRuntimeWorkspace = (cwd, dir = configDir2()) => {
|
|
|
6842
6909
|
if (!glob.ok)
|
|
6843
6910
|
throw new WorkspaceConfigError(`${file} workspace ${entry.name}: ${glob.error}`);
|
|
6844
6911
|
}
|
|
6845
|
-
const matches = matchingEntries(cwd, entries ?? []);
|
|
6846
6912
|
const workspaceName = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
|
|
6847
|
-
const selected =
|
|
6848
|
-
|
|
6913
|
+
const selected = resolveWorkspaceFromEntries(cwd, entries ?? [], workspaceName, true);
|
|
6914
|
+
if (!selected)
|
|
6915
|
+
return null;
|
|
6916
|
+
const matches = matchingEntries(cwd, entries ?? []);
|
|
6917
|
+
return { file, selected, matches: matches.length ? matches : [selected] };
|
|
6849
6918
|
};
|
|
6850
6919
|
var modelSources = (cwd, dir) => {
|
|
6851
6920
|
const out = [];
|
|
@@ -7259,12 +7328,12 @@ Merge them by hand (cp -Rn ${workit}/. ${target}/), then delete them here.
|
|
|
7259
7328
|
}
|
|
7260
7329
|
|
|
7261
7330
|
// packages/workit-core/src/store/paths.ts
|
|
7262
|
-
import { spawnSync as
|
|
7331
|
+
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
7263
7332
|
import fs5 from "node:fs";
|
|
7264
7333
|
import path8 from "node:path";
|
|
7265
7334
|
var NOT_A_REPO = /not a git repository \(or any (of the parent directories|parent up to)/u;
|
|
7266
7335
|
var gitRun = (cwd, args) => {
|
|
7267
|
-
const run =
|
|
7336
|
+
const run = spawnSync6("git", args, {
|
|
7268
7337
|
cwd,
|
|
7269
7338
|
encoding: "utf8",
|
|
7270
7339
|
timeout: 20000,
|
|
@@ -7486,7 +7555,7 @@ var assetRoot = () => {
|
|
|
7486
7555
|
};
|
|
7487
7556
|
|
|
7488
7557
|
// packages/workit-core/src/core/store-lock.ts
|
|
7489
|
-
import { spawnSync as
|
|
7558
|
+
import { spawnSync as spawnSync7 } from "node:child_process";
|
|
7490
7559
|
import fs6 from "node:fs";
|
|
7491
7560
|
var metadataLockSchema = strictObject({
|
|
7492
7561
|
pid: number2().check(int(), _nonnegative(), int()),
|
|
@@ -7511,7 +7580,7 @@ var readProcStat = (pid) => {
|
|
|
7511
7580
|
};
|
|
7512
7581
|
var psStart = (pid) => {
|
|
7513
7582
|
try {
|
|
7514
|
-
const run =
|
|
7583
|
+
const run = spawnSync7("ps", ["-o", "lstart=", "-p", String(pid)], {
|
|
7515
7584
|
encoding: "utf8",
|
|
7516
7585
|
timeout: 1000,
|
|
7517
7586
|
env: { ...process.env, LC_ALL: "C" }
|
|
@@ -7598,7 +7667,7 @@ var PM_RUN = new Set(["run", "run-script"]);
|
|
|
7598
7667
|
var PYTHON_RUNNERS = new Set(["uv", "poetry", "pipenv", "pdm", "hatch", "rye"]);
|
|
7599
7668
|
|
|
7600
7669
|
// packages/workit-core/src/ledger.ts
|
|
7601
|
-
import { spawnSync as
|
|
7670
|
+
import { spawnSync as spawnSync8 } from "node:child_process";
|
|
7602
7671
|
import { createHash as createHash4, randomBytes } from "node:crypto";
|
|
7603
7672
|
import fs8 from "node:fs";
|
|
7604
7673
|
import path11 from "node:path";
|
|
@@ -7778,7 +7847,7 @@ var err = (code, error, unblock) => ({
|
|
|
7778
7847
|
...unblock ? { unblock } : {}
|
|
7779
7848
|
});
|
|
7780
7849
|
var gitRun2 = (cwd, args, timeoutMs = GIT_TIMEOUTS.local) => {
|
|
7781
|
-
const run =
|
|
7850
|
+
const run = spawnSync8("git", args, {
|
|
7782
7851
|
cwd,
|
|
7783
7852
|
encoding: "utf8",
|
|
7784
7853
|
timeout: timeoutMs,
|
|
@@ -9988,11 +10057,11 @@ var READ_CMDLETS = new Set([
|
|
|
9988
10057
|
import path14 from "node:path";
|
|
9989
10058
|
|
|
9990
10059
|
// packages/workit-core/src/core/live-session.ts
|
|
9991
|
-
import { spawnSync as
|
|
10060
|
+
import { spawnSync as spawnSync9 } from "node:child_process";
|
|
9992
10061
|
var LIVE_SESSION_TTL_MS = 15 * 60000;
|
|
9993
10062
|
var liveProbe = {
|
|
9994
10063
|
platform: process.platform,
|
|
9995
|
-
run: (args) =>
|
|
10064
|
+
run: (args) => spawnSync9("ps", args, { encoding: "utf8", timeout: 2000 }).stdout ?? "",
|
|
9996
10065
|
start: (pid) => processStartOf(pid)
|
|
9997
10066
|
};
|
|
9998
10067
|
var PIDS = new Map;
|
package/dist/workit.js
CHANGED
|
@@ -8474,7 +8474,7 @@ var workspaceConfigSchema = looseObject({
|
|
|
8474
8474
|
})),
|
|
8475
8475
|
models: optional(looseObject({ roles: modelRoles })),
|
|
8476
8476
|
resources: optional(unknown()),
|
|
8477
|
-
remotes: optional(array(nonBlank.check(refine((pattern) =>
|
|
8477
|
+
remotes: optional(array(nonBlank.check(refine((pattern) => isRemotePattern(pattern), "is not a remote URL (https://host/owner/repo, git@host:owner/repo, a path, or owner/*)")))),
|
|
8478
8478
|
externalRepos: optional(array(nonBlank.check(_regex(/^[\w-]+(?:\/\w[\w.-]*)*\/(?:\w[\w.-]*|\*)$/u, "is owner/name, group/project or owner/* on the checkout's forge host, without the host")))),
|
|
8479
8479
|
additiveRiskPaths: optional(array(nonBlank)),
|
|
8480
8480
|
autonomy: optional(looseObject(Object.fromEntries(["push", "pr", "merge", "release", "rerun"].map((kind) => [
|
|
@@ -8843,6 +8843,7 @@ var canonicalGlob = (glob) => {
|
|
|
8843
8843
|
return real + (prefix.endsWith("/") ? "/" : "") + rest;
|
|
8844
8844
|
};
|
|
8845
8845
|
var globSpecificity = (glob) => glob.replaceAll("\\", "/").split("/").filter((segment) => segment.length > 0 && !/[*?[\]{]/.test(segment)).length;
|
|
8846
|
+
var workspaceMatches = (cwd, entries) => matchingEntries(cwd, entries);
|
|
8846
8847
|
var selectWorkspaceMatch = (matches, cwd, workspaceName) => {
|
|
8847
8848
|
if (workspaceName !== undefined) {
|
|
8848
8849
|
const named = matches.filter((entry) => entry.name === workspaceName);
|
|
@@ -8864,15 +8865,32 @@ var selectWorkspaceMatch = (matches, cwd, workspaceName) => {
|
|
|
8864
8865
|
}
|
|
8865
8866
|
return mostSpecific[0];
|
|
8866
8867
|
};
|
|
8867
|
-
var
|
|
8868
|
-
|
|
8869
|
-
|
|
8870
|
-
|
|
8871
|
-
|
|
8868
|
+
var HOSTLESS_REMOTE = /^[\w-]+\/\*$/u;
|
|
8869
|
+
var expandRemotePattern = (entry, pattern) => {
|
|
8870
|
+
if (!HOSTLESS_REMOTE.test(pattern.trim()))
|
|
8871
|
+
return pattern;
|
|
8872
|
+
const vcs = entry.vcs ?? {};
|
|
8873
|
+
const host = typeof vcs.host === "string" && vcs.host.trim().replace(/^https?:\/\/|\/.*$/giu, "") || `${vcs.provider === "gitlab" ? "gitlab" : "github"}.com`;
|
|
8874
|
+
return `https://${host}/${pattern.trim()}`;
|
|
8875
|
+
};
|
|
8876
|
+
var isRemotePattern = (pattern) => !!remotePattern(expandRemotePattern({}, pattern));
|
|
8877
|
+
var remoteClaimOf = (entry, key, exact = false) => (Array.isArray(entry.remotes) ? entry.remotes : []).find((pattern) => typeof pattern === "string" && !(exact && pattern.trim().endsWith("/*")) && remoteMatches(expandRemotePattern(entry, pattern), key));
|
|
8878
|
+
var resolveWorkspaceFromEntries = (cwd, entries, workspaceName, remotes) => {
|
|
8879
|
+
const globbed = matchingEntries(cwd, entries);
|
|
8880
|
+
const listed = !remotes || globbed.length || !entries.some((entry) => entry.remotes) ? [] : checkoutRemotes(cwd);
|
|
8881
|
+
const origin = listed instanceof Error ? [] : listed.filter((item) => item.name === "origin");
|
|
8882
|
+
const hits = entries.filter((entry) => origin.length && origin.every((item) => remoteClaimOf(entry, item.key)));
|
|
8883
|
+
const exact = hits.filter((entry) => origin.every((item) => remoteClaimOf(entry, item.key, true)));
|
|
8884
|
+
const ranked = exact.length ? exact : hits;
|
|
8885
|
+
if (workspaceName === undefined && ranked.length > 1)
|
|
8886
|
+
return null;
|
|
8887
|
+
return selectWorkspaceMatch(hits.length ? workspaceName ? hits : ranked : globbed, cwd, workspaceName) ?? null;
|
|
8888
|
+
};
|
|
8889
|
+
var resolveWorkspaceFrom = (cwd, dir, workspaceName, remotes) => {
|
|
8872
8890
|
const result = readWorkspacesResult(dir);
|
|
8873
8891
|
if (result.status === "malformed" || result.status === "invalid")
|
|
8874
8892
|
throw new WorkspaceConfigError(result.error);
|
|
8875
|
-
return resolveWorkspaceFromEntries(cwd, result.entries, workspaceName);
|
|
8893
|
+
return resolveWorkspaceFromEntries(cwd, result.entries, workspaceName, remotes);
|
|
8876
8894
|
};
|
|
8877
8895
|
var runtimeWorkspacePolicySchema = (kind) => {
|
|
8878
8896
|
const key = kind === "branch" ? "branchPolicy" : kind === "commit" ? "commitPolicy" : "vcs";
|
|
@@ -8922,10 +8940,12 @@ var matchRuntimeWorkspace = (cwd, dir = configDir2()) => {
|
|
|
8922
8940
|
if (!glob.ok)
|
|
8923
8941
|
throw new WorkspaceConfigError(`${file} workspace ${entry.name}: ${glob.error}`);
|
|
8924
8942
|
}
|
|
8925
|
-
const matches = matchingEntries(cwd, entries ?? []);
|
|
8926
8943
|
const workspaceName = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
|
|
8927
|
-
const selected =
|
|
8928
|
-
|
|
8944
|
+
const selected = resolveWorkspaceFromEntries(cwd, entries ?? [], workspaceName, true);
|
|
8945
|
+
if (!selected)
|
|
8946
|
+
return null;
|
|
8947
|
+
const matches = matchingEntries(cwd, entries ?? []);
|
|
8948
|
+
return { file, selected, matches: matches.length ? matches : [selected] };
|
|
8929
8949
|
};
|
|
8930
8950
|
var resolveRuntimeReleaseTracks = (cwd) => {
|
|
8931
8951
|
const matched = matchRuntimeWorkspace(cwd);
|
|
@@ -19072,6 +19092,7 @@ var youTrackHostAllowed = (allowed, host) => {
|
|
|
19072
19092
|
var YTRACK_MISSING = "ytrack is not on PATH: Workit reaches YouTrack only through ytrack";
|
|
19073
19093
|
|
|
19074
19094
|
// packages/workit-core/src/autonomy.ts
|
|
19095
|
+
var resolveWorkspaceFrom2 = (cwd, dir, name) => resolveWorkspaceFrom(cwd, dir, name, true);
|
|
19075
19096
|
var accountHomeDir = () => {
|
|
19076
19097
|
const home = grantsHome.resolve();
|
|
19077
19098
|
return home === null ? null : configDir({ HOME: home });
|
|
@@ -19104,11 +19125,11 @@ var accountUnread = () => {
|
|
|
19104
19125
|
};
|
|
19105
19126
|
var entriesIn = (dir) => dir === null ? [] : loadWorkspacesFrom(dir);
|
|
19106
19127
|
var fileSource = (dir = accountDir()) => ({
|
|
19107
|
-
resolve: (cwd, name) => dir === null ? null :
|
|
19128
|
+
resolve: (cwd, name) => dir === null ? null : resolveWorkspaceFrom2(cwd, dir, name),
|
|
19108
19129
|
entries: () => entriesIn(dir)
|
|
19109
19130
|
});
|
|
19110
19131
|
var sealedSource = (entries) => ({
|
|
19111
|
-
resolve: (cwd, name) => resolveWorkspaceFromEntries(cwd, entries, name),
|
|
19132
|
+
resolve: (cwd, name) => resolveWorkspaceFromEntries(cwd, entries, name, true),
|
|
19112
19133
|
entries: () => entries
|
|
19113
19134
|
});
|
|
19114
19135
|
var sealOf = () => {
|
|
@@ -19134,8 +19155,8 @@ var youTrackWritesPolicy = (cwd) => {
|
|
|
19134
19155
|
return ASK;
|
|
19135
19156
|
const auto = (entry) => youtrackOf(entry)?.writes === "auto";
|
|
19136
19157
|
const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
|
|
19137
|
-
const named =
|
|
19138
|
-
const folder = name ?
|
|
19158
|
+
const named = resolveWorkspaceFrom2(cwd, dir, name);
|
|
19159
|
+
const folder = name ? resolveWorkspaceFrom2(cwd, dir) : named;
|
|
19139
19160
|
if (!auto(named) || !auto(folder))
|
|
19140
19161
|
return ASK;
|
|
19141
19162
|
const [a, b] = [autoHostsOf(named), autoHostsOf(folder)];
|
|
@@ -19396,7 +19417,8 @@ function resolveWith(source, cwd, world, target) {
|
|
|
19396
19417
|
const above = checkoutsAbove(cwd);
|
|
19397
19418
|
for (const where of above instanceof Error ? [above] : above)
|
|
19398
19419
|
autonomy = capAt(source, autonomy, where, where instanceof Error ? "git" : `checkout ${where}`, "a worktree or submodule never exceeds it", true);
|
|
19399
|
-
|
|
19420
|
+
const own = real && workspaceMatches(cwd, source.entries()).length === 0 ? real : undefined;
|
|
19421
|
+
return capAtRemotes(source, autonomy, cwd, target, own);
|
|
19400
19422
|
}
|
|
19401
19423
|
var needsAccount = (autonomy) => autonomy.configured.length > 0 && !autonomy.accountConfigured;
|
|
19402
19424
|
function stricter(current, sealed, note, unblock) {
|
|
@@ -19435,17 +19457,31 @@ function stricter(current, sealed, note, unblock) {
|
|
|
19435
19457
|
note: current.note ? `${current.note}; ${note}` : note
|
|
19436
19458
|
};
|
|
19437
19459
|
}
|
|
19438
|
-
function capAtRemotes(source, autonomy, cwd, target) {
|
|
19460
|
+
function capAtRemotes(source, autonomy, cwd, target, own) {
|
|
19439
19461
|
const claiming = source.entries().filter((entry) => entry.remotes?.length);
|
|
19440
19462
|
if (claiming.length === 0)
|
|
19441
19463
|
return autonomy;
|
|
19442
19464
|
const remotes = target === undefined ? checkoutRemotes(cwd) : typeof target === "function" ? target() : target;
|
|
19443
19465
|
if (remotes instanceof Error)
|
|
19444
19466
|
return capAt(source, autonomy, remotes, target === undefined ? "git" : "target", "a target that cannot be resolved never raises grants");
|
|
19467
|
+
const listed = Array.isArray(remotes) ? remotes : remotes.remotes;
|
|
19468
|
+
const capped = own ? capAtOwnClaim(source, autonomy, cwd, own, target && listed) : autonomy;
|
|
19469
|
+
return capAtClaims(source, capped, listed, claiming);
|
|
19470
|
+
}
|
|
19471
|
+
function capAtOwnClaim(source, autonomy, cwd, own, judged) {
|
|
19472
|
+
const push = judged ? { remotes: judged } : pushTarget(cwd, pushRemoteName(cwd) ?? "");
|
|
19473
|
+
if (push instanceof Error)
|
|
19474
|
+
return capAt(source, autonomy, push, "push target", "a target that cannot be resolved never raises grants");
|
|
19475
|
+
const unclaimed = push.remotes.filter((remote) => !remoteClaimOf(own, remote.key));
|
|
19476
|
+
if (unclaimed.length === 0 && push.remotes.length > 0)
|
|
19477
|
+
return autonomy;
|
|
19478
|
+
return stricter(autonomy, autonomyOf(null), `${unclaimed.map((remote) => `remote ${remote.name} ${remote.url}`).join(", ") || "no target"}: not in workspace ${own.name}'s remotes, which matched this checkout by its origin; grants capped at the defaults`, `ask the user to add that repository to workspace ${own.name}'s remotes, in their own terminal: workit workspace set ${own.name} remotes=<patterns>`);
|
|
19479
|
+
}
|
|
19480
|
+
function capAtClaims(source, autonomy, listed, claiming) {
|
|
19445
19481
|
let capped = autonomy;
|
|
19446
|
-
for (const remote of
|
|
19482
|
+
for (const remote of listed)
|
|
19447
19483
|
for (const entry of claiming) {
|
|
19448
|
-
const pattern = entry
|
|
19484
|
+
const pattern = remoteClaimOf(entry, remote.key);
|
|
19449
19485
|
if (pattern)
|
|
19450
19486
|
capped = capAt(source, capped, { entry }, `remote ${remote.name} ${remote.url} (workspace ${entry.name} claims ${pattern})`, "a checkout never exceeds the workspace that owns its remote");
|
|
19451
19487
|
}
|
|
@@ -19473,7 +19509,7 @@ function claimsIn(target, entries) {
|
|
|
19473
19509
|
return target;
|
|
19474
19510
|
const claiming = entries.filter((entry) => entry.remotes?.length);
|
|
19475
19511
|
return target.remotes.flatMap((remote) => claiming.flatMap((entry) => {
|
|
19476
|
-
const pattern = entry
|
|
19512
|
+
const pattern = remoteClaimOf(entry, remote.key);
|
|
19477
19513
|
return pattern ? [{ url: remote.url, workspace: entry.name, pattern }] : [];
|
|
19478
19514
|
}));
|
|
19479
19515
|
}
|