@leitwerk-dev/coding 0.1.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/README.md +9 -0
- package/dist/LICENSE +13 -0
- package/dist/actions.d.ts +18 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +45 -0
- package/dist/actions.js.map +1 -0
- package/dist/auto-work-branch.d.ts +17 -0
- package/dist/auto-work-branch.d.ts.map +1 -0
- package/dist/auto-work-branch.js +112 -0
- package/dist/auto-work-branch.js.map +1 -0
- package/dist/chunk-5LVPKVI2.js +27 -0
- package/dist/chunk-5LVPKVI2.js.map +1 -0
- package/dist/chunk-67YKGZLM.js +25 -0
- package/dist/chunk-67YKGZLM.js.map +1 -0
- package/dist/chunk-DSQX3ZHJ.js +60 -0
- package/dist/chunk-DSQX3ZHJ.js.map +1 -0
- package/dist/chunk-JZU3UVR6.js +573 -0
- package/dist/chunk-JZU3UVR6.js.map +1 -0
- package/dist/chunk-NIJCT4VK.js +45 -0
- package/dist/chunk-NIJCT4VK.js.map +1 -0
- package/dist/chunk-OFDNIT5X.js +13 -0
- package/dist/chunk-OFDNIT5X.js.map +1 -0
- package/dist/chunk-PX6F3LHL.js +40 -0
- package/dist/chunk-PX6F3LHL.js.map +1 -0
- package/dist/chunk-RWCLBBB2.js +34 -0
- package/dist/chunk-RWCLBBB2.js.map +1 -0
- package/dist/chunk-RZ54IVY5.js +28 -0
- package/dist/chunk-RZ54IVY5.js.map +1 -0
- package/dist/chunk-UBVLJV3V.js +23 -0
- package/dist/chunk-UBVLJV3V.js.map +1 -0
- package/dist/chunk-Y2S6JFVO.js +185 -0
- package/dist/chunk-Y2S6JFVO.js.map +1 -0
- package/dist/dist-CFKPEMX5.js +546 -0
- package/dist/dist-CFKPEMX5.js.map +1 -0
- package/dist/finalization-git.d.ts +34 -0
- package/dist/finalization-git.d.ts.map +1 -0
- package/dist/finalization-git.js +533 -0
- package/dist/finalization-git.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/magic-string.es-4IX5OHLL.js +1309 -0
- package/dist/magic-string.es-4IX5OHLL.js.map +1 -0
- package/dist/repository-change-launch.d.ts +65 -0
- package/dist/repository-change-launch.d.ts.map +1 -0
- package/dist/repository-change-launch.js +183 -0
- package/dist/repository-change-launch.js.map +1 -0
- package/dist/repository-change-process.d.ts +38 -0
- package/dist/repository-change-process.d.ts.map +1 -0
- package/dist/repository-change-process.js +751 -0
- package/dist/repository-change-process.js.map +1 -0
- package/dist/repository-change-state.d.ts +16 -0
- package/dist/repository-change-state.d.ts.map +1 -0
- package/dist/repository-change-state.js +52 -0
- package/dist/repository-change-state.js.map +1 -0
- package/dist/turns/generate-commit-message.d.ts +4 -0
- package/dist/turns/generate-commit-message.d.ts.map +1 -0
- package/dist/turns/generate-commit-message.js +39 -0
- package/dist/turns/generate-commit-message.js.map +1 -0
- package/dist/turns/generate-plan.d.ts +3 -0
- package/dist/turns/generate-plan.d.ts.map +1 -0
- package/dist/turns/generate-plan.js +20 -0
- package/dist/turns/generate-plan.js.map +1 -0
- package/dist/turns/implement.d.ts +3 -0
- package/dist/turns/implement.d.ts.map +1 -0
- package/dist/turns/implement.js +18 -0
- package/dist/turns/implement.js.map +1 -0
- package/dist/turns/resolve-merge-conflict.d.ts +3 -0
- package/dist/turns/resolve-merge-conflict.d.ts.map +1 -0
- package/dist/turns/resolve-merge-conflict.js +22 -0
- package/dist/turns/resolve-merge-conflict.js.map +1 -0
- package/dist/turns/review-implementation.d.ts +4 -0
- package/dist/turns/review-implementation.d.ts.map +1 -0
- package/dist/turns/review-implementation.js +28 -0
- package/dist/turns/review-implementation.js.map +1 -0
- package/dist/turns/review-plan.d.ts +4 -0
- package/dist/turns/review-plan.d.ts.map +1 -0
- package/dist/turns/review-plan.js +22 -0
- package/dist/turns/review-plan.js.map +1 -0
- package/dist/turns/simplify-implementation.d.ts +3 -0
- package/dist/turns/simplify-implementation.d.ts.map +1 -0
- package/dist/turns/simplify-implementation.js +8 -0
- package/dist/turns/simplify-implementation.js.map +1 -0
- package/package.json +72 -0
- package/src/actions.ts +60 -0
- package/src/auto-work-branch.ts +145 -0
- package/src/finalization-git.ts +741 -0
- package/src/index.ts +9 -0
- package/src/repository-change-launch.ts +264 -0
- package/src/repository-change-process.ts +933 -0
- package/src/repository-change-state.ts +75 -0
- package/src/turns/generate-commit-message.ts +49 -0
- package/src/turns/generate-plan.ts +23 -0
- package/src/turns/implement.ts +21 -0
- package/src/turns/resolve-merge-conflict.ts +25 -0
- package/src/turns/review-implementation.ts +32 -0
- package/src/turns/review-plan.ts +26 -0
- package/src/turns/simplify-implementation.ts +11 -0
|
@@ -0,0 +1,573 @@
|
|
|
1
|
+
// src/finalization-git.ts
|
|
2
|
+
import { execFileSync } from "child_process";
|
|
3
|
+
import { existsSync, readFileSync } from "fs";
|
|
4
|
+
import { homedir } from "os";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
7
|
+
import { detectRepoLocatorKind, trimToNull } from "@leitwerk-dev/domain";
|
|
8
|
+
import {
|
|
9
|
+
repositoryGitArgs,
|
|
10
|
+
repositoryGitSubprocessEnv
|
|
11
|
+
} from "@leitwerk-dev/process-sdk";
|
|
12
|
+
import { resolveGitBinary } from "@leitwerk-dev/process-sdk/git-binary";
|
|
13
|
+
var DeterministicGitError = class extends Error {
|
|
14
|
+
errorClass = "git_error";
|
|
15
|
+
constructor(message) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.name = "DeterministicGitError";
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
function normalizeLines(value) {
|
|
21
|
+
if (!value) {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
return value.split(/\r?\n/).map((line) => line.trim()).filter((line) => line !== "");
|
|
25
|
+
}
|
|
26
|
+
function abbreviateSha(sha) {
|
|
27
|
+
return sha.slice(0, 12);
|
|
28
|
+
}
|
|
29
|
+
function describeMergeMode(mode) {
|
|
30
|
+
switch (mode) {
|
|
31
|
+
case "noop":
|
|
32
|
+
return "Already up to date";
|
|
33
|
+
case "fast_forward":
|
|
34
|
+
return "Fast-forwarded from origin";
|
|
35
|
+
case "merge_commit":
|
|
36
|
+
return "Created a merge commit";
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function gitConfigIdentityEnv() {
|
|
40
|
+
const env = repositoryGitSubprocessEnv("repo", { GIT_TERMINAL_PROMPT: "0" });
|
|
41
|
+
for (const key of [
|
|
42
|
+
"GIT_AUTHOR_NAME",
|
|
43
|
+
"GIT_AUTHOR_EMAIL",
|
|
44
|
+
"GIT_AUTHOR_DATE",
|
|
45
|
+
"GIT_COMMITTER_NAME",
|
|
46
|
+
"GIT_COMMITTER_EMAIL",
|
|
47
|
+
"GIT_COMMITTER_DATE"
|
|
48
|
+
])
|
|
49
|
+
delete env[key];
|
|
50
|
+
return env;
|
|
51
|
+
}
|
|
52
|
+
function runGit(repoPath, args) {
|
|
53
|
+
try {
|
|
54
|
+
const stdout = execFileSync(resolveGitBinary(), repositoryGitArgs(args), {
|
|
55
|
+
cwd: repoPath,
|
|
56
|
+
encoding: "utf8",
|
|
57
|
+
env: gitConfigIdentityEnv(),
|
|
58
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
ok: true,
|
|
62
|
+
stdout,
|
|
63
|
+
stderr: "",
|
|
64
|
+
status: 0
|
|
65
|
+
};
|
|
66
|
+
} catch (error) {
|
|
67
|
+
const execError = error;
|
|
68
|
+
return {
|
|
69
|
+
ok: false,
|
|
70
|
+
stdout: typeof execError.stdout === "string" ? execError.stdout : execError.stdout ? execError.stdout.toString("utf8") : "",
|
|
71
|
+
stderr: typeof execError.stderr === "string" ? execError.stderr : execError.stderr ? execError.stderr.toString("utf8") : trimToNull(execError.message) ?? "",
|
|
72
|
+
status: execError.status ?? null
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function git(repoPath, ...args) {
|
|
77
|
+
const result = runGit(repoPath, args);
|
|
78
|
+
if (!result.ok) {
|
|
79
|
+
throw new DeterministicGitError(
|
|
80
|
+
`git ${args.join(" ")} failed in '${repoPath}': ${trimToNull(result.stderr) ?? trimToNull(result.stdout) ?? "unknown git error"}`
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
return result.stdout.trim();
|
|
84
|
+
}
|
|
85
|
+
function gitOrNull(repoPath, ...args) {
|
|
86
|
+
const result = runGit(repoPath, args);
|
|
87
|
+
if (!result.ok) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return trimToNull(result.stdout);
|
|
91
|
+
}
|
|
92
|
+
function repoExists(repoPath) {
|
|
93
|
+
return existsSync(repoPath) && existsSync(path.join(repoPath, ".git"));
|
|
94
|
+
}
|
|
95
|
+
function gitRepositoryExists(repoPath) {
|
|
96
|
+
return existsSync(repoPath) && runGit(repoPath, ["rev-parse", "--git-dir"]).ok;
|
|
97
|
+
}
|
|
98
|
+
function currentBranch(repoPath) {
|
|
99
|
+
return git(repoPath, "branch", "--show-current");
|
|
100
|
+
}
|
|
101
|
+
function currentHeadSha(repoPath) {
|
|
102
|
+
return git(repoPath, "rev-parse", "HEAD");
|
|
103
|
+
}
|
|
104
|
+
function originBaseRef(baseBranch) {
|
|
105
|
+
return `origin/${baseBranch}`;
|
|
106
|
+
}
|
|
107
|
+
function remoteOriginUrl(repoPath) {
|
|
108
|
+
const remoteUrl = gitOrNull(repoPath, "remote", "get-url", "origin");
|
|
109
|
+
if (!remoteUrl) {
|
|
110
|
+
throw new DeterministicGitError(`Repository '${repoPath}' does not have an 'origin' remote`);
|
|
111
|
+
}
|
|
112
|
+
return remoteUrl;
|
|
113
|
+
}
|
|
114
|
+
function expandHomePath(value) {
|
|
115
|
+
if (value === "~") {
|
|
116
|
+
return homedir();
|
|
117
|
+
}
|
|
118
|
+
if (value.startsWith("~/")) {
|
|
119
|
+
return path.join(homedir(), value.slice(2));
|
|
120
|
+
}
|
|
121
|
+
return value;
|
|
122
|
+
}
|
|
123
|
+
function resolveLocalRepoPath(repoPath, repoLocator) {
|
|
124
|
+
if (detectRepoLocatorKind(repoLocator) !== "local_path") {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
if (repoLocator.startsWith("file://")) {
|
|
128
|
+
try {
|
|
129
|
+
return fileURLToPath(repoLocator);
|
|
130
|
+
} catch {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return path.resolve(repoPath, expandHomePath(repoLocator));
|
|
135
|
+
}
|
|
136
|
+
function isBareRepository(repoPath) {
|
|
137
|
+
return git(repoPath, "rev-parse", "--is-bare-repository") === "true";
|
|
138
|
+
}
|
|
139
|
+
function resolveLocalSourceRepo(repoPath) {
|
|
140
|
+
const remoteUrl = remoteOriginUrl(repoPath);
|
|
141
|
+
const localRepoPath = resolveLocalRepoPath(repoPath, remoteUrl);
|
|
142
|
+
if (!localRepoPath || !gitRepositoryExists(localRepoPath)) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
path: localRepoPath,
|
|
147
|
+
kind: isBareRepository(localRepoPath) ? "bare" : "non_bare"
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function workingTreeStatus(repoPath) {
|
|
151
|
+
const rawStatus = gitOrNull(repoPath, "status", "--porcelain");
|
|
152
|
+
const dirtyFiles = (rawStatus ?? "").split(/\r?\n/).map((line) => line.replace(/\s+$/, "")).filter((line) => line !== "").map((line) => line.slice(2).trim()).filter((line) => line !== "");
|
|
153
|
+
return { dirtyFiles };
|
|
154
|
+
}
|
|
155
|
+
function conflictedFiles(repoPath) {
|
|
156
|
+
return normalizeLines(gitOrNull(repoPath, "diff", "--name-only", "--diff-filter=U"));
|
|
157
|
+
}
|
|
158
|
+
function mergeHeadPath(repoPath) {
|
|
159
|
+
const gitDir = git(repoPath, "rev-parse", "--git-dir");
|
|
160
|
+
return path.resolve(repoPath, gitDir, "MERGE_HEAD");
|
|
161
|
+
}
|
|
162
|
+
function mergeInProgress(repoPath) {
|
|
163
|
+
return existsSync(mergeHeadPath(repoPath));
|
|
164
|
+
}
|
|
165
|
+
function assertExpectedCheckout(repoPath, workBranch) {
|
|
166
|
+
const branch = currentBranch(repoPath);
|
|
167
|
+
if (branch !== workBranch) {
|
|
168
|
+
throw new DeterministicGitError(
|
|
169
|
+
`Expected '${repoPath}' to be checked out on '${workBranch}', but found '${branch || "detached HEAD"}'`
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function assertGitIdentity(repoPath) {
|
|
174
|
+
const author = runGit(repoPath, ["var", "GIT_AUTHOR_IDENT"]);
|
|
175
|
+
const committer = runGit(repoPath, ["var", "GIT_COMMITTER_IDENT"]);
|
|
176
|
+
if (!author.ok || !committer.ok) {
|
|
177
|
+
throw new DeterministicGitError(
|
|
178
|
+
"Git author/committer identity is not configured. Configure user.name and user.email in this repository or the operator's global Git config, then retry finalization."
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function commitDirtyWorktree(repoPath, commitMessage) {
|
|
183
|
+
assertGitIdentity(repoPath);
|
|
184
|
+
const addResult = runGit(repoPath, ["add", "--all"]);
|
|
185
|
+
if (!addResult.ok) {
|
|
186
|
+
throw new DeterministicGitError(
|
|
187
|
+
`Failed to stage the completed change: ${trimToNull(addResult.stderr) ?? trimToNull(addResult.stdout) ?? "unknown git error"}`
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
const commitResult = runGit(repoPath, [
|
|
191
|
+
"-c",
|
|
192
|
+
"core.hooksPath=/dev/null",
|
|
193
|
+
"commit",
|
|
194
|
+
"--no-gpg-sign",
|
|
195
|
+
"-m",
|
|
196
|
+
commitMessage
|
|
197
|
+
]);
|
|
198
|
+
if (!commitResult.ok) {
|
|
199
|
+
throw new DeterministicGitError(
|
|
200
|
+
`Failed to commit the completed change: ${trimToNull(commitResult.stderr) ?? trimToNull(commitResult.stdout) ?? "unknown git error"}`
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
const remaining = workingTreeStatus(repoPath);
|
|
204
|
+
if (remaining.dirtyFiles.length > 0) {
|
|
205
|
+
throw new DeterministicGitError(
|
|
206
|
+
`Deterministic commit left uncommitted changes: ${remaining.dirtyFiles.join(", ")}`
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
return currentHeadSha(repoPath);
|
|
210
|
+
}
|
|
211
|
+
function assertPostConflictCheckpoint(input, repoPath) {
|
|
212
|
+
if (!trimToNull(input.expectedPostConflictHeadSha)) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (mergeInProgress(repoPath) || conflictedFiles(repoPath).length > 0) {
|
|
216
|
+
throw new DeterministicGitError(
|
|
217
|
+
"Conflict-resolution helper reported a clean merge, but the repository is still in a merge-conflict state"
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
const status = workingTreeStatus(repoPath);
|
|
221
|
+
if (status.dirtyFiles.length > 0) {
|
|
222
|
+
throw new DeterministicGitError(
|
|
223
|
+
`Conflict-resolution helper reported a clean merge, but the repository still has uncommitted changes: ${status.dirtyFiles.join(", ")}`
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
function fetchOriginBase(repoPath, baseBranch) {
|
|
228
|
+
const ref = originBaseRef(baseBranch);
|
|
229
|
+
const fetchResult = runGit(repoPath, ["fetch", "origin", baseBranch]);
|
|
230
|
+
if (!fetchResult.ok) {
|
|
231
|
+
throw new DeterministicGitError(
|
|
232
|
+
`Failed to fetch '${ref}': ${trimToNull(fetchResult.stderr) ?? trimToNull(fetchResult.stdout) ?? "unknown git error"}`
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
const baseSha = gitOrNull(repoPath, "rev-parse", ref);
|
|
236
|
+
if (!baseSha) {
|
|
237
|
+
throw new DeterministicGitError(`Fetched '${ref}' but could not resolve its commit sha`);
|
|
238
|
+
}
|
|
239
|
+
return baseSha;
|
|
240
|
+
}
|
|
241
|
+
function isAncestor(repoPath, olderRef, newerRef) {
|
|
242
|
+
return runGit(repoPath, ["merge-base", "--is-ancestor", olderRef, newerRef]).ok;
|
|
243
|
+
}
|
|
244
|
+
function deterministicMerge(input) {
|
|
245
|
+
const { repoPath, baseBranch, headBefore, baseSha } = input;
|
|
246
|
+
const ref = originBaseRef(baseBranch);
|
|
247
|
+
const headIsAncestorOfBase = isAncestor(repoPath, headBefore, ref);
|
|
248
|
+
const baseIsAncestorOfHead = isAncestor(repoPath, ref, headBefore);
|
|
249
|
+
if (baseIsAncestorOfHead) {
|
|
250
|
+
return { ok: true, mergeMode: "noop", headSha: headBefore };
|
|
251
|
+
}
|
|
252
|
+
if (headIsAncestorOfBase) {
|
|
253
|
+
const ffResult = runGit(repoPath, ["merge", "--ff-only", ref]);
|
|
254
|
+
if (!ffResult.ok) {
|
|
255
|
+
throw new DeterministicGitError(
|
|
256
|
+
`Fast-forward merge from '${ref}' failed: ${trimToNull(ffResult.stderr) ?? trimToNull(ffResult.stdout) ?? "unknown git error"}`
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
return {
|
|
260
|
+
ok: true,
|
|
261
|
+
mergeMode: "fast_forward",
|
|
262
|
+
headSha: currentHeadSha(repoPath)
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
assertGitIdentity(repoPath);
|
|
266
|
+
const mergeResult = runGit(repoPath, [
|
|
267
|
+
"-c",
|
|
268
|
+
"core.hooksPath=/dev/null",
|
|
269
|
+
"merge",
|
|
270
|
+
"--no-edit",
|
|
271
|
+
"--no-gpg-sign",
|
|
272
|
+
ref
|
|
273
|
+
]);
|
|
274
|
+
if (!mergeResult.ok) {
|
|
275
|
+
const conflicts = conflictedFiles(repoPath);
|
|
276
|
+
if (mergeInProgress(repoPath) || conflicts.length > 0) {
|
|
277
|
+
return {
|
|
278
|
+
ok: false,
|
|
279
|
+
conflict: true,
|
|
280
|
+
headSha: currentHeadSha(repoPath),
|
|
281
|
+
conflictedFiles: conflicts
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
throw new DeterministicGitError(
|
|
285
|
+
`Deterministic merge from '${ref}' failed: ${trimToNull(mergeResult.stderr) ?? trimToNull(mergeResult.stdout) ?? "unknown git error"}`
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
const headAfter = currentHeadSha(repoPath);
|
|
289
|
+
return {
|
|
290
|
+
ok: true,
|
|
291
|
+
mergeMode: headAfter === baseSha ? "fast_forward" : "merge_commit",
|
|
292
|
+
headSha: headAfter
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
function branchRef(branch) {
|
|
296
|
+
return `refs/heads/${branch}`;
|
|
297
|
+
}
|
|
298
|
+
function pushHeadToBranch(repoPath, branch) {
|
|
299
|
+
const pushTarget = `origin/${branch}`;
|
|
300
|
+
const pushResult = runGit(repoPath, ["push", "origin", `HEAD:${branchRef(branch)}`]);
|
|
301
|
+
if (!pushResult.ok) {
|
|
302
|
+
throw new DeterministicGitError(
|
|
303
|
+
`Failed to push HEAD to '${pushTarget}': ${trimToNull(pushResult.stderr) ?? trimToNull(pushResult.stdout) ?? "unknown git error"}`
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
return pushTarget;
|
|
307
|
+
}
|
|
308
|
+
function assertLocalSourceBaseRef(input) {
|
|
309
|
+
const ref = branchRef(input.baseBranch);
|
|
310
|
+
const actualHeadSha = gitOrNull(input.localSourceRepoPath, "rev-parse", ref);
|
|
311
|
+
if (!actualHeadSha) {
|
|
312
|
+
throw new DeterministicGitError(
|
|
313
|
+
`Local source repo '${input.localSourceRepoPath}' does not have '${ref}' ${input.operation}`
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
if (actualHeadSha !== input.expectedHeadSha) {
|
|
317
|
+
throw new DeterministicGitError(
|
|
318
|
+
`Local source repo '${input.localSourceRepoPath}' has '${ref}' at '${actualHeadSha}', but expected '${input.expectedHeadSha}' ${input.operation}`
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
function assertLocalBareSourceRepoReady(localSourceRepoPath, baseBranch, expectedBaseSha) {
|
|
323
|
+
assertLocalSourceBaseRef({
|
|
324
|
+
localSourceRepoPath,
|
|
325
|
+
baseBranch,
|
|
326
|
+
expectedHeadSha: expectedBaseSha,
|
|
327
|
+
operation: "before finalization could publish the workspace branch. Retry finalization."
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
function pushLocalSourceBaseBranchToOriginIfPresent(input) {
|
|
331
|
+
if (!runGit(input.localSourceRepoPath, ["remote", "get-url", "origin"]).ok) {
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
assertLocalSourceBaseRef({
|
|
335
|
+
localSourceRepoPath: input.localSourceRepoPath,
|
|
336
|
+
baseBranch: input.baseBranch,
|
|
337
|
+
expectedHeadSha: input.expectedHeadSha,
|
|
338
|
+
operation: "before pushing it to its origin remote"
|
|
339
|
+
});
|
|
340
|
+
const ref = branchRef(input.baseBranch);
|
|
341
|
+
const pushTarget = originBaseRef(input.baseBranch);
|
|
342
|
+
const pushResult = runGit(input.localSourceRepoPath, ["push", "origin", `${ref}:${ref}`]);
|
|
343
|
+
if (!pushResult.ok) {
|
|
344
|
+
throw new DeterministicGitError(
|
|
345
|
+
`Failed to push local source repo '${input.localSourceRepoPath}' base branch '${input.baseBranch}' to '${pushTarget}': ${trimToNull(pushResult.stderr) ?? trimToNull(pushResult.stdout) ?? "unknown git error"}`
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
return pushTarget;
|
|
349
|
+
}
|
|
350
|
+
function assertLocalBaseRepoReady(localBaseRepoPath, baseBranch, expectedBaseSha) {
|
|
351
|
+
const branch = currentBranch(localBaseRepoPath);
|
|
352
|
+
if (branch !== baseBranch) {
|
|
353
|
+
throw new DeterministicGitError(
|
|
354
|
+
`Expected local source repo '${localBaseRepoPath}' to be checked out on '${baseBranch}', but found '${branch || "detached HEAD"}'`
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
if (mergeInProgress(localBaseRepoPath) || conflictedFiles(localBaseRepoPath).length > 0) {
|
|
358
|
+
throw new DeterministicGitError(
|
|
359
|
+
`Local source repo '${localBaseRepoPath}' must not already be in a merge-conflict state before finalization updates '${baseBranch}'`
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
const status = workingTreeStatus(localBaseRepoPath);
|
|
363
|
+
if (status.dirtyFiles.length > 0) {
|
|
364
|
+
throw new DeterministicGitError(
|
|
365
|
+
`Local source repo '${localBaseRepoPath}' must be clean before finalization updates '${baseBranch}': ${status.dirtyFiles.join(", ")}`
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
const actualBaseSha = currentHeadSha(localBaseRepoPath);
|
|
369
|
+
if (actualBaseSha !== expectedBaseSha) {
|
|
370
|
+
throw new DeterministicGitError(
|
|
371
|
+
`Local source repo '${localBaseRepoPath}' moved on '${baseBranch}' from '${expectedBaseSha}' to '${actualBaseSha}' before finalization could continue. Retry finalization.`
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
function mergeWorkBranchIntoLocalBaseRepo(input) {
|
|
376
|
+
assertLocalBaseRepoReady(input.localBaseRepoPath, input.baseBranch, input.expectedBaseSha);
|
|
377
|
+
const mergeResult = runGit(input.localBaseRepoPath, [
|
|
378
|
+
"merge",
|
|
379
|
+
"--ff-only",
|
|
380
|
+
`refs/heads/${input.workBranch}`
|
|
381
|
+
]);
|
|
382
|
+
if (!mergeResult.ok) {
|
|
383
|
+
throw new DeterministicGitError(
|
|
384
|
+
`Failed to fast-forward local source repo '${input.localBaseRepoPath}' branch '${input.baseBranch}' from '${input.workBranch}': ${trimToNull(mergeResult.stderr) ?? trimToNull(mergeResult.stdout) ?? "unknown git error"}`
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
const actualHeadSha = currentHeadSha(input.localBaseRepoPath);
|
|
388
|
+
if (actualHeadSha !== input.expectedHeadSha) {
|
|
389
|
+
throw new DeterministicGitError(
|
|
390
|
+
`Local source repo '${input.localBaseRepoPath}' finished finalization at '${actualHeadSha}', but expected '${input.expectedHeadSha}' after merging '${input.workBranch}' into '${input.baseBranch}'`
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
function updateLocalBaseRef(repoPath, baseBranch) {
|
|
395
|
+
const branch = currentBranch(repoPath);
|
|
396
|
+
if (branch === baseBranch) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
const updateResult = runGit(repoPath, ["branch", "--force", baseBranch, "HEAD"]);
|
|
400
|
+
if (!updateResult.ok) {
|
|
401
|
+
throw new DeterministicGitError(
|
|
402
|
+
`Failed to update the local '${baseBranch}' ref to the finalized HEAD: ${trimToNull(updateResult.stderr) ?? trimToNull(updateResult.stdout) ?? "unknown git error"}`
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
function buildFinalizationMarkdown(input) {
|
|
407
|
+
const lines = [
|
|
408
|
+
"## Finalized change",
|
|
409
|
+
"",
|
|
410
|
+
`- Repository workspace: ${input.workspaceClonePath}`,
|
|
411
|
+
`- Work branch: ${input.workBranch}`,
|
|
412
|
+
`- Base branch: ${input.baseBranch}`,
|
|
413
|
+
`- Merge result: ${describeMergeMode(input.mergeMode)}`
|
|
414
|
+
];
|
|
415
|
+
if (input.localSourceRepoPath) {
|
|
416
|
+
lines.push(
|
|
417
|
+
`- Local source repo: ${input.localSourceRepoPath} (${input.localSourceRepoKind === "bare" ? "bare" : "non-bare"})`
|
|
418
|
+
);
|
|
419
|
+
if (input.workspacePushTarget) {
|
|
420
|
+
lines.push(`- Workspace publish: HEAD -> ${input.workspacePushTarget}`);
|
|
421
|
+
}
|
|
422
|
+
if (input.localSourceRepoKind === "non_bare") {
|
|
423
|
+
lines.push(`- Base repo merge: ${input.workBranch} -> ${input.baseBranch}`);
|
|
424
|
+
}
|
|
425
|
+
if (input.sourceOriginPushTarget) {
|
|
426
|
+
lines.push(
|
|
427
|
+
`- Source origin push: ${branchRef(input.baseBranch)} -> ${input.sourceOriginPushTarget}`
|
|
428
|
+
);
|
|
429
|
+
} else {
|
|
430
|
+
lines.push("- Source origin push: skipped (local source repo has no origin remote)");
|
|
431
|
+
}
|
|
432
|
+
} else {
|
|
433
|
+
lines.push(`- Pushed: HEAD -> ${input.pushTarget}`);
|
|
434
|
+
}
|
|
435
|
+
lines.push(
|
|
436
|
+
`- Final HEAD: \`${abbreviateSha(input.headSha)}\``,
|
|
437
|
+
`- Conflict resolution used: ${input.usedConflictResolution ? "yes" : "no"}`
|
|
438
|
+
);
|
|
439
|
+
return lines.join("\n");
|
|
440
|
+
}
|
|
441
|
+
function runDeterministicFinalization(ctx) {
|
|
442
|
+
const repo = ctx.repo.get("repo");
|
|
443
|
+
const input = {
|
|
444
|
+
repoPath: repo.fsPath,
|
|
445
|
+
workspaceClonePath: repo.workspaceClonePath,
|
|
446
|
+
baseBranch: repo.baseBranch,
|
|
447
|
+
workBranch: repo.workBranch,
|
|
448
|
+
expectedPostConflictHeadSha: ctx.state.finalization.expectedPostConflictHeadSha,
|
|
449
|
+
usedConflictResolution: ctx.state.finalization.usedConflictResolution,
|
|
450
|
+
commitMessage: ctx.state.finalization.generatedCommitMessage ?? ""
|
|
451
|
+
};
|
|
452
|
+
const repoPath = path.resolve(input.repoPath);
|
|
453
|
+
if (!repoExists(repoPath)) {
|
|
454
|
+
throw new DeterministicGitError(
|
|
455
|
+
`Repository workspace '${repoPath}' does not exist or is not a git repository`
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
assertExpectedCheckout(repoPath, input.workBranch);
|
|
459
|
+
if (!trimToNull(input.commitMessage)) {
|
|
460
|
+
throw new DeterministicGitError(
|
|
461
|
+
"No generated commit message is available; retry commit-message generation before finalization"
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
assertPostConflictCheckpoint(input, repoPath);
|
|
465
|
+
let headSha = currentHeadSha(repoPath);
|
|
466
|
+
const conflicts = conflictedFiles(repoPath);
|
|
467
|
+
if (mergeInProgress(repoPath) || conflicts.length > 0) {
|
|
468
|
+
return {
|
|
469
|
+
outcome: "merge_conflict",
|
|
470
|
+
params: {
|
|
471
|
+
headSha,
|
|
472
|
+
conflictedFiles: conflicts,
|
|
473
|
+
fetchedBaseSha: null
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
const baseSha = fetchOriginBase(repoPath, input.baseBranch);
|
|
478
|
+
const localSourceRepo = resolveLocalSourceRepo(repoPath);
|
|
479
|
+
if (localSourceRepo?.kind === "non_bare") {
|
|
480
|
+
assertLocalBaseRepoReady(localSourceRepo.path, input.baseBranch, baseSha);
|
|
481
|
+
} else if (localSourceRepo?.kind === "bare") {
|
|
482
|
+
assertLocalBareSourceRepoReady(localSourceRepo.path, input.baseBranch, baseSha);
|
|
483
|
+
}
|
|
484
|
+
const status = workingTreeStatus(repoPath);
|
|
485
|
+
if (status.dirtyFiles.length > 0) {
|
|
486
|
+
headSha = commitDirtyWorktree(repoPath, input.commitMessage);
|
|
487
|
+
}
|
|
488
|
+
const mergeResult = deterministicMerge({
|
|
489
|
+
repoPath,
|
|
490
|
+
baseBranch: input.baseBranch,
|
|
491
|
+
headBefore: headSha,
|
|
492
|
+
baseSha
|
|
493
|
+
});
|
|
494
|
+
if (!mergeResult.ok) {
|
|
495
|
+
return {
|
|
496
|
+
outcome: "merge_conflict",
|
|
497
|
+
params: {
|
|
498
|
+
headSha: mergeResult.headSha,
|
|
499
|
+
conflictedFiles: mergeResult.conflictedFiles,
|
|
500
|
+
fetchedBaseSha: baseSha
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
let pushTarget;
|
|
505
|
+
let workspacePushTarget = null;
|
|
506
|
+
let sourceOriginPushTarget = null;
|
|
507
|
+
if (localSourceRepo?.kind === "non_bare") {
|
|
508
|
+
assertLocalBaseRepoReady(localSourceRepo.path, input.baseBranch, baseSha);
|
|
509
|
+
workspacePushTarget = pushHeadToBranch(repoPath, input.workBranch);
|
|
510
|
+
mergeWorkBranchIntoLocalBaseRepo({
|
|
511
|
+
localBaseRepoPath: localSourceRepo.path,
|
|
512
|
+
baseBranch: input.baseBranch,
|
|
513
|
+
workBranch: input.workBranch,
|
|
514
|
+
expectedBaseSha: baseSha,
|
|
515
|
+
expectedHeadSha: mergeResult.headSha
|
|
516
|
+
});
|
|
517
|
+
sourceOriginPushTarget = pushLocalSourceBaseBranchToOriginIfPresent({
|
|
518
|
+
localSourceRepoPath: localSourceRepo.path,
|
|
519
|
+
baseBranch: input.baseBranch,
|
|
520
|
+
expectedHeadSha: mergeResult.headSha
|
|
521
|
+
});
|
|
522
|
+
pushTarget = sourceOriginPushTarget ?? originBaseRef(input.baseBranch);
|
|
523
|
+
} else if (localSourceRepo?.kind === "bare") {
|
|
524
|
+
assertLocalBareSourceRepoReady(localSourceRepo.path, input.baseBranch, baseSha);
|
|
525
|
+
workspacePushTarget = pushHeadToBranch(repoPath, input.baseBranch);
|
|
526
|
+
sourceOriginPushTarget = pushLocalSourceBaseBranchToOriginIfPresent({
|
|
527
|
+
localSourceRepoPath: localSourceRepo.path,
|
|
528
|
+
baseBranch: input.baseBranch,
|
|
529
|
+
expectedHeadSha: mergeResult.headSha
|
|
530
|
+
});
|
|
531
|
+
pushTarget = sourceOriginPushTarget ?? workspacePushTarget;
|
|
532
|
+
} else {
|
|
533
|
+
pushTarget = pushHeadToBranch(repoPath, input.baseBranch);
|
|
534
|
+
}
|
|
535
|
+
updateLocalBaseRef(repoPath, input.baseBranch);
|
|
536
|
+
const finalHeadSha = currentHeadSha(repoPath);
|
|
537
|
+
return {
|
|
538
|
+
outcome: "finalized",
|
|
539
|
+
params: {
|
|
540
|
+
headSha: finalHeadSha,
|
|
541
|
+
mergeMode: mergeResult.mergeMode,
|
|
542
|
+
pushTarget,
|
|
543
|
+
usedConflictResolution: input.usedConflictResolution === true
|
|
544
|
+
},
|
|
545
|
+
markdown: buildFinalizationMarkdown({
|
|
546
|
+
workspaceClonePath: input.workspaceClonePath,
|
|
547
|
+
baseBranch: input.baseBranch,
|
|
548
|
+
workBranch: input.workBranch,
|
|
549
|
+
headSha: finalHeadSha,
|
|
550
|
+
mergeMode: mergeResult.mergeMode,
|
|
551
|
+
pushTarget,
|
|
552
|
+
localSourceRepoPath: localSourceRepo?.path ?? null,
|
|
553
|
+
localSourceRepoKind: localSourceRepo?.kind ?? null,
|
|
554
|
+
workspacePushTarget,
|
|
555
|
+
sourceOriginPushTarget,
|
|
556
|
+
usedConflictResolution: input.usedConflictResolution === true
|
|
557
|
+
})
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
function readMergeMessage(repoPath) {
|
|
561
|
+
const messagePath = path.resolve(repoPath, git(repoPath, "rev-parse", "--git-dir"), "MERGE_MSG");
|
|
562
|
+
if (!existsSync(messagePath)) {
|
|
563
|
+
return null;
|
|
564
|
+
}
|
|
565
|
+
return trimToNull(readFileSync(messagePath, "utf8"));
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
export {
|
|
569
|
+
DeterministicGitError,
|
|
570
|
+
runDeterministicFinalization,
|
|
571
|
+
readMergeMessage
|
|
572
|
+
};
|
|
573
|
+
//# sourceMappingURL=chunk-JZU3UVR6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/finalization-git.ts"],"sourcesContent":["import { execFileSync } from \"node:child_process\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { detectRepoLocatorKind, trimToNull, type WorkerErrorClass } from \"@leitwerk-dev/domain\";\nimport {\n\ttype FlowAutomaticRunContext,\n\trepositoryGitArgs,\n\trepositoryGitSubprocessEnv,\n\ttype StructuralProcessState,\n} from \"@leitwerk-dev/process-sdk\";\nimport { resolveGitBinary } from \"@leitwerk-dev/process-sdk/git-binary\";\n\nexport type DeterministicFinalizationMergeMode = \"noop\" | \"fast_forward\" | \"merge_commit\";\n\ninterface DeterministicFinalizationInput {\n\trepoPath: string;\n\tworkspaceClonePath: string;\n\tbaseBranch: string;\n\tworkBranch: string;\n\texpectedPostConflictHeadSha?: string | null;\n\tusedConflictResolution?: boolean;\n\tcommitMessage: string;\n}\n\nexport type DeterministicFinalizationResult =\n\t| {\n\t\t\toutcome: \"merge_conflict\";\n\t\t\tparams: {\n\t\t\t\theadSha: string;\n\t\t\t\tconflictedFiles: string[];\n\t\t\t\tfetchedBaseSha: string | null;\n\t\t\t};\n\t }\n\t| {\n\t\t\toutcome: \"finalized\";\n\t\t\tparams: {\n\t\t\t\theadSha: string;\n\t\t\t\tmergeMode: DeterministicFinalizationMergeMode;\n\t\t\t\tpushTarget: string;\n\t\t\t\tusedConflictResolution: boolean;\n\t\t\t};\n\t\t\tmarkdown: string;\n\t };\n\nexport class DeterministicGitError extends Error {\n\treadonly errorClass: WorkerErrorClass = \"git_error\";\n\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"DeterministicGitError\";\n\t}\n}\n\ninterface GitExecResult {\n\tok: boolean;\n\tstdout: string;\n\tstderr: string;\n\tstatus: number | null;\n}\n\ninterface LocalSourceRepo {\n\tpath: string;\n\tkind: \"bare\" | \"non_bare\";\n}\n\nfunction normalizeLines(value: string | null | undefined): string[] {\n\tif (!value) {\n\t\treturn [];\n\t}\n\treturn value\n\t\t.split(/\\r?\\n/)\n\t\t.map((line) => line.trim())\n\t\t.filter((line) => line !== \"\");\n}\n\nfunction abbreviateSha(sha: string): string {\n\treturn sha.slice(0, 12);\n}\n\nfunction describeMergeMode(mode: DeterministicFinalizationMergeMode): string {\n\tswitch (mode) {\n\t\tcase \"noop\":\n\t\t\treturn \"Already up to date\";\n\t\tcase \"fast_forward\":\n\t\t\treturn \"Fast-forwarded from origin\";\n\t\tcase \"merge_commit\":\n\t\t\treturn \"Created a merge commit\";\n\t}\n}\n\nfunction gitConfigIdentityEnv(): NodeJS.ProcessEnv {\n\tconst env = repositoryGitSubprocessEnv(\"repo\", { GIT_TERMINAL_PROMPT: \"0\" });\n\t// Identity is operator-owned repository/global Git configuration, never an\n\t// ambient worker identity or a Leitwerk override.\n\tfor (const key of [\n\t\t\"GIT_AUTHOR_NAME\",\n\t\t\"GIT_AUTHOR_EMAIL\",\n\t\t\"GIT_AUTHOR_DATE\",\n\t\t\"GIT_COMMITTER_NAME\",\n\t\t\"GIT_COMMITTER_EMAIL\",\n\t\t\"GIT_COMMITTER_DATE\",\n\t])\n\t\tdelete env[key];\n\treturn env;\n}\n\nfunction runGit(repoPath: string, args: readonly string[]): GitExecResult {\n\ttry {\n\t\tconst stdout = execFileSync(resolveGitBinary(), repositoryGitArgs(args), {\n\t\t\tcwd: repoPath,\n\t\t\tencoding: \"utf8\",\n\t\t\tenv: gitConfigIdentityEnv(),\n\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t});\n\t\treturn {\n\t\t\tok: true,\n\t\t\tstdout,\n\t\t\tstderr: \"\",\n\t\t\tstatus: 0,\n\t\t};\n\t} catch (error) {\n\t\tconst execError = error as {\n\t\t\tstatus?: number | null;\n\t\t\tstdout?: string | Buffer;\n\t\t\tstderr?: string | Buffer;\n\t\t\tmessage?: string;\n\t\t};\n\t\treturn {\n\t\t\tok: false,\n\t\t\tstdout:\n\t\t\t\ttypeof execError.stdout === \"string\"\n\t\t\t\t\t? execError.stdout\n\t\t\t\t\t: execError.stdout\n\t\t\t\t\t\t? execError.stdout.toString(\"utf8\")\n\t\t\t\t\t\t: \"\",\n\t\t\tstderr:\n\t\t\t\ttypeof execError.stderr === \"string\"\n\t\t\t\t\t? execError.stderr\n\t\t\t\t\t: execError.stderr\n\t\t\t\t\t\t? execError.stderr.toString(\"utf8\")\n\t\t\t\t\t\t: (trimToNull(execError.message) ?? \"\"),\n\t\t\tstatus: execError.status ?? null,\n\t\t};\n\t}\n}\n\nfunction git(repoPath: string, ...args: string[]): string {\n\tconst result = runGit(repoPath, args);\n\tif (!result.ok) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`git ${args.join(\" \")} failed in '${repoPath}': ${trimToNull(result.stderr) ?? trimToNull(result.stdout) ?? \"unknown git error\"}`,\n\t\t);\n\t}\n\treturn result.stdout.trim();\n}\n\nfunction gitOrNull(repoPath: string, ...args: string[]): string | null {\n\tconst result = runGit(repoPath, args);\n\tif (!result.ok) {\n\t\treturn null;\n\t}\n\treturn trimToNull(result.stdout);\n}\n\nfunction repoExists(repoPath: string): boolean {\n\treturn existsSync(repoPath) && existsSync(path.join(repoPath, \".git\"));\n}\n\nfunction gitRepositoryExists(repoPath: string): boolean {\n\treturn existsSync(repoPath) && runGit(repoPath, [\"rev-parse\", \"--git-dir\"]).ok;\n}\n\nfunction currentBranch(repoPath: string): string {\n\treturn git(repoPath, \"branch\", \"--show-current\");\n}\n\nfunction currentHeadSha(repoPath: string): string {\n\treturn git(repoPath, \"rev-parse\", \"HEAD\");\n}\n\nfunction originBaseRef(baseBranch: string): string {\n\treturn `origin/${baseBranch}`;\n}\n\nfunction remoteOriginUrl(repoPath: string): string {\n\tconst remoteUrl = gitOrNull(repoPath, \"remote\", \"get-url\", \"origin\");\n\tif (!remoteUrl) {\n\t\tthrow new DeterministicGitError(`Repository '${repoPath}' does not have an 'origin' remote`);\n\t}\n\treturn remoteUrl;\n}\n\nfunction expandHomePath(value: string): string {\n\tif (value === \"~\") {\n\t\treturn homedir();\n\t}\n\tif (value.startsWith(\"~/\")) {\n\t\treturn path.join(homedir(), value.slice(2));\n\t}\n\treturn value;\n}\n\nfunction resolveLocalRepoPath(repoPath: string, repoLocator: string): string | null {\n\tif (detectRepoLocatorKind(repoLocator) !== \"local_path\") {\n\t\treturn null;\n\t}\n\tif (repoLocator.startsWith(\"file://\")) {\n\t\ttry {\n\t\t\treturn fileURLToPath(repoLocator);\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\treturn path.resolve(repoPath, expandHomePath(repoLocator));\n}\n\nfunction isBareRepository(repoPath: string): boolean {\n\treturn git(repoPath, \"rev-parse\", \"--is-bare-repository\") === \"true\";\n}\n\nfunction resolveLocalSourceRepo(repoPath: string): LocalSourceRepo | null {\n\tconst remoteUrl = remoteOriginUrl(repoPath);\n\tconst localRepoPath = resolveLocalRepoPath(repoPath, remoteUrl);\n\tif (!localRepoPath || !gitRepositoryExists(localRepoPath)) {\n\t\treturn null;\n\t}\n\treturn {\n\t\tpath: localRepoPath,\n\t\tkind: isBareRepository(localRepoPath) ? \"bare\" : \"non_bare\",\n\t};\n}\n\nfunction workingTreeStatus(repoPath: string): { dirtyFiles: string[] } {\n\tconst rawStatus = gitOrNull(repoPath, \"status\", \"--porcelain\");\n\tconst dirtyFiles = (rawStatus ?? \"\")\n\t\t.split(/\\r?\\n/)\n\t\t.map((line) => line.replace(/\\s+$/, \"\"))\n\t\t.filter((line) => line !== \"\")\n\t\t.map((line) => line.slice(2).trim())\n\t\t.filter((line) => line !== \"\");\n\treturn { dirtyFiles };\n}\n\nfunction conflictedFiles(repoPath: string): string[] {\n\treturn normalizeLines(gitOrNull(repoPath, \"diff\", \"--name-only\", \"--diff-filter=U\"));\n}\n\nfunction mergeHeadPath(repoPath: string): string {\n\tconst gitDir = git(repoPath, \"rev-parse\", \"--git-dir\");\n\treturn path.resolve(repoPath, gitDir, \"MERGE_HEAD\");\n}\n\nfunction mergeInProgress(repoPath: string): boolean {\n\treturn existsSync(mergeHeadPath(repoPath));\n}\n\nfunction assertExpectedCheckout(repoPath: string, workBranch: string): void {\n\tconst branch = currentBranch(repoPath);\n\tif (branch !== workBranch) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Expected '${repoPath}' to be checked out on '${workBranch}', but found '${branch || \"detached HEAD\"}'`,\n\t\t);\n\t}\n}\n\nfunction assertGitIdentity(repoPath: string): void {\n\tconst author = runGit(repoPath, [\"var\", \"GIT_AUTHOR_IDENT\"]);\n\tconst committer = runGit(repoPath, [\"var\", \"GIT_COMMITTER_IDENT\"]);\n\tif (!author.ok || !committer.ok) {\n\t\tthrow new DeterministicGitError(\n\t\t\t\"Git author/committer identity is not configured. Configure user.name and user.email in this repository or the operator's global Git config, then retry finalization.\",\n\t\t);\n\t}\n}\n\nfunction commitDirtyWorktree(repoPath: string, commitMessage: string): string {\n\tassertGitIdentity(repoPath);\n\tconst addResult = runGit(repoPath, [\"add\", \"--all\"]);\n\tif (!addResult.ok) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Failed to stage the completed change: ${trimToNull(addResult.stderr) ?? trimToNull(addResult.stdout) ?? \"unknown git error\"}`,\n\t\t);\n\t}\n\tconst commitResult = runGit(repoPath, [\n\t\t\"-c\",\n\t\t\"core.hooksPath=/dev/null\",\n\t\t\"commit\",\n\t\t\"--no-gpg-sign\",\n\t\t\"-m\",\n\t\tcommitMessage,\n\t]);\n\tif (!commitResult.ok) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Failed to commit the completed change: ${trimToNull(commitResult.stderr) ?? trimToNull(commitResult.stdout) ?? \"unknown git error\"}`,\n\t\t);\n\t}\n\tconst remaining = workingTreeStatus(repoPath);\n\tif (remaining.dirtyFiles.length > 0) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Deterministic commit left uncommitted changes: ${remaining.dirtyFiles.join(\", \")}`,\n\t\t);\n\t}\n\treturn currentHeadSha(repoPath);\n}\n\nfunction assertPostConflictCheckpoint(\n\tinput: DeterministicFinalizationInput,\n\trepoPath: string,\n): void {\n\tif (!trimToNull(input.expectedPostConflictHeadSha)) {\n\t\treturn;\n\t}\n\tif (mergeInProgress(repoPath) || conflictedFiles(repoPath).length > 0) {\n\t\tthrow new DeterministicGitError(\n\t\t\t\"Conflict-resolution helper reported a clean merge, but the repository is still in a merge-conflict state\",\n\t\t);\n\t}\n\tconst status = workingTreeStatus(repoPath);\n\tif (status.dirtyFiles.length > 0) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Conflict-resolution helper reported a clean merge, but the repository still has uncommitted changes: ${status.dirtyFiles.join(\", \")}`,\n\t\t);\n\t}\n}\n\nfunction fetchOriginBase(repoPath: string, baseBranch: string): string {\n\tconst ref = originBaseRef(baseBranch);\n\tconst fetchResult = runGit(repoPath, [\"fetch\", \"origin\", baseBranch]);\n\tif (!fetchResult.ok) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Failed to fetch '${ref}': ${trimToNull(fetchResult.stderr) ?? trimToNull(fetchResult.stdout) ?? \"unknown git error\"}`,\n\t\t);\n\t}\n\tconst baseSha = gitOrNull(repoPath, \"rev-parse\", ref);\n\tif (!baseSha) {\n\t\tthrow new DeterministicGitError(`Fetched '${ref}' but could not resolve its commit sha`);\n\t}\n\treturn baseSha;\n}\n\nfunction isAncestor(repoPath: string, olderRef: string, newerRef: string): boolean {\n\treturn runGit(repoPath, [\"merge-base\", \"--is-ancestor\", olderRef, newerRef]).ok;\n}\n\nfunction deterministicMerge(input: {\n\trepoPath: string;\n\tbaseBranch: string;\n\theadBefore: string;\n\tbaseSha: string;\n}):\n\t| { ok: true; mergeMode: DeterministicFinalizationMergeMode; headSha: string }\n\t| { ok: false; conflict: true; headSha: string; conflictedFiles: string[] } {\n\tconst { repoPath, baseBranch, headBefore, baseSha } = input;\n\tconst ref = originBaseRef(baseBranch);\n\tconst headIsAncestorOfBase = isAncestor(repoPath, headBefore, ref);\n\tconst baseIsAncestorOfHead = isAncestor(repoPath, ref, headBefore);\n\n\tif (baseIsAncestorOfHead) {\n\t\treturn { ok: true, mergeMode: \"noop\", headSha: headBefore };\n\t}\n\n\tif (headIsAncestorOfBase) {\n\t\tconst ffResult = runGit(repoPath, [\"merge\", \"--ff-only\", ref]);\n\t\tif (!ffResult.ok) {\n\t\t\tthrow new DeterministicGitError(\n\t\t\t\t`Fast-forward merge from '${ref}' failed: ${trimToNull(ffResult.stderr) ?? trimToNull(ffResult.stdout) ?? \"unknown git error\"}`,\n\t\t\t);\n\t\t}\n\t\treturn {\n\t\t\tok: true,\n\t\t\tmergeMode: \"fast_forward\",\n\t\t\theadSha: currentHeadSha(repoPath),\n\t\t};\n\t}\n\n\tassertGitIdentity(repoPath);\n\tconst mergeResult = runGit(repoPath, [\n\t\t\"-c\",\n\t\t\"core.hooksPath=/dev/null\",\n\t\t\"merge\",\n\t\t\"--no-edit\",\n\t\t\"--no-gpg-sign\",\n\t\tref,\n\t]);\n\tif (!mergeResult.ok) {\n\t\tconst conflicts = conflictedFiles(repoPath);\n\t\tif (mergeInProgress(repoPath) || conflicts.length > 0) {\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\tconflict: true,\n\t\t\t\theadSha: currentHeadSha(repoPath),\n\t\t\t\tconflictedFiles: conflicts,\n\t\t\t};\n\t\t}\n\t\tthrow new DeterministicGitError(\n\t\t\t`Deterministic merge from '${ref}' failed: ${trimToNull(mergeResult.stderr) ?? trimToNull(mergeResult.stdout) ?? \"unknown git error\"}`,\n\t\t);\n\t}\n\n\tconst headAfter = currentHeadSha(repoPath);\n\treturn {\n\t\tok: true,\n\t\tmergeMode: headAfter === baseSha ? \"fast_forward\" : \"merge_commit\",\n\t\theadSha: headAfter,\n\t};\n}\n\nfunction branchRef(branch: string): string {\n\treturn `refs/heads/${branch}`;\n}\n\nfunction pushHeadToBranch(repoPath: string, branch: string): string {\n\tconst pushTarget = `origin/${branch}`;\n\tconst pushResult = runGit(repoPath, [\"push\", \"origin\", `HEAD:${branchRef(branch)}`]);\n\tif (!pushResult.ok) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Failed to push HEAD to '${pushTarget}': ${trimToNull(pushResult.stderr) ?? trimToNull(pushResult.stdout) ?? \"unknown git error\"}`,\n\t\t);\n\t}\n\treturn pushTarget;\n}\n\nfunction assertLocalSourceBaseRef(input: {\n\tlocalSourceRepoPath: string;\n\tbaseBranch: string;\n\texpectedHeadSha: string;\n\toperation: string;\n}): void {\n\tconst ref = branchRef(input.baseBranch);\n\tconst actualHeadSha = gitOrNull(input.localSourceRepoPath, \"rev-parse\", ref);\n\tif (!actualHeadSha) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Local source repo '${input.localSourceRepoPath}' does not have '${ref}' ${input.operation}`,\n\t\t);\n\t}\n\tif (actualHeadSha !== input.expectedHeadSha) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Local source repo '${input.localSourceRepoPath}' has '${ref}' at '${actualHeadSha}', but expected '${input.expectedHeadSha}' ${input.operation}`,\n\t\t);\n\t}\n}\n\nfunction assertLocalBareSourceRepoReady(\n\tlocalSourceRepoPath: string,\n\tbaseBranch: string,\n\texpectedBaseSha: string,\n): void {\n\tassertLocalSourceBaseRef({\n\t\tlocalSourceRepoPath,\n\t\tbaseBranch,\n\t\texpectedHeadSha: expectedBaseSha,\n\t\toperation: \"before finalization could publish the workspace branch. Retry finalization.\",\n\t});\n}\n\nfunction pushLocalSourceBaseBranchToOriginIfPresent(input: {\n\tlocalSourceRepoPath: string;\n\tbaseBranch: string;\n\texpectedHeadSha: string;\n}): string | null {\n\tif (!runGit(input.localSourceRepoPath, [\"remote\", \"get-url\", \"origin\"]).ok) {\n\t\treturn null;\n\t}\n\tassertLocalSourceBaseRef({\n\t\tlocalSourceRepoPath: input.localSourceRepoPath,\n\t\tbaseBranch: input.baseBranch,\n\t\texpectedHeadSha: input.expectedHeadSha,\n\t\toperation: \"before pushing it to its origin remote\",\n\t});\n\tconst ref = branchRef(input.baseBranch);\n\tconst pushTarget = originBaseRef(input.baseBranch);\n\tconst pushResult = runGit(input.localSourceRepoPath, [\"push\", \"origin\", `${ref}:${ref}`]);\n\tif (!pushResult.ok) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Failed to push local source repo '${input.localSourceRepoPath}' base branch '${input.baseBranch}' to '${pushTarget}': ${trimToNull(pushResult.stderr) ?? trimToNull(pushResult.stdout) ?? \"unknown git error\"}`,\n\t\t);\n\t}\n\treturn pushTarget;\n}\n\nfunction assertLocalBaseRepoReady(\n\tlocalBaseRepoPath: string,\n\tbaseBranch: string,\n\texpectedBaseSha: string,\n): void {\n\tconst branch = currentBranch(localBaseRepoPath);\n\tif (branch !== baseBranch) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Expected local source repo '${localBaseRepoPath}' to be checked out on '${baseBranch}', but found '${branch || \"detached HEAD\"}'`,\n\t\t);\n\t}\n\tif (mergeInProgress(localBaseRepoPath) || conflictedFiles(localBaseRepoPath).length > 0) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Local source repo '${localBaseRepoPath}' must not already be in a merge-conflict state before finalization updates '${baseBranch}'`,\n\t\t);\n\t}\n\tconst status = workingTreeStatus(localBaseRepoPath);\n\tif (status.dirtyFiles.length > 0) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Local source repo '${localBaseRepoPath}' must be clean before finalization updates '${baseBranch}': ${status.dirtyFiles.join(\", \")}`,\n\t\t);\n\t}\n\tconst actualBaseSha = currentHeadSha(localBaseRepoPath);\n\tif (actualBaseSha !== expectedBaseSha) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Local source repo '${localBaseRepoPath}' moved on '${baseBranch}' from '${expectedBaseSha}' to '${actualBaseSha}' before finalization could continue. Retry finalization.`,\n\t\t);\n\t}\n}\n\nfunction mergeWorkBranchIntoLocalBaseRepo(input: {\n\tlocalBaseRepoPath: string;\n\tbaseBranch: string;\n\tworkBranch: string;\n\texpectedBaseSha: string;\n\texpectedHeadSha: string;\n}): void {\n\tassertLocalBaseRepoReady(input.localBaseRepoPath, input.baseBranch, input.expectedBaseSha);\n\tconst mergeResult = runGit(input.localBaseRepoPath, [\n\t\t\"merge\",\n\t\t\"--ff-only\",\n\t\t`refs/heads/${input.workBranch}`,\n\t]);\n\tif (!mergeResult.ok) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Failed to fast-forward local source repo '${input.localBaseRepoPath}' branch '${input.baseBranch}' from '${input.workBranch}': ${trimToNull(mergeResult.stderr) ?? trimToNull(mergeResult.stdout) ?? \"unknown git error\"}`,\n\t\t);\n\t}\n\tconst actualHeadSha = currentHeadSha(input.localBaseRepoPath);\n\tif (actualHeadSha !== input.expectedHeadSha) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Local source repo '${input.localBaseRepoPath}' finished finalization at '${actualHeadSha}', but expected '${input.expectedHeadSha}' after merging '${input.workBranch}' into '${input.baseBranch}'`,\n\t\t);\n\t}\n}\n\nfunction updateLocalBaseRef(repoPath: string, baseBranch: string): void {\n\tconst branch = currentBranch(repoPath);\n\tif (branch === baseBranch) {\n\t\treturn;\n\t}\n\tconst updateResult = runGit(repoPath, [\"branch\", \"--force\", baseBranch, \"HEAD\"]);\n\tif (!updateResult.ok) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Failed to update the local '${baseBranch}' ref to the finalized HEAD: ${trimToNull(updateResult.stderr) ?? trimToNull(updateResult.stdout) ?? \"unknown git error\"}`,\n\t\t);\n\t}\n}\n\nfunction buildFinalizationMarkdown(input: {\n\tworkspaceClonePath: string;\n\tbaseBranch: string;\n\tworkBranch: string;\n\theadSha: string;\n\tmergeMode: DeterministicFinalizationMergeMode;\n\tpushTarget: string;\n\tlocalSourceRepoPath: string | null;\n\tlocalSourceRepoKind: LocalSourceRepo[\"kind\"] | null;\n\tworkspacePushTarget: string | null;\n\tsourceOriginPushTarget: string | null;\n\tusedConflictResolution: boolean;\n}): string {\n\tconst lines = [\n\t\t\"## Finalized change\",\n\t\t\"\",\n\t\t`- Repository workspace: ${input.workspaceClonePath}`,\n\t\t`- Work branch: ${input.workBranch}`,\n\t\t`- Base branch: ${input.baseBranch}`,\n\t\t`- Merge result: ${describeMergeMode(input.mergeMode)}`,\n\t];\n\tif (input.localSourceRepoPath) {\n\t\tlines.push(\n\t\t\t`- Local source repo: ${input.localSourceRepoPath} (${input.localSourceRepoKind === \"bare\" ? \"bare\" : \"non-bare\"})`,\n\t\t);\n\t\tif (input.workspacePushTarget) {\n\t\t\tlines.push(`- Workspace publish: HEAD -> ${input.workspacePushTarget}`);\n\t\t}\n\t\tif (input.localSourceRepoKind === \"non_bare\") {\n\t\t\tlines.push(`- Base repo merge: ${input.workBranch} -> ${input.baseBranch}`);\n\t\t}\n\t\tif (input.sourceOriginPushTarget) {\n\t\t\tlines.push(\n\t\t\t\t`- Source origin push: ${branchRef(input.baseBranch)} -> ${input.sourceOriginPushTarget}`,\n\t\t\t);\n\t\t} else {\n\t\t\tlines.push(\"- Source origin push: skipped (local source repo has no origin remote)\");\n\t\t}\n\t} else {\n\t\tlines.push(`- Pushed: HEAD -> ${input.pushTarget}`);\n\t}\n\tlines.push(\n\t\t`- Final HEAD: \\`${abbreviateSha(input.headSha)}\\``,\n\t\t`- Conflict resolution used: ${input.usedConflictResolution ? \"yes\" : \"no\"}`,\n\t);\n\treturn lines.join(\"\\n\");\n}\n\nexport interface RepositoryChangeFinalizationContextState extends StructuralProcessState {\n\tfinalization: {\n\t\texpectedPostConflictHeadSha: string | null;\n\t\tusedConflictResolution: boolean;\n\t\tgeneratedCommitMessage: string | null;\n\t};\n}\n\nexport function runDeterministicFinalization<\n\tTParams,\n\tTState extends RepositoryChangeFinalizationContextState,\n>(ctx: FlowAutomaticRunContext<TParams, TState>): DeterministicFinalizationResult {\n\tconst repo = ctx.repo.get(\"repo\");\n\tconst input: DeterministicFinalizationInput = {\n\t\trepoPath: repo.fsPath,\n\t\tworkspaceClonePath: repo.workspaceClonePath,\n\t\tbaseBranch: repo.baseBranch,\n\t\tworkBranch: repo.workBranch,\n\t\texpectedPostConflictHeadSha: ctx.state.finalization.expectedPostConflictHeadSha,\n\t\tusedConflictResolution: ctx.state.finalization.usedConflictResolution,\n\t\tcommitMessage: ctx.state.finalization.generatedCommitMessage ?? \"\",\n\t};\n\tconst repoPath = path.resolve(input.repoPath);\n\tif (!repoExists(repoPath)) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Repository workspace '${repoPath}' does not exist or is not a git repository`,\n\t\t);\n\t}\n\tassertExpectedCheckout(repoPath, input.workBranch);\n\tif (!trimToNull(input.commitMessage)) {\n\t\tthrow new DeterministicGitError(\n\t\t\t\"No generated commit message is available; retry commit-message generation before finalization\",\n\t\t);\n\t}\n\tassertPostConflictCheckpoint(input, repoPath);\n\n\tlet headSha = currentHeadSha(repoPath);\n\tconst conflicts = conflictedFiles(repoPath);\n\tif (mergeInProgress(repoPath) || conflicts.length > 0) {\n\t\treturn {\n\t\t\toutcome: \"merge_conflict\",\n\t\t\tparams: {\n\t\t\t\theadSha,\n\t\t\t\tconflictedFiles: conflicts,\n\t\t\t\tfetchedBaseSha: null,\n\t\t\t},\n\t\t};\n\t}\n\n\tconst baseSha = fetchOriginBase(repoPath, input.baseBranch);\n\tconst localSourceRepo = resolveLocalSourceRepo(repoPath);\n\tif (localSourceRepo?.kind === \"non_bare\") {\n\t\tassertLocalBaseRepoReady(localSourceRepo.path, input.baseBranch, baseSha);\n\t} else if (localSourceRepo?.kind === \"bare\") {\n\t\tassertLocalBareSourceRepoReady(localSourceRepo.path, input.baseBranch, baseSha);\n\t}\n\n\tconst status = workingTreeStatus(repoPath);\n\tif (status.dirtyFiles.length > 0) {\n\t\theadSha = commitDirtyWorktree(repoPath, input.commitMessage);\n\t}\n\tconst mergeResult = deterministicMerge({\n\t\trepoPath,\n\t\tbaseBranch: input.baseBranch,\n\t\theadBefore: headSha,\n\t\tbaseSha,\n\t});\n\tif (!mergeResult.ok) {\n\t\treturn {\n\t\t\toutcome: \"merge_conflict\",\n\t\t\tparams: {\n\t\t\t\theadSha: mergeResult.headSha,\n\t\t\t\tconflictedFiles: mergeResult.conflictedFiles,\n\t\t\t\tfetchedBaseSha: baseSha,\n\t\t\t},\n\t\t};\n\t}\n\n\tlet pushTarget: string;\n\tlet workspacePushTarget: string | null = null;\n\tlet sourceOriginPushTarget: string | null = null;\n\tif (localSourceRepo?.kind === \"non_bare\") {\n\t\tassertLocalBaseRepoReady(localSourceRepo.path, input.baseBranch, baseSha);\n\t\tworkspacePushTarget = pushHeadToBranch(repoPath, input.workBranch);\n\t\tmergeWorkBranchIntoLocalBaseRepo({\n\t\t\tlocalBaseRepoPath: localSourceRepo.path,\n\t\t\tbaseBranch: input.baseBranch,\n\t\t\tworkBranch: input.workBranch,\n\t\t\texpectedBaseSha: baseSha,\n\t\t\texpectedHeadSha: mergeResult.headSha,\n\t\t});\n\t\tsourceOriginPushTarget = pushLocalSourceBaseBranchToOriginIfPresent({\n\t\t\tlocalSourceRepoPath: localSourceRepo.path,\n\t\t\tbaseBranch: input.baseBranch,\n\t\t\texpectedHeadSha: mergeResult.headSha,\n\t\t});\n\t\tpushTarget = sourceOriginPushTarget ?? originBaseRef(input.baseBranch);\n\t} else if (localSourceRepo?.kind === \"bare\") {\n\t\tassertLocalBareSourceRepoReady(localSourceRepo.path, input.baseBranch, baseSha);\n\t\tworkspacePushTarget = pushHeadToBranch(repoPath, input.baseBranch);\n\t\tsourceOriginPushTarget = pushLocalSourceBaseBranchToOriginIfPresent({\n\t\t\tlocalSourceRepoPath: localSourceRepo.path,\n\t\t\tbaseBranch: input.baseBranch,\n\t\t\texpectedHeadSha: mergeResult.headSha,\n\t\t});\n\t\tpushTarget = sourceOriginPushTarget ?? workspacePushTarget;\n\t} else {\n\t\tpushTarget = pushHeadToBranch(repoPath, input.baseBranch);\n\t}\n\tupdateLocalBaseRef(repoPath, input.baseBranch);\n\tconst finalHeadSha = currentHeadSha(repoPath);\n\treturn {\n\t\toutcome: \"finalized\",\n\t\tparams: {\n\t\t\theadSha: finalHeadSha,\n\t\t\tmergeMode: mergeResult.mergeMode,\n\t\t\tpushTarget,\n\t\t\tusedConflictResolution: input.usedConflictResolution === true,\n\t\t},\n\t\tmarkdown: buildFinalizationMarkdown({\n\t\t\tworkspaceClonePath: input.workspaceClonePath,\n\t\t\tbaseBranch: input.baseBranch,\n\t\t\tworkBranch: input.workBranch,\n\t\t\theadSha: finalHeadSha,\n\t\t\tmergeMode: mergeResult.mergeMode,\n\t\t\tpushTarget,\n\t\t\tlocalSourceRepoPath: localSourceRepo?.path ?? null,\n\t\t\tlocalSourceRepoKind: localSourceRepo?.kind ?? null,\n\t\t\tworkspacePushTarget,\n\t\t\tsourceOriginPushTarget,\n\t\t\tusedConflictResolution: input.usedConflictResolution === true,\n\t\t}),\n\t};\n}\n\nexport function readMergeMessage(repoPath: string): string | null {\n\tconst messagePath = path.resolve(repoPath, git(repoPath, \"rev-parse\", \"--git-dir\"), \"MERGE_MSG\");\n\tif (!existsSync(messagePath)) {\n\t\treturn null;\n\t}\n\treturn trimToNull(readFileSync(messagePath, \"utf8\"));\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,oBAAoB;AACzC,SAAS,eAAe;AACxB,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB,kBAAyC;AACzE;AAAA,EAEC;AAAA,EACA;AAAA,OAEM;AACP,SAAS,wBAAwB;AAkC1B,IAAM,wBAAN,cAAoC,MAAM;AAAA,EACvC,aAA+B;AAAA,EAExC,YAAY,SAAiB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACb;AACD;AAcA,SAAS,eAAe,OAA4C;AACnE,MAAI,CAAC,OAAO;AACX,WAAO,CAAC;AAAA,EACT;AACA,SAAO,MACL,MAAM,OAAO,EACb,IAAI,CAAC,SAAS,KAAK,KAAK,CAAC,EACzB,OAAO,CAAC,SAAS,SAAS,EAAE;AAC/B;AAEA,SAAS,cAAc,KAAqB;AAC3C,SAAO,IAAI,MAAM,GAAG,EAAE;AACvB;AAEA,SAAS,kBAAkB,MAAkD;AAC5E,UAAQ,MAAM;AAAA,IACb,KAAK;AACJ,aAAO;AAAA,IACR,KAAK;AACJ,aAAO;AAAA,IACR,KAAK;AACJ,aAAO;AAAA,EACT;AACD;AAEA,SAAS,uBAA0C;AAClD,QAAM,MAAM,2BAA2B,QAAQ,EAAE,qBAAqB,IAAI,CAAC;AAG3E,aAAW,OA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