@bakers-build/core 0.10.1-next.12 → 0.10.1-next.14
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/src/config-types.generated.d.ts +1 -0
- package/dist/src/core/isolated-git.d.ts +5 -3
- package/dist/src/core/isolated-git.js +27 -6
- package/dist/src/core/run-clone.d.ts +2 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/package.json +2 -2
- package/schema/project.schema.json +1 -0
|
@@ -94,6 +94,7 @@ export interface ProjectConfig {
|
|
|
94
94
|
url: string;
|
|
95
95
|
/** Branch or tag. */
|
|
96
96
|
ref: string;
|
|
97
|
+
/** Plugins to install from this marketplace, at least one. */
|
|
97
98
|
plugins: Array<string>;
|
|
98
99
|
}>;
|
|
99
100
|
/** Function choosing the agent for a ticket; replaces the shipped selection. */
|
|
@@ -5,14 +5,16 @@ import type { RunClone } from './run-clone.js';
|
|
|
5
5
|
* Git holding its lock must not fail a run start or a transfer.
|
|
6
6
|
*/
|
|
7
7
|
export declare function refreshRunCloneIndex({ workspace }: RunClone): void;
|
|
8
|
+
/** Protected paths `to` changes against `from`, both commits of the parent. */
|
|
9
|
+
export declare function changedProtectedPaths(record: RunClone, from: string, to: string): string[];
|
|
8
10
|
/** The run's ticket branch tip, read as plain files: Git never runs under the run's config. */
|
|
9
11
|
export declare function runCloneTip(record: RunClone): string;
|
|
10
12
|
/**
|
|
11
13
|
* Give the run the parent's current `origin/<branch>` refs (default: its
|
|
12
|
-
* target)
|
|
13
|
-
* runs Git inside the run's directory.
|
|
14
|
+
* target) and the objects of `commits`, which get no ref: objects as one new
|
|
15
|
+
* pack, each ref as a plain file. Nothing here runs Git inside the run's directory.
|
|
14
16
|
*/
|
|
15
|
-
export declare function refreshRunTarget(record: RunClone, branches?: readonly string[]): void;
|
|
17
|
+
export declare function refreshRunTarget(record: RunClone, branches?: readonly string[], commits?: readonly string[]): void;
|
|
16
18
|
/**
|
|
17
19
|
* Import verified objects through clean metadata and fast-forward the ticket
|
|
18
20
|
* branch in the parent with compare-and-swap. Defaults to the run's branch tip.
|
|
@@ -41,6 +41,16 @@ function normalizeProtectedPaths(paths) {
|
|
|
41
41
|
})),
|
|
42
42
|
];
|
|
43
43
|
}
|
|
44
|
+
/** Protected paths `to` changes against `from`, NUL-separated; empty when none. */
|
|
45
|
+
function protectedDiff(run, record, from, to) {
|
|
46
|
+
return run('diff-tree', '-r', '--name-only', '-z', '--no-renames', from, to, '--', ...normalizeProtectedPaths(record.protectedPaths ?? []).map((path) => `:(literal)${path}`));
|
|
47
|
+
}
|
|
48
|
+
/** Protected paths `to` changes against `from`, both commits of the parent. */
|
|
49
|
+
export function changedProtectedPaths(record, from, to) {
|
|
50
|
+
return protectedDiff((...args) => git(record.parentGitDir, `--git-dir=${record.parentGitDir}`, ...args), record, from, to)
|
|
51
|
+
.split('\0')
|
|
52
|
+
.filter(Boolean);
|
|
53
|
+
}
|
|
44
54
|
function rejectGitlinks(entries) {
|
|
45
55
|
if (entries.split('\0').some((entry) => entry.startsWith('160000 ')))
|
|
46
56
|
throw new Error('isolated Git: submodules are not supported');
|
|
@@ -184,16 +194,19 @@ function writeRunRef(record, ref, tip) {
|
|
|
184
194
|
}
|
|
185
195
|
/**
|
|
186
196
|
* Give the run the parent's current `origin/<branch>` refs (default: its
|
|
187
|
-
* target)
|
|
188
|
-
* runs Git inside the run's directory.
|
|
197
|
+
* target) and the objects of `commits`, which get no ref: objects as one new
|
|
198
|
+
* pack, each ref as a plain file. Nothing here runs Git inside the run's directory.
|
|
189
199
|
*/
|
|
190
|
-
export function refreshRunTarget(record, branches = record.target ? [record.target] : []) {
|
|
200
|
+
export function refreshRunTarget(record, branches = record.target ? [record.target] : [], commits = []) {
|
|
191
201
|
const tips = branches.flatMap((branch) => {
|
|
192
202
|
git(record.parentGitDir, 'check-ref-format', `refs/heads/${branch}`);
|
|
193
203
|
const tip = parentOrigin(record, branch);
|
|
194
204
|
return tip ? [{ branch, tip }] : [];
|
|
195
205
|
});
|
|
196
|
-
if (
|
|
206
|
+
if (commits.some((commit) => !HASH.test(commit)))
|
|
207
|
+
throw new Error('isolated Git: hand-off requires full commit hashes');
|
|
208
|
+
const wanted = [...tips.map(({ tip }) => tip), ...commits];
|
|
209
|
+
if (wanted.length === 0)
|
|
197
210
|
return;
|
|
198
211
|
// pack-objects renames its pack from the parent's objects dir; /tmp may be another filesystem (EXDEV).
|
|
199
212
|
const scratch = mkdtempSync(join(record.parentGitDir, 'bb-target-refresh-'));
|
|
@@ -205,7 +218,7 @@ export function refreshRunTarget(record, branches = record.target ? [record.targ
|
|
|
205
218
|
'--revs',
|
|
206
219
|
join(scratch, 'pack'),
|
|
207
220
|
], {
|
|
208
|
-
input: `${
|
|
221
|
+
input: `${wanted.join('\n')}\n^${record.expected}\n`,
|
|
209
222
|
stdio: ['pipe', 'ignore', 'pipe'],
|
|
210
223
|
});
|
|
211
224
|
const pack = pinDir(record.gitDir, 'objects/pack', true);
|
|
@@ -240,6 +253,14 @@ export function transferIsolatedCommit(record, commit = runCloneTip(record)) {
|
|
|
240
253
|
if (commit === record.expected)
|
|
241
254
|
return commit;
|
|
242
255
|
const parent = (...args) => git(record.parentGitDir, `--git-dir=${record.parentGitDir}`, ...args);
|
|
256
|
+
// A run still at a tip the host moved its branch past (forge_update_branch) has nothing to bring.
|
|
257
|
+
try {
|
|
258
|
+
parent('merge-base', '--is-ancestor', commit, record.expected);
|
|
259
|
+
return record.expected;
|
|
260
|
+
}
|
|
261
|
+
catch {
|
|
262
|
+
// Not an ancestor, or not in the parent yet: transfer it.
|
|
263
|
+
}
|
|
243
264
|
const scratch = mkdtempSync(join(tmpdir(), 'bb-commit-transfer-'));
|
|
244
265
|
try {
|
|
245
266
|
git(scratch, 'init', '--bare', '--template=', `--object-format=${commit.length === 64 ? 'sha256' : 'sha1'}`, '-q');
|
|
@@ -253,7 +274,7 @@ export function transferIsolatedCommit(record, commit = runCloneTip(record)) {
|
|
|
253
274
|
rejectGitlinks(git(scratch, 'ls-tree', '-r', '-z', commit));
|
|
254
275
|
git(scratch, 'merge-base', '--is-ancestor', record.expected, commit);
|
|
255
276
|
// Against the tip the run started from, so a merge of the target passes.
|
|
256
|
-
if (git(scratch,
|
|
277
|
+
if (protectedDiff((...args) => git(scratch, ...args), record, record.expected, commit))
|
|
257
278
|
throw new Error(`isolated Git: commit ${commit} changes a protected path`);
|
|
258
279
|
// Only scratch's clean config is read; the run's hooks/config never reach host Git.
|
|
259
280
|
parent('-c', 'protocol.file.allow=always', 'fetch', '--no-tags', '--no-write-fetch-head', scratch, commit);
|
|
@@ -15,6 +15,8 @@ export interface RunClone {
|
|
|
15
15
|
target?: string;
|
|
16
16
|
shared: boolean;
|
|
17
17
|
protectedPaths?: string[];
|
|
18
|
+
/** Set when forge_update_branch changed protected paths the run cannot see: push refuses until a fresh clone. */
|
|
19
|
+
restartPending?: string;
|
|
18
20
|
}
|
|
19
21
|
export interface RunCloneOptions {
|
|
20
22
|
/** Any path inside the parent checkout. */
|
package/dist/src/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export type { ConnectionConfig, MachineConfig, ProjectConfig, } from './config-t
|
|
|
20
20
|
export { configHomeOf, defaultRootGitExec, deriveCheckoutRoot, type RootGitExec, } from './core/checkout-root.js';
|
|
21
21
|
export { CommandRunner, ExecError, exec, setDefaultCommandRunner, } from './core/exec.js';
|
|
22
22
|
export { type GitSandboxPaths, gitSandboxPaths, withoutGitDirs, } from './core/git-sandbox.js';
|
|
23
|
-
export { refreshRunTarget, runCloneTip, transferIsolatedCommit, } from './core/isolated-git.js';
|
|
23
|
+
export { changedProtectedPaths, refreshRunTarget, runCloneTip, transferIsolatedCommit, } from './core/isolated-git.js';
|
|
24
24
|
export { type ConductorLiveness, type ConductorLivenessInput, deriveConductorLiveness, toUnixSeconds, } from './core/liveness.js';
|
|
25
25
|
export { type ConductorLogger, createLogger } from './core/logger.js';
|
|
26
26
|
export { defaultProcProbe, defaultRunProcessProbe, killRunProcesses, type ProcProbe, type RunProcessProbe, type SignalFailureReason, type SignalOutcome, type SignalVerifiedInput, signalVerifiedProcess, type VerifyOutcome, type VerifyProcessInput, verifyConductorProcess, } from './core/proc.js';
|
package/dist/src/index.js
CHANGED
|
@@ -21,7 +21,7 @@ export { discoverBbWorkspaces, loadReadyBbConnection, resolveWorkspaceSelector,
|
|
|
21
21
|
export { configHomeOf, defaultRootGitExec, deriveCheckoutRoot, } from './core/checkout-root.js';
|
|
22
22
|
export { CommandRunner, ExecError, exec, setDefaultCommandRunner, } from './core/exec.js';
|
|
23
23
|
export { gitSandboxPaths, withoutGitDirs, } from './core/git-sandbox.js';
|
|
24
|
-
export { refreshRunTarget, runCloneTip, transferIsolatedCommit, } from './core/isolated-git.js';
|
|
24
|
+
export { changedProtectedPaths, refreshRunTarget, runCloneTip, transferIsolatedCommit, } from './core/isolated-git.js';
|
|
25
25
|
export { deriveConductorLiveness, toUnixSeconds, } from './core/liveness.js';
|
|
26
26
|
export { createLogger } from './core/logger.js';
|
|
27
27
|
export { defaultProcProbe, defaultRunProcessProbe, killRunProcesses, signalVerifiedProcess, verifyConductorProcess, } from './core/proc.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bakers-build/core",
|
|
3
|
-
"version": "0.10.1-next.
|
|
3
|
+
"version": "0.10.1-next.14",
|
|
4
4
|
"description": "bakers.build surface-agnostic kernel: host contract, split-config helpers, addon preset/discovery machinery, shared primitives.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"yaml": "^2.7.0"
|
|
41
41
|
},
|
|
42
42
|
"bakersBuild": {
|
|
43
|
-
"commit": "
|
|
43
|
+
"commit": "2e1bce1387cf3b5b5bafd3f12317773702160fae",
|
|
44
44
|
"channel": "next"
|
|
45
45
|
}
|
|
46
46
|
}
|