@git-stunts/git-cas 6.5.5 → 6.5.6
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/CHANGELOG.md +23 -0
- package/README.md +8 -1
- package/UPGRADING.md +16 -0
- package/bin/ui/context.js +18 -51
- package/bin/ui/dashboard-view.js +294 -256
- package/bin/ui/dashboard.js +352 -283
- package/bin/ui/progress.js +83 -23
- package/bin/ui/theme.js +39 -12
- package/build-info.json +2 -2
- package/docs/releases/v6.5.6.md +55 -0
- package/package.json +6 -5
- package/src/infrastructure/adapters/GitRefAdapter.js +62 -32
- package/src/package-version.js +1 -1
- package/src/ports/GitRefPort.js +6 -0
package/bin/ui/progress.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { statSync } from 'node:fs';
|
|
7
|
-
import { CLEAR_LINE_RETURN, progressBar } from '@flyingrobots/bijou';
|
|
7
|
+
import { CLEAR_LINE_RETURN, cursorGuard, progressBar } from '@flyingrobots/bijou';
|
|
8
8
|
import { getCliContext } from './context.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -43,7 +43,13 @@ function formatBytes(bytes) {
|
|
|
43
43
|
* @param {import('@flyingrobots/bijou').BijouContext} [options.ctx] - Context override.
|
|
44
44
|
* @returns {ProgressTracker}
|
|
45
45
|
*/
|
|
46
|
-
export function createStoreProgress({
|
|
46
|
+
export function createStoreProgress({
|
|
47
|
+
filePath,
|
|
48
|
+
chunkSize,
|
|
49
|
+
quiet,
|
|
50
|
+
fileSize: providedSize,
|
|
51
|
+
ctx: providedCtx,
|
|
52
|
+
}) {
|
|
47
53
|
if (quiet) {
|
|
48
54
|
return { attach() {}, detach() {} };
|
|
49
55
|
}
|
|
@@ -92,6 +98,7 @@ export function createRestoreProgress({ totalChunks, quiet, ctx: providedCtx })
|
|
|
92
98
|
* @property {number | null} startTime
|
|
93
99
|
* @property {Observer | null} service
|
|
94
100
|
* @property {((evt: { size: number }) => void) | null} handler
|
|
101
|
+
* @property {import('@flyingrobots/bijou').CursorHideHandle | null} cursorHandle
|
|
95
102
|
*/
|
|
96
103
|
|
|
97
104
|
/**
|
|
@@ -102,18 +109,77 @@ export function createRestoreProgress({ totalChunks, quiet, ctx: providedCtx })
|
|
|
102
109
|
* @param {{ ctx: import('@flyingrobots/bijou').BijouContext, totalChunks: number, label: string, width: number }} deps
|
|
103
110
|
*/
|
|
104
111
|
function handleChunkEvent({ size }, state, deps) {
|
|
105
|
-
if (!state.startTime) {
|
|
112
|
+
if (!state.startTime) {
|
|
113
|
+
state.startTime = Date.now();
|
|
114
|
+
}
|
|
106
115
|
state.chunksProcessed++;
|
|
107
116
|
state.bytesProcessed += size;
|
|
117
|
+
renderProgress(state, deps);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Render the current tracker state without mutating its counters.
|
|
122
|
+
*
|
|
123
|
+
* @param {TrackerState} state
|
|
124
|
+
* @param {{ ctx: import('@flyingrobots/bijou').BijouContext, totalChunks: number, label: string, width: number }} deps
|
|
125
|
+
*/
|
|
126
|
+
function renderProgress(state, deps) {
|
|
108
127
|
const pct = (state.chunksProcessed / deps.totalChunks) * 100;
|
|
109
|
-
const elapsed = (Date.now() - state.startTime) / 1000;
|
|
128
|
+
const elapsed = state.startTime ? (Date.now() - state.startTime) / 1000 : 0;
|
|
110
129
|
const throughput = elapsed > 0 ? state.bytesProcessed / elapsed : 0;
|
|
111
130
|
if (deps.ctx.mode === 'interactive') {
|
|
112
131
|
const status = ` ${deps.label} ${state.chunksProcessed}/${deps.totalChunks} ${formatBytes(throughput)}/s `;
|
|
113
132
|
const barStr = progressBar(pct, { width: deps.width, showPercent: false, ctx: deps.ctx });
|
|
114
133
|
deps.ctx.io.writeError(`${CLEAR_LINE_RETURN}${status}${barStr}`);
|
|
115
|
-
} else if (
|
|
116
|
-
|
|
134
|
+
} else if (
|
|
135
|
+
state.chunksProcessed === 1 ||
|
|
136
|
+
state.chunksProcessed === deps.totalChunks ||
|
|
137
|
+
state.chunksProcessed % 10 === 0
|
|
138
|
+
) {
|
|
139
|
+
deps.ctx.io.writeError(
|
|
140
|
+
`${deps.label} ${state.chunksProcessed}/${deps.totalChunks} ${Math.round(pct)}%\n`
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function releaseTracker(state) {
|
|
146
|
+
state.cursorHandle?.dispose();
|
|
147
|
+
state.cursorHandle = null;
|
|
148
|
+
state.service = null;
|
|
149
|
+
state.handler = null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function attachProgress(svc, state, deps) {
|
|
153
|
+
state.service = svc;
|
|
154
|
+
state.handler = (/** @type {{ size: number }} */ evt) => handleChunkEvent(evt, state, deps);
|
|
155
|
+
try {
|
|
156
|
+
if (deps.ctx.mode === 'interactive') {
|
|
157
|
+
state.cursorHandle = cursorGuard(deps.ctx.io).hide();
|
|
158
|
+
renderProgress(state, deps);
|
|
159
|
+
}
|
|
160
|
+
state.service.on(deps.event, state.handler);
|
|
161
|
+
} catch (error) {
|
|
162
|
+
releaseTracker(state);
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function detachProgress(state, deps) {
|
|
168
|
+
try {
|
|
169
|
+
if (state.service && state.handler) {
|
|
170
|
+
state.service.removeListener(deps.event, state.handler);
|
|
171
|
+
}
|
|
172
|
+
const elapsed = state.startTime ? (Date.now() - state.startTime) / 1000 : 0;
|
|
173
|
+
const throughput = elapsed > 0 ? state.bytesProcessed / elapsed : 0;
|
|
174
|
+
if (deps.ctx.mode === 'interactive') {
|
|
175
|
+
deps.ctx.io.writeError(
|
|
176
|
+
`${CLEAR_LINE_RETURN} ${deps.label} ${state.chunksProcessed}/${deps.totalChunks} done ${formatBytes(throughput)}/s\n`
|
|
177
|
+
);
|
|
178
|
+
} else {
|
|
179
|
+
deps.ctx.io.writeError(`${deps.label} ${state.chunksProcessed}/${deps.totalChunks} done\n`);
|
|
180
|
+
}
|
|
181
|
+
} finally {
|
|
182
|
+
releaseTracker(state);
|
|
117
183
|
}
|
|
118
184
|
}
|
|
119
185
|
|
|
@@ -126,29 +192,23 @@ function handleChunkEvent({ size }, state, deps) {
|
|
|
126
192
|
function createProgressTracker({ ctx, totalChunks, event, label }) {
|
|
127
193
|
const width = Math.min(40, (ctx.runtime.columns || 80) - 30);
|
|
128
194
|
/** @type {TrackerState} */
|
|
129
|
-
const state = {
|
|
130
|
-
|
|
195
|
+
const state = {
|
|
196
|
+
chunksProcessed: 0,
|
|
197
|
+
bytesProcessed: 0,
|
|
198
|
+
startTime: null,
|
|
199
|
+
service: null,
|
|
200
|
+
handler: null,
|
|
201
|
+
cursorHandle: null,
|
|
202
|
+
};
|
|
203
|
+
const deps = { ctx, totalChunks, event, label, width };
|
|
131
204
|
|
|
132
205
|
return {
|
|
133
206
|
/** @param {Observer} svc */
|
|
134
207
|
attach(svc) {
|
|
135
|
-
state
|
|
136
|
-
state.handler = (/** @type {{ size: number }} */ evt) => handleChunkEvent(evt, state, deps);
|
|
137
|
-
if (ctx.mode === 'interactive') {
|
|
138
|
-
ctx.io.writeError('\x1b[?25l'); // hide cursor
|
|
139
|
-
handleChunkEvent({ size: 0 }, state, deps);
|
|
140
|
-
}
|
|
141
|
-
state.service.on(event, state.handler);
|
|
208
|
+
attachProgress(svc, state, deps);
|
|
142
209
|
},
|
|
143
210
|
detach() {
|
|
144
|
-
|
|
145
|
-
const elapsed = state.startTime ? (Date.now() - state.startTime) / 1000 : 0;
|
|
146
|
-
const throughput = elapsed > 0 ? state.bytesProcessed / elapsed : 0;
|
|
147
|
-
if (ctx.mode === 'interactive') {
|
|
148
|
-
ctx.io.writeError(`${CLEAR_LINE_RETURN} ${label} ${state.chunksProcessed}/${totalChunks} done ${formatBytes(throughput)}/s\n\x1b[?25h`); // show cursor
|
|
149
|
-
} else {
|
|
150
|
-
ctx.io.writeError(`${label} ${state.chunksProcessed}/${totalChunks} done\n`);
|
|
151
|
-
}
|
|
211
|
+
detachProgress(state, deps);
|
|
152
212
|
},
|
|
153
213
|
};
|
|
154
214
|
}
|
package/bin/ui/theme.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Shared visual language for git-cas terminal surfaces.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { parseAnsiToSurface } from '@flyingrobots/bijou';
|
|
5
|
+
import { defineThemeSafePairs, parseAnsiToSurface } from '@flyingrobots/bijou';
|
|
6
6
|
|
|
7
7
|
export const GIT_CAS_PALETTE = {
|
|
8
8
|
ghost: [251, 252, 252],
|
|
@@ -31,16 +31,18 @@ function token(rgb, modifiers = [], bg) {
|
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
const {
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
const { ghost, slate, cyan, orange, midnight, ink, ruby, sky, violet, deepSlate } = GIT_CAS_PALETTE;
|
|
35
|
+
|
|
36
|
+
const secondaryBackground = [43, 58, 68];
|
|
37
|
+
const elevatedBackground = [51, 68, 78];
|
|
38
|
+
const mutedBackground = [31, 41, 49];
|
|
37
39
|
|
|
38
40
|
/**
|
|
39
|
-
* Bijou
|
|
41
|
+
* Bijou v7 theme for the git-cas cockpit.
|
|
40
42
|
*
|
|
41
43
|
* Keep this object aligned with Bijou's public Theme shape. App-specific
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
+
* surface tokens are registered under `ui` so Bijou's theme doctor can verify
|
|
45
|
+
* every foreground/background relationship used by the cockpit.
|
|
44
46
|
*/
|
|
45
47
|
export const GIT_CAS_THEME = {
|
|
46
48
|
name: 'git-cas-cockpit',
|
|
@@ -51,7 +53,7 @@ export const GIT_CAS_THEME = {
|
|
|
51
53
|
info: token(sky),
|
|
52
54
|
pending: token(slate),
|
|
53
55
|
active: token(cyan, ['bold']),
|
|
54
|
-
muted: token(
|
|
56
|
+
muted: token(slate),
|
|
55
57
|
},
|
|
56
58
|
semantic: {
|
|
57
59
|
success: token(cyan, ['bold']),
|
|
@@ -91,22 +93,47 @@ export const GIT_CAS_THEME = {
|
|
|
91
93
|
logo: token(cyan, ['bold']),
|
|
92
94
|
tableHeader: token(ghost, ['bold']),
|
|
93
95
|
trackEmpty: token(deepSlate),
|
|
96
|
+
canvas: token(midnight),
|
|
97
|
+
secondaryCanvas: token(secondaryBackground),
|
|
98
|
+
elevatedCanvas: token(elevatedBackground),
|
|
99
|
+
overlayCanvas: token(ink),
|
|
100
|
+
mutedCanvas: token(mutedBackground),
|
|
94
101
|
},
|
|
95
102
|
surface: {
|
|
96
103
|
primary: token(ghost, [], midnight),
|
|
97
|
-
secondary: token(
|
|
98
|
-
elevated: token(ghost, [],
|
|
104
|
+
secondary: token(ghost, [], secondaryBackground),
|
|
105
|
+
elevated: token(ghost, [], elevatedBackground),
|
|
99
106
|
overlay: token(ghost, [], ink),
|
|
100
|
-
muted: token(
|
|
107
|
+
muted: token(ghost, [], mutedBackground),
|
|
101
108
|
},
|
|
102
109
|
};
|
|
103
110
|
|
|
111
|
+
/**
|
|
112
|
+
* High-contrast foreground/background contracts selected with Design Book and
|
|
113
|
+
* enforced by Bijou's theme doctor. Decorative track and border colors are not
|
|
114
|
+
* text pairs and are intentionally excluded.
|
|
115
|
+
*/
|
|
116
|
+
export const GIT_CAS_THEME_SAFE_PAIRS = defineThemeSafePairs()
|
|
117
|
+
.readable('surface.primary', 'ui.canvas', { label: 'primary surface text' })
|
|
118
|
+
.readable('surface.secondary', 'ui.secondaryCanvas', { label: 'secondary surface text' })
|
|
119
|
+
.readable('surface.elevated', 'ui.elevatedCanvas', { label: 'elevated surface text' })
|
|
120
|
+
.readable('surface.overlay', 'ui.overlayCanvas', { label: 'overlay surface text' })
|
|
121
|
+
.readable('surface.muted', 'ui.mutedCanvas', { label: 'muted surface text' })
|
|
122
|
+
.readable('semantic.primary', 'ui.canvas', { label: 'primary cockpit text' })
|
|
123
|
+
.readable('semantic.muted', 'ui.canvas', { label: 'muted cockpit text' })
|
|
124
|
+
.status('semantic.success', 'ui.canvas', { label: 'success cockpit text' })
|
|
125
|
+
.status('semantic.error', 'ui.canvas', { label: 'error cockpit text' })
|
|
126
|
+
.status('semantic.warning', 'ui.canvas', { label: 'warning cockpit text' })
|
|
127
|
+
.status('semantic.info', 'ui.canvas', { label: 'informational cockpit text' })
|
|
128
|
+
.status('semantic.accent', 'ui.canvas', { label: 'accent cockpit text' })
|
|
129
|
+
.build();
|
|
130
|
+
|
|
104
131
|
const TEXT_TONES = {
|
|
105
132
|
brand: { fg: cyan, bold: true },
|
|
106
133
|
accent: { fg: orange, bold: true },
|
|
107
134
|
primary: { fg: ghost },
|
|
108
135
|
secondary: { fg: slate },
|
|
109
|
-
subdued: { fg:
|
|
136
|
+
subdued: { fg: slate },
|
|
110
137
|
info: { fg: sky, bold: true },
|
|
111
138
|
violet: { fg: violet, bold: true },
|
|
112
139
|
success: { fg: cyan, bold: true },
|
package/build-info.json
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# git-cas v6.5.6 Release Notes
|
|
2
|
+
|
|
3
|
+
v6.5.6 moves the interactive cockpit onto Bijou 7.2's hosted application
|
|
4
|
+
boundary and makes checked Git ref conflicts independent of diagnostic prose.
|
|
5
|
+
It changes no public package API or stored-data schema.
|
|
6
|
+
|
|
7
|
+
## Bijou 7 Hosted Cockpit
|
|
8
|
+
|
|
9
|
+
The interactive launcher now runs a `FramedApp`. Bijou owns terminal lifecycle,
|
|
10
|
+
outer chrome, help, command and asset-search palettes, settings, notifications,
|
|
11
|
+
performance telemetry, quit confirmation, and reference-counted cursor state.
|
|
12
|
+
The git-cas page continues to own vault authentication, storage state,
|
|
13
|
+
Explorer/Atlas/Operations navigation, filtering, and the Store Wizard.
|
|
14
|
+
|
|
15
|
+
Store and restore progress use Bijou's shared cursor guard and render the
|
|
16
|
+
initial `0/N` state without incrementing the processed count. Frame and page
|
|
17
|
+
tests preserve ordinary modal input, page-first key ownership, structured
|
|
18
|
+
stdout, and the static noninteractive fallback.
|
|
19
|
+
|
|
20
|
+
Design Book selected the high-contrast foregrounds for the dark cockpit
|
|
21
|
+
surfaces. Bijou's theme doctor and explicit text-tone tests enforce a minimum
|
|
22
|
+
4.5:1 contrast ratio.
|
|
23
|
+
|
|
24
|
+
## Deterministic Checked-Ref Conflicts
|
|
25
|
+
|
|
26
|
+
Failed checked updates, atomic anchors, and checked deletes no longer inspect
|
|
27
|
+
Git's human-readable diagnostics. The Git adapter reads structured post-failure
|
|
28
|
+
posture—direct OID, symbolic target, or absence—and normalizes only when that
|
|
29
|
+
posture disproves the attempted compare-and-swap precondition.
|
|
30
|
+
|
|
31
|
+
The existing contracts remain:
|
|
32
|
+
|
|
33
|
+
- checked updates and deletes reject with `GIT_REF_CONFLICT` plus structured
|
|
34
|
+
expected and observed posture;
|
|
35
|
+
- atomic anchors return `false` when their source changed or target appeared;
|
|
36
|
+
- operational failures remain the original error when the attempted ref
|
|
37
|
+
precondition still holds.
|
|
38
|
+
|
|
39
|
+
Diagnostic-free unit and real-Git tests cover changed, absent, and symbolic
|
|
40
|
+
posture across all three mutation paths.
|
|
41
|
+
|
|
42
|
+
## Verification
|
|
43
|
+
|
|
44
|
+
The release candidate passed the repository's complete 14-step verifier with
|
|
45
|
+
6,898 observed tests across Node, Bun, and Deno. The matrix includes public
|
|
46
|
+
type compatibility, executable examples, 199 real-Git integration tests on
|
|
47
|
+
each runtime, build stamping, and npm and JSR dry-runs.
|
|
48
|
+
|
|
49
|
+
## Compatibility
|
|
50
|
+
|
|
51
|
+
This release requires no application or stored-data migration. Existing refs,
|
|
52
|
+
objects, handles, cockpit lower modes, machine-readable output, and package
|
|
53
|
+
exports remain valid. Interactive operators receive the hosted Bijou shell
|
|
54
|
+
automatically; callers receive more reliable existing conflict semantics
|
|
55
|
+
without changing method signatures.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@git-stunts/git-cas",
|
|
3
|
-
"version": "6.5.
|
|
3
|
+
"version": "6.5.6",
|
|
4
4
|
"description": "Content-addressed storage backed by Git's object database, with optional encryption and pluggable codecs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"docs/releases/v6.5.3.md",
|
|
43
43
|
"docs/releases/v6.5.4.md",
|
|
44
44
|
"docs/releases/v6.5.5.md",
|
|
45
|
+
"docs/releases/v6.5.6.md",
|
|
45
46
|
"docs/THREAT_MODEL.md",
|
|
46
47
|
"docs/VAULT_INTERNALS.md",
|
|
47
48
|
"docs/WALKTHROUGH.md",
|
|
@@ -102,10 +103,10 @@
|
|
|
102
103
|
"format": "prettier --write ."
|
|
103
104
|
},
|
|
104
105
|
"dependencies": {
|
|
105
|
-
"@flyingrobots/bijou": "^
|
|
106
|
-
"@flyingrobots/bijou-node": "^
|
|
107
|
-
"@flyingrobots/bijou-tui": "^
|
|
108
|
-
"@flyingrobots/bijou-tui-app": "^
|
|
106
|
+
"@flyingrobots/bijou": "^7.2.0",
|
|
107
|
+
"@flyingrobots/bijou-node": "^7.2.0",
|
|
108
|
+
"@flyingrobots/bijou-tui": "^7.2.0",
|
|
109
|
+
"@flyingrobots/bijou-tui-app": "^7.2.0",
|
|
109
110
|
"@git-stunts/alfred": "^0.10.0",
|
|
110
111
|
"@git-stunts/plumbing": "^3.2.0",
|
|
111
112
|
"@git-stunts/vault": "^1.0.1",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Policy } from '@git-stunts/alfred';
|
|
2
2
|
import GitRefPort from '../../ports/GitRefPort.js';
|
|
3
3
|
import { CasError, ErrorCodes } from '../../domain/errors/index.js';
|
|
4
|
-
import {
|
|
4
|
+
import { isGitMissingRefError } from '../../domain/helpers/gitRefErrors.js';
|
|
5
5
|
import Oid from '../../domain/value-objects/Oid.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -136,9 +136,22 @@ export default class GitRefAdapter extends GitRefPort {
|
|
|
136
136
|
if (expectedOldOid !== undefined) {
|
|
137
137
|
args.push(expectedOldOid ?? '0'.repeat(newOid.length));
|
|
138
138
|
}
|
|
139
|
-
|
|
140
|
-
this.
|
|
141
|
-
|
|
139
|
+
try {
|
|
140
|
+
await this.policy.execute(() =>
|
|
141
|
+
this.plumbing.execute({ args }),
|
|
142
|
+
);
|
|
143
|
+
} catch (error) {
|
|
144
|
+
const actual = await this.#inspectRefPosture(ref);
|
|
145
|
+
if (postureDisprovesExpectedOid(actual, expectedOldOid)) {
|
|
146
|
+
throw refConflictFromPosture({
|
|
147
|
+
ref,
|
|
148
|
+
expectedOldOid: expectedOldOid ?? null,
|
|
149
|
+
actual,
|
|
150
|
+
originalError: error,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
throw error;
|
|
154
|
+
}
|
|
142
155
|
}
|
|
143
156
|
|
|
144
157
|
/** @override */
|
|
@@ -168,7 +181,12 @@ export default class GitRefAdapter extends GitRefPort {
|
|
|
168
181
|
);
|
|
169
182
|
return true;
|
|
170
183
|
} catch (error) {
|
|
171
|
-
|
|
184
|
+
const sourceActual = await this.#inspectRefPosture(sourceRef);
|
|
185
|
+
if (postureDisprovesExpectedOid(sourceActual, generation)) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
const targetActual = await this.#inspectRefPosture(targetRef);
|
|
189
|
+
if (postureDisprovesExpectedOid(targetActual, null)) {
|
|
172
190
|
return false;
|
|
173
191
|
}
|
|
174
192
|
throw error;
|
|
@@ -197,27 +215,16 @@ export default class GitRefAdapter extends GitRefPort {
|
|
|
197
215
|
}),
|
|
198
216
|
);
|
|
199
217
|
} catch (error) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
const racedSymbolicTarget = await this.#resolveSymbolicRef(ref);
|
|
204
|
-
if (racedSymbolicTarget !== null) {
|
|
205
|
-
throw refConflict({
|
|
218
|
+
const actual = await this.#inspectRefPosture(ref);
|
|
219
|
+
if (postureDisprovesExpectedOid(actual, expectedGeneration)) {
|
|
220
|
+
throw refConflictFromPosture({
|
|
206
221
|
ref,
|
|
207
222
|
expectedOldOid: expectedGeneration,
|
|
208
|
-
|
|
209
|
-
actualSymref: racedSymbolicTarget,
|
|
223
|
+
actual,
|
|
210
224
|
originalError: error,
|
|
211
225
|
});
|
|
212
226
|
}
|
|
213
|
-
|
|
214
|
-
throw refConflict({
|
|
215
|
-
ref,
|
|
216
|
-
expectedOldOid: expectedGeneration,
|
|
217
|
-
actualOldOid: actual?.oid ?? null,
|
|
218
|
-
actualSymref: actual?.symref ?? null,
|
|
219
|
-
originalError: error,
|
|
220
|
-
});
|
|
227
|
+
throw error;
|
|
221
228
|
}
|
|
222
229
|
return true;
|
|
223
230
|
}
|
|
@@ -270,6 +277,18 @@ export default class GitRefAdapter extends GitRefPort {
|
|
|
270
277
|
});
|
|
271
278
|
}
|
|
272
279
|
|
|
280
|
+
async #inspectRefPosture(ref) {
|
|
281
|
+
const symbolicTarget = await this.#resolveSymbolicRef(ref);
|
|
282
|
+
if (symbolicTarget !== null) {
|
|
283
|
+
return Object.freeze({ oid: null, symref: symbolicTarget });
|
|
284
|
+
}
|
|
285
|
+
const direct = await this.#inspectDirectRef(ref);
|
|
286
|
+
if (direct?.symref) {
|
|
287
|
+
return Object.freeze({ oid: null, symref: direct.symref });
|
|
288
|
+
}
|
|
289
|
+
return Object.freeze({ oid: direct?.oid ?? null, symref: null });
|
|
290
|
+
}
|
|
291
|
+
|
|
273
292
|
async #resolveSymbolicRef(ref) {
|
|
274
293
|
try {
|
|
275
294
|
const output = await this.policy.execute(() =>
|
|
@@ -443,17 +462,18 @@ function invalidRefName(ref) {
|
|
|
443
462
|
return new CasError('Git ref name or prefix is invalid', ErrorCodes.GIT_ERROR, { ref });
|
|
444
463
|
}
|
|
445
464
|
|
|
446
|
-
function
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
465
|
+
function postureDisprovesExpectedOid(actual, expectedOldOid) {
|
|
466
|
+
if (actual.symref !== null) {
|
|
467
|
+
return true;
|
|
468
|
+
}
|
|
469
|
+
if (expectedOldOid === undefined) {
|
|
470
|
+
return false;
|
|
471
|
+
}
|
|
472
|
+
if (expectedOldOid === null) {
|
|
473
|
+
return actual.oid !== null;
|
|
474
|
+
}
|
|
475
|
+
return actual.oid === null
|
|
476
|
+
|| Oid.from(actual.oid).toString() !== Oid.from(expectedOldOid).toString();
|
|
457
477
|
}
|
|
458
478
|
|
|
459
479
|
function isQuietSymbolicRefMiss(error, ref) {
|
|
@@ -479,3 +499,13 @@ function refConflict({
|
|
|
479
499
|
{ ref, expectedOldOid, actualOldOid, actualSymref, originalError },
|
|
480
500
|
);
|
|
481
501
|
}
|
|
502
|
+
|
|
503
|
+
function refConflictFromPosture({ ref, expectedOldOid, actual, originalError }) {
|
|
504
|
+
return refConflict({
|
|
505
|
+
ref,
|
|
506
|
+
expectedOldOid,
|
|
507
|
+
actualOldOid: actual.oid,
|
|
508
|
+
actualSymref: actual.symref,
|
|
509
|
+
originalError,
|
|
510
|
+
});
|
|
511
|
+
}
|
package/src/package-version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const PACKAGE_VERSION = '6.5.
|
|
1
|
+
export const PACKAGE_VERSION = '6.5.6';
|
package/src/ports/GitRefPort.js
CHANGED
|
@@ -54,6 +54,8 @@ export default class GitRefPort {
|
|
|
54
54
|
* @param {string} _options.newOid - New OID to set.
|
|
55
55
|
* @param {string|null} [_options.expectedOldOid] - Expected current OID for CAS; `null` means the ref must not exist.
|
|
56
56
|
* @returns {Promise<void>}
|
|
57
|
+
* @throws A `GIT_REF_CONFLICT` error when observed ref posture disproves the
|
|
58
|
+
* checked mutation precondition.
|
|
57
59
|
*/
|
|
58
60
|
async updateRef(_options) {
|
|
59
61
|
throw new Error('Not implemented');
|
|
@@ -66,6 +68,8 @@ export default class GitRefPort {
|
|
|
66
68
|
* @param {string} _options.expectedSourceOid
|
|
67
69
|
* @param {string} _options.targetRef
|
|
68
70
|
* @returns {Promise<boolean>} Whether the source generation was anchored.
|
|
71
|
+
* `false` means observed ref posture disproved the atomic verify/create
|
|
72
|
+
* preconditions.
|
|
69
73
|
*/
|
|
70
74
|
async anchorRef(_options) {
|
|
71
75
|
throw unsupportedAcquisitionCapability('anchorRef');
|
|
@@ -77,6 +81,8 @@ export default class GitRefPort {
|
|
|
77
81
|
* @param {string} _options.ref
|
|
78
82
|
* @param {string} _options.expectedOldOid
|
|
79
83
|
* @returns {Promise<boolean>} Whether the ref existed and was deleted.
|
|
84
|
+
* @throws A `GIT_REF_CONFLICT` error when observed ref posture disproves the
|
|
85
|
+
* checked delete precondition.
|
|
80
86
|
*/
|
|
81
87
|
async deleteRef(_options) {
|
|
82
88
|
throw unsupportedAcquisitionCapability('deleteRef');
|