@leitwerk-dev/coding 0.5.11 → 0.5.13
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 +1 -0
- package/dist/{chunk-E3DB4TIZ.js → chunk-DVQWH5SN.js} +22 -2
- package/dist/chunk-DVQWH5SN.js.map +1 -0
- package/dist/{chunk-VG6XF3OK.js → chunk-MCD2KII3.js} +27 -17
- package/dist/chunk-MCD2KII3.js.map +1 -0
- package/dist/{chunk-DNG7D77K.js → chunk-NZOQQZOA.js} +4 -2
- package/dist/chunk-NZOQQZOA.js.map +1 -0
- package/dist/{chunk-JL53OV5M.js → chunk-SJXIMPUS.js} +65 -58
- package/dist/chunk-SJXIMPUS.js.map +1 -0
- package/dist/finalization-git-internal.d.ts +4 -0
- package/dist/finalization-git-internal.d.ts.map +1 -1
- package/dist/finalization-git.js +2 -2
- package/dist/index.js +3 -3
- package/dist/{repository-change-launch-internal-CP2jJJCR.d.ts → repository-change-launch-internal-D_QWCQAN.d.ts} +1 -1
- package/dist/{repository-change-process-DbcnkzLw.d.ts → repository-change-process-Dc-jsbCL.d.ts} +2 -0
- package/dist/repository-change-process.d.ts +2 -0
- package/dist/repository-change-process.d.ts.map +1 -1
- package/dist/repository-change-publication.d.ts +4 -0
- package/dist/repository-change-publication.d.ts.map +1 -1
- package/dist/repository-change-publication.js +57 -49
- package/dist/repository-change-publication.js.map +1 -1
- package/dist/repository-reconciliation.d.ts +21 -15
- package/dist/repository-reconciliation.d.ts.map +1 -1
- package/dist/submodule-staging.d.ts +11 -0
- package/dist/submodule-staging.d.ts.map +1 -0
- package/dist/turns/generate-commit-message.d.ts.map +1 -1
- package/dist/turns/generate-commit-message.js +1 -1
- package/package.json +5 -5
- package/src/finalization-git-internal.ts +28 -20
- package/src/repository-change-process.ts +37 -16
- package/src/repository-change-publication.ts +58 -48
- package/src/repository-reconciliation.ts +53 -80
- package/src/submodule-staging.ts +27 -0
- package/src/turns/generate-commit-message.ts +7 -3
- package/dist/chunk-DNG7D77K.js.map +0 -1
- package/dist/chunk-E3DB4TIZ.js.map +0 -1
- package/dist/chunk-JL53OV5M.js.map +0 -1
- package/dist/chunk-VG6XF3OK.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository-reconciliation.d.ts","sourceRoot":"","sources":["../src/repository-reconciliation.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"repository-reconciliation.d.ts","sourceRoot":"","sources":["../src/repository-reconciliation.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAWzD,KAAK,kBAAkB,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AACnE,KAAK,UAAU,GAAG,kBAAkB,GAAG;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAC9D,KAAK,mBAAmB,GAAG,UAAU,GAAG;IACvC,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,kEAAkE;IAClE,WAAW,CAAC,EAAE,WAAW,CAAC;CAC1B,CAAC;AAEF,gBAAgB;AAChB,MAAM,WAAW,oBAAoB;IACpC,MAAM,EAAE,WAAW,GAAG,YAAY,GAAG,WAAW,CAAC;IACjD,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;CAChB;AA8JD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAClC,KAAK,EAAE,mBAAmB,EAC1B,KAAK,GAAE,SAAS,GAAG,SAAqB,GACtC,oBAAoB,CAqStB;AAED,mGAAmG;AACnG,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAKjG;AAED,6FAA6F;AAC7F,wBAAgB,sBAAsB,CACrC,KAAK,EAAE,UAAU,GAAG;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,WAAW,CAAC;CACzB,GACC,IAAI,CA6CN;AAED,gBAAgB;AAChB,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAE5E;AAED,oGAAoG;AACpG,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAgBpF;AAED,gBAAgB;AAChB,eAAO,MAAM,oBAAoB,8iCAA8iC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type TurnDiagnosticReport } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
/** @internal */
|
|
3
|
+
export declare function prepareSubmodules(repo: {
|
|
4
|
+
key: string;
|
|
5
|
+
fsPath: string;
|
|
6
|
+
}, ctx: {
|
|
7
|
+
reportDiagnostic(report: TurnDiagnosticReport): void;
|
|
8
|
+
}): Promise<string | undefined>;
|
|
9
|
+
/** @internal */
|
|
10
|
+
export declare function assertSafeSubmoduleStaging(git: (args: string[]) => string): void;
|
|
11
|
+
//# sourceMappingURL=submodule-staging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submodule-staging.d.ts","sourceRoot":"","sources":["../src/submodule-staging.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEnG,gBAAgB;AAChB,wBAAsB,iBAAiB,CACtC,IAAI,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EACrC,GAAG,EAAE;IAAE,gBAAgB,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI,CAAA;CAAE,+BAK7D;AAID,gBAAgB;AAChB,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,MAAM,GAAG,IAAI,CAWhF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-commit-message.d.ts","sourceRoot":"","sources":["../../src/turns/generate-commit-message.ts"],"names":[],"mappings":"AACA,OAAO,EAIN,KAAK,iBAAiB,EACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,8BAA8B,CAAC;AAEvF,gBAAgB;AAChB,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAatE;
|
|
1
|
+
{"version":3,"file":"generate-commit-message.d.ts","sourceRoot":"","sources":["../../src/turns/generate-commit-message.ts"],"names":[],"mappings":"AACA,OAAO,EAIN,KAAK,iBAAiB,EACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,8BAA8B,CAAC;AAEvF,gBAAgB;AAChB,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAatE;AAgBD,gBAAgB;AAChB,wBAAgB,mCAAmC,CAAC,OAAO,EAAE,MAAM,EAClE,GAAG,EAAE,iBAAiB,CACrB,OAAO,EACP,MAAM,EACN,MAAM,GAAG,wBAAwB,EACjC,kCAAkC,CAClC,GACC,MAAM,CAuBR;AACD,gBAAgB;AAChB,wBAAgB,6BAA6B,CAC5C,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,MAAM,EAAE,GACZ,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CASxB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leitwerk-dev/coding",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.13",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/leitwerk-dev/leitwerk.git",
|
|
@@ -65,12 +65,12 @@
|
|
|
65
65
|
"build": "tsup --silent"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@leitwerk-dev/domain": "0.5.
|
|
69
|
-
"@leitwerk-dev/process-sdk": "0.5.
|
|
68
|
+
"@leitwerk-dev/domain": "0.5.13",
|
|
69
|
+
"@leitwerk-dev/process-sdk": "0.5.13"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@leitwerk-dev/extension-runtime": "0.5.
|
|
73
|
-
"@leitwerk-dev/test-support": "0.5.
|
|
72
|
+
"@leitwerk-dev/extension-runtime": "0.5.13",
|
|
73
|
+
"@leitwerk-dev/test-support": "0.5.13",
|
|
74
74
|
"tsup": "^8.5.1"
|
|
75
75
|
},
|
|
76
76
|
"license": "Apache-2.0",
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
repositoryBindingMatches,
|
|
13
13
|
savePublicationReceipt,
|
|
14
14
|
} from "./repository-publication-receipt.js";
|
|
15
|
+
import { assertSafeSubmoduleStaging } from "./submodule-staging.js";
|
|
15
16
|
|
|
16
17
|
/** @public */
|
|
17
18
|
export interface GitIdentity {
|
|
@@ -116,14 +117,7 @@ function repositoryGit(projectKey: string, repoPath: string) {
|
|
|
116
117
|
return result.ok ? trimToNull(result.stdout) : null;
|
|
117
118
|
}
|
|
118
119
|
|
|
119
|
-
|
|
120
|
-
return (gitOrNull("status", "--porcelain") ?? "")
|
|
121
|
-
.split(/\r?\n/)
|
|
122
|
-
.map((line) => line.replace(/\s+$/, ""))
|
|
123
|
-
.filter(Boolean)
|
|
124
|
-
.map((line) => line.slice(2).trim())
|
|
125
|
-
.filter(Boolean);
|
|
126
|
-
}
|
|
120
|
+
const workingTreeStatus = () => git("status", "--porcelain", "--ignore-submodules=dirty");
|
|
127
121
|
|
|
128
122
|
function conflictedFiles(): string[] {
|
|
129
123
|
return (gitOrNull("diff", "--name-only", "--diff-filter=U") ?? "")
|
|
@@ -146,15 +140,18 @@ function repositoryGit(projectKey: string, repoPath: string) {
|
|
|
146
140
|
}
|
|
147
141
|
}
|
|
148
142
|
|
|
149
|
-
function commitIfDirty(commitMessage: string, identity: GitIdentity): string {
|
|
150
|
-
if (workingTreeStatus()
|
|
143
|
+
function commitIfDirty(commitMessage: string, identity: GitIdentity, signoff = false): string {
|
|
144
|
+
if (!workingTreeStatus()) return git("rev-parse", "HEAD");
|
|
151
145
|
assertGitIdentity(identity);
|
|
152
146
|
checkedGit(["add", "--all"], "Failed to stage the completed change");
|
|
153
|
-
checkedGit(
|
|
147
|
+
checkedGit(
|
|
148
|
+
["commit", "--no-gpg-sign", ...(signoff ? ["--signoff"] : []), "-m", commitMessage],
|
|
149
|
+
"Commit failed",
|
|
150
|
+
identity,
|
|
151
|
+
);
|
|
154
152
|
const remaining = workingTreeStatus();
|
|
155
|
-
if (remaining
|
|
156
|
-
throw new DeterministicGitError(`Commit left uncommitted changes
|
|
157
|
-
}
|
|
153
|
+
if (remaining)
|
|
154
|
+
throw new DeterministicGitError(`Commit left uncommitted changes:\n${remaining}`);
|
|
158
155
|
return git("rev-parse", "HEAD");
|
|
159
156
|
}
|
|
160
157
|
|
|
@@ -223,7 +220,15 @@ function repositoryGit(projectKey: string, repoPath: string) {
|
|
|
223
220
|
return pushTarget;
|
|
224
221
|
}
|
|
225
222
|
|
|
226
|
-
return {
|
|
223
|
+
return {
|
|
224
|
+
runGit,
|
|
225
|
+
git,
|
|
226
|
+
workingTreeStatus,
|
|
227
|
+
conflictedFiles,
|
|
228
|
+
mergeInProgress,
|
|
229
|
+
commitIfDirty,
|
|
230
|
+
pushAndVerify,
|
|
231
|
+
};
|
|
227
232
|
}
|
|
228
233
|
|
|
229
234
|
/** Inspect staged, unstaged, untracked, and already committed unpublished changes. @public */
|
|
@@ -232,10 +237,8 @@ export function repositoryHasChanges(
|
|
|
232
237
|
baseBranch: string,
|
|
233
238
|
projectKey = "repo",
|
|
234
239
|
): boolean {
|
|
235
|
-
const { git } = repositoryGit(projectKey, repoPath);
|
|
236
|
-
return Boolean(
|
|
237
|
-
git("status", "--porcelain") || git("diff", "--name-only", `origin/${baseBranch}...HEAD`),
|
|
238
|
-
);
|
|
240
|
+
const { git, workingTreeStatus } = repositoryGit(projectKey, repoPath);
|
|
241
|
+
return Boolean(workingTreeStatus() || git("diff", "--name-only", `origin/${baseBranch}...HEAD`));
|
|
239
242
|
}
|
|
240
243
|
|
|
241
244
|
/** Commit the current workspace change and non-force push only the feature branch. */
|
|
@@ -250,8 +253,12 @@ export function commitAndPushWorkBranch(input: {
|
|
|
250
253
|
commitMessage: string;
|
|
251
254
|
/** @public */
|
|
252
255
|
gitIdentity: GitIdentity;
|
|
256
|
+
/** Append a Git Signed-off-by trailer (`git commit --signoff`). @public */
|
|
257
|
+
signoff?: boolean;
|
|
253
258
|
/** Captured remote head; null requires branch creation. @internal */
|
|
254
259
|
expectedRemoteHead?: string | null;
|
|
260
|
+
/** Require explicit staging of submodule Git link changes. @internal */
|
|
261
|
+
protectSubmodules?: boolean;
|
|
255
262
|
}) {
|
|
256
263
|
const repoPath = path.resolve(input.repoPath);
|
|
257
264
|
const { runGit, git, conflictedFiles, mergeInProgress, commitIfDirty, pushAndVerify } =
|
|
@@ -276,7 +283,8 @@ export function commitAndPushWorkBranch(input: {
|
|
|
276
283
|
`Cannot publish a work branch with unresolved conflicts: ${conflicts.join(", ") || "merge in progress"}`,
|
|
277
284
|
);
|
|
278
285
|
}
|
|
279
|
-
|
|
286
|
+
if (input.protectSubmodules) assertSafeSubmoduleStaging((args) => git(...args));
|
|
287
|
+
const headSha = commitIfDirty(input.commitMessage, input.gitIdentity, input.signoff === true);
|
|
280
288
|
return {
|
|
281
289
|
/** @public */
|
|
282
290
|
headSha,
|
|
@@ -16,8 +16,9 @@ import {
|
|
|
16
16
|
type RepositoryChangeState,
|
|
17
17
|
repositoryChangeStateCodec,
|
|
18
18
|
} from "./repository-change-state-internal.js";
|
|
19
|
-
import {
|
|
19
|
+
import { reconcileRepository, reconciliationPrompt } from "./repository-reconciliation.js";
|
|
20
20
|
import { codingPurposes } from "./settings.js";
|
|
21
|
+
import { prepareSubmodules } from "./submodule-staging.js";
|
|
21
22
|
import { prepareRepositoryCommitMessageEvidence } from "./turns/commit-message-evidence.js";
|
|
22
23
|
import {
|
|
23
24
|
buildRepositoryCommitMessagesPrompt,
|
|
@@ -87,6 +88,8 @@ export interface RepositoryChangeProcessConfig<TParams extends RepositoryChangeP
|
|
|
87
88
|
fragment: FlowFragmentBuilder<TParams, RepositoryChangeState>;
|
|
88
89
|
/** @public */
|
|
89
90
|
happyPath?: readonly string[];
|
|
91
|
+
/** @internal */
|
|
92
|
+
prepareSubmodules?: boolean;
|
|
90
93
|
};
|
|
91
94
|
}
|
|
92
95
|
|
|
@@ -274,6 +277,7 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
274
277
|
)
|
|
275
278
|
.publish("plan");
|
|
276
279
|
const refreshTarget = config.workflow?.refreshTargetBeforeImplementation;
|
|
280
|
+
const prepareDependencies = config.publication.prepareSubmodules;
|
|
277
281
|
const implement = flow
|
|
278
282
|
.llm<TParams, RepositoryChangeState>("implement")
|
|
279
283
|
.description("Implement")
|
|
@@ -283,24 +287,40 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
283
287
|
.freshSeededPrimary()
|
|
284
288
|
.startFromRoot()
|
|
285
289
|
.consume("plan")
|
|
286
|
-
.prepare((ctx) =>
|
|
287
|
-
|
|
290
|
+
.prepare(async (ctx) => {
|
|
291
|
+
const submoduleWarnings: string[] = [];
|
|
292
|
+
for (const repo of ctx.repo.all()) {
|
|
288
293
|
const identity = asUnknownRecord(
|
|
289
294
|
ctx.projects.find((p) => p.key === repo.key)?.metadata?.["leitwerk.gitIdentity"],
|
|
290
295
|
);
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
296
|
+
const result = reconcileRepository(
|
|
297
|
+
{
|
|
298
|
+
projectKey: repo.key,
|
|
299
|
+
repoPath: repo.fsPath,
|
|
300
|
+
workBranch: repo.workBranch,
|
|
301
|
+
baseBranch: refreshTarget ? repo.baseBranch : undefined,
|
|
302
|
+
protectSubmodules: prepareDependencies,
|
|
303
|
+
gitIdentity:
|
|
304
|
+
typeof identity?.name === "string" && typeof identity.email === "string"
|
|
305
|
+
? { name: identity.name, email: identity.email }
|
|
306
|
+
: undefined,
|
|
307
|
+
},
|
|
308
|
+
"prepare",
|
|
309
|
+
);
|
|
310
|
+
if (prepareDependencies && result.status !== "conflicts") {
|
|
311
|
+
const warning = await prepareSubmodules(repo, ctx);
|
|
312
|
+
if (warning) submoduleWarnings.push(warning);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return { submoduleWarnings };
|
|
316
|
+
})
|
|
317
|
+
.buildPrompt((ctx) =>
|
|
318
|
+
[
|
|
319
|
+
buildImplementPrompt(ctx, refreshTarget),
|
|
320
|
+
reconciliationPrompt,
|
|
321
|
+
...(ctx.prepared?.submoduleWarnings ?? []),
|
|
322
|
+
].join("\n\n"),
|
|
323
|
+
)
|
|
304
324
|
.outcomeTool("implementation_ready", (tool) =>
|
|
305
325
|
tool
|
|
306
326
|
.description("Implementation and checks are complete; continue to delivery")
|
|
@@ -412,6 +432,7 @@ ${ctx.input["simplification-plan"]}`,
|
|
|
412
432
|
.turn(applySimplification)
|
|
413
433
|
.turn(generateCommitMessage)
|
|
414
434
|
.use(config.publication.fragment);
|
|
435
|
+
if (prepareDependencies) builder.runtime({ repositorySubmodules: "best_effort" });
|
|
415
436
|
if (config.repositoryCredentials) builder.repositoryCredentials(config.repositoryCredentials);
|
|
416
437
|
if (config.launcher) builder.launcher(config.launcher);
|
|
417
438
|
return {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { asUnknownRecord } from "@leitwerk-dev/domain";
|
|
2
2
|
import {
|
|
3
3
|
type AutomaticOutcomeBuilder,
|
|
4
|
+
COMMIT_MESSAGE_PROJECT_METADATA_KEY,
|
|
4
5
|
type ExtensionProcessDefinition,
|
|
5
6
|
type ExternalActionSource,
|
|
6
7
|
type FlowAutomaticRunContext,
|
|
@@ -23,13 +24,14 @@ import {
|
|
|
23
24
|
import { type ConflictEvidence, conflictKey, validateConflict } from "./repository-rebase/index.js";
|
|
24
25
|
import { rebasePrompt } from "./repository-rebase/prompt.js";
|
|
25
26
|
import {
|
|
26
|
-
|
|
27
|
+
reconcileRepository,
|
|
27
28
|
reconciliationPrompt,
|
|
28
29
|
recordRepositoryPublication,
|
|
29
30
|
repositoryWorktreeIsDirty,
|
|
30
31
|
retainConcurrentRebase,
|
|
31
32
|
} from "./repository-reconciliation.js";
|
|
32
33
|
import { codingPurposes } from "./settings.js";
|
|
34
|
+
import { prepareSubmodules } from "./submodule-staging.js";
|
|
33
35
|
|
|
34
36
|
export {
|
|
35
37
|
createPullRequestChangeProcess,
|
|
@@ -201,6 +203,8 @@ export interface RepositoryChangePublicationAdapter<P> {
|
|
|
201
203
|
};
|
|
202
204
|
/** @public */
|
|
203
205
|
namespace: string;
|
|
206
|
+
/** Prepare pinned submodules after revision reconciliation. @public */
|
|
207
|
+
prepareSubmodules?: boolean;
|
|
204
208
|
/** Reconcile a single-repository no-change outcome. @public */
|
|
205
209
|
unchanged?(ctx: PublicationContext<P>): Promise<void>;
|
|
206
210
|
/** Optional coordinated repositories; each retains independent publication state. @public */
|
|
@@ -639,6 +643,11 @@ export function createRepositoryChangePublication<P>(
|
|
|
639
643
|
expectedRemoteHead = remote(ctx.state).headSha,
|
|
640
644
|
) {
|
|
641
645
|
const repo = ctx.repo.get("repo");
|
|
646
|
+
const commitMessageMetadata = asUnknownRecord(
|
|
647
|
+
ctx.projects.find((candidate) => candidate.key === repo.key)?.metadata?.[
|
|
648
|
+
COMMIT_MESSAGE_PROJECT_METADATA_KEY
|
|
649
|
+
],
|
|
650
|
+
);
|
|
642
651
|
const gitIdentity = await adapter.identity(ctx);
|
|
643
652
|
if (adapter.maintenance)
|
|
644
653
|
await ctx.callIntegrationTool(adapter.maintenance.ownershipTool, { projectKey: repo.key });
|
|
@@ -648,21 +657,25 @@ export function createRepositoryChangePublication<P>(
|
|
|
648
657
|
workBranch: repo.workBranch,
|
|
649
658
|
commitMessage,
|
|
650
659
|
gitIdentity,
|
|
660
|
+
signoff: commitMessageMetadata?.signoff === true,
|
|
651
661
|
expectedRemoteHead,
|
|
662
|
+
protectSubmodules: adapter.prepareSubmodules,
|
|
652
663
|
});
|
|
653
664
|
}
|
|
654
665
|
async function reconcile(ctx: PublicationContext<P>, current: PublicationState) {
|
|
655
666
|
const repo = ctx.repo.get("repo");
|
|
656
|
-
return
|
|
667
|
+
return reconcileRepository({
|
|
657
668
|
projectKey: repo.key,
|
|
658
669
|
repoPath: repo.fsPath,
|
|
659
670
|
workBranch: repo.workBranch,
|
|
660
671
|
baseBranch: repo.baseBranch,
|
|
661
672
|
baselineSha: current.workBaselineSha ?? current.headSha ?? undefined,
|
|
662
673
|
gitIdentity: await adapter.identity(ctx),
|
|
674
|
+
protectSubmodules: adapter.prepareSubmodules,
|
|
663
675
|
});
|
|
664
676
|
}
|
|
665
677
|
const runRepository = async (ctx: PublicationContext<P>) => {
|
|
678
|
+
const repo = ctx.repo.get("repo");
|
|
666
679
|
let current = remote(ctx.state);
|
|
667
680
|
const update = (patch: Parameters<typeof patchRemote>[1]) => {
|
|
668
681
|
current = { ...current, ...patch, delivery: { ...current.delivery, ...patch.delivery } };
|
|
@@ -676,7 +689,6 @@ export function createRepositoryChangePublication<P>(
|
|
|
676
689
|
reconciliationCycles: 0,
|
|
677
690
|
pipeline: changed ? null : current.pipeline,
|
|
678
691
|
});
|
|
679
|
-
const repo = ctx.repo.get("repo");
|
|
680
692
|
recordRepositoryPublication(
|
|
681
693
|
{
|
|
682
694
|
projectKey: repo.key,
|
|
@@ -736,11 +748,7 @@ export function createRepositoryChangePublication<P>(
|
|
|
736
748
|
if (
|
|
737
749
|
!current.headSha &&
|
|
738
750
|
(adapter.repositories || adapter.unchanged) &&
|
|
739
|
-
!repositoryHasChanges(
|
|
740
|
-
ctx.repo.get("repo").fsPath,
|
|
741
|
-
ctx.repo.get("repo").baseBranch,
|
|
742
|
-
ctx.repo.get("repo").key,
|
|
743
|
-
)
|
|
751
|
+
!repositoryHasChanges(repo.fsPath, repo.baseBranch, repo.key)
|
|
744
752
|
) {
|
|
745
753
|
update({ noChanges: true });
|
|
746
754
|
await adapter.unchanged?.(ctx);
|
|
@@ -764,7 +772,7 @@ export function createRepositoryChangePublication<P>(
|
|
|
764
772
|
try {
|
|
765
773
|
published = await commitWorkBranch(
|
|
766
774
|
ctx,
|
|
767
|
-
ctx.state.finalization.commitMessages?.[
|
|
775
|
+
ctx.state.finalization.commitMessages?.[repo.key] ??
|
|
768
776
|
ctx.state.finalization.generatedCommitMessage ??
|
|
769
777
|
"",
|
|
770
778
|
publicationLease,
|
|
@@ -795,9 +803,9 @@ export function createRepositoryChangePublication<P>(
|
|
|
795
803
|
let adjustmentPublished = false;
|
|
796
804
|
if (adjustment.publishRequired || adjustment.origin === "rebase" || adapter.maintenance) {
|
|
797
805
|
ctx.reportProgress(deliveryProgress(current, adapter.label, "publish_adjustment"));
|
|
798
|
-
if (adapter.maintenance)
|
|
806
|
+
if (adjustment.origin === "rebase" && adapter.maintenance)
|
|
799
807
|
await ctx.callIntegrationTool(adapter.maintenance.ownershipTool, {
|
|
800
|
-
projectKey:
|
|
808
|
+
projectKey: repo.key,
|
|
801
809
|
});
|
|
802
810
|
let published: { headSha: string };
|
|
803
811
|
try {
|
|
@@ -811,11 +819,10 @@ export function createRepositoryChangePublication<P>(
|
|
|
811
819
|
} catch (error) {
|
|
812
820
|
if (error instanceof ConcurrentRebaseSourceError) {
|
|
813
821
|
if (error.published) return reconcileAgain();
|
|
814
|
-
const project = ctx.repo.get("repo");
|
|
815
822
|
retainConcurrentRebase({
|
|
816
|
-
projectKey:
|
|
817
|
-
repoPath:
|
|
818
|
-
workBranch:
|
|
823
|
+
projectKey: repo.key,
|
|
824
|
+
repoPath: repo.fsPath,
|
|
825
|
+
workBranch: repo.workBranch,
|
|
819
826
|
baselineSha: error.repair.originalHead,
|
|
820
827
|
rebasedHead: error.repair.headSha,
|
|
821
828
|
targetBase: error.repair.baseSha,
|
|
@@ -1056,26 +1063,6 @@ export function createRepositoryChangePublication<P>(
|
|
|
1056
1063
|
return kind === "feedback" && remote(state).repairReason === "rebase" ? "rebase" : kind;
|
|
1057
1064
|
}
|
|
1058
1065
|
|
|
1059
|
-
function revisionPrompt(kind: "feedback" | "ci") {
|
|
1060
|
-
return (ctx: {
|
|
1061
|
-
state: RepositoryChangeState;
|
|
1062
|
-
prepared?: unknown;
|
|
1063
|
-
prompts?: { initial: string };
|
|
1064
|
-
}) => {
|
|
1065
|
-
const current = remote(ctx.state);
|
|
1066
|
-
const repository = adapter.repositories
|
|
1067
|
-
? `Repository: ${activeKey(ctx.state)}. Apply changes only to this checkout. `
|
|
1068
|
-
: "";
|
|
1069
|
-
if (asUnknownRecord(ctx.prepared)?.deferredRebase)
|
|
1070
|
-
return `${repository}${reconciliationPrompt}\nThe source branch or retained local work must be reconciled before the target-branch repair. Resolve any source reconciliation, then use changes_ready. Delivery will restore and validate the result before reassessing current target conflicts.`;
|
|
1071
|
-
if (current.reconciliationRequired)
|
|
1072
|
-
return `${repository}${reconciliationPrompt}\nValidate the reconciled repository, including any upstream target changes and retained local work, against the requested change and pending feedback: ${JSON.stringify(current.feedbackIds)}. Treat the current remote as authoritative; do not restore deliberately removed code simply to match an older plan. Use changes_ready after validation, even when no further edit is needed, so retained local changes are published. If blocked use cannot_repair.\nOriginal request for context: ${ctx.prompts?.initial ?? "Inspect the current repository and retained request"}`;
|
|
1073
|
-
if (repairReason(ctx.state, kind) === "rebase")
|
|
1074
|
-
return `${rebasePrompt} Evidence: ${JSON.stringify(current.conflict)}. Call changes_ready or no_changes when verified complete, cannot_repair when blocked.`;
|
|
1075
|
-
return `${adapter.repositories ? `Repository: ${activeKey(ctx.state)}. Apply changes only to this checkout. ` : ""}${adapter.prompt(kind, current)}\n\n${reconciliationPrompt}`;
|
|
1076
|
-
};
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
1066
|
function revisionTurn(id: string, kind: "feedback" | "ci") {
|
|
1080
1067
|
const turn = flow
|
|
1081
1068
|
.llm<P, RepositoryChangeState>(id)
|
|
@@ -1102,11 +1089,16 @@ export function createRepositoryChangePublication<P>(
|
|
|
1102
1089
|
.prepare(async (ctx) => {
|
|
1103
1090
|
const project = ctx.repo.get(activeKey(ctx.state) ?? "repo");
|
|
1104
1091
|
const current = remote(ctx.state);
|
|
1092
|
+
const prepareDependencies = () =>
|
|
1093
|
+
adapter.prepareSubmodules ? prepareSubmodules(project, ctx) : undefined;
|
|
1094
|
+
const prepareRebase = async () => {
|
|
1095
|
+
startRebase(rebaseInput(ctx));
|
|
1096
|
+
return { deferredRebase: false, submoduleWarning: await prepareDependencies() };
|
|
1097
|
+
};
|
|
1105
1098
|
const targetRebase =
|
|
1106
1099
|
repairReason(ctx.state, kind) === "rebase" && !current.reconciliationRequired;
|
|
1107
1100
|
// Resume Git's existing target repair; it must not be mistaken for source synchronization.
|
|
1108
|
-
if (targetRebase && hasPreparedRebase(rebaseInput(ctx)))
|
|
1109
|
-
return { rebase: startRebase(rebaseInput(ctx)) };
|
|
1101
|
+
if (targetRebase && hasPreparedRebase(rebaseInput(ctx))) return prepareRebase();
|
|
1110
1102
|
const report = (label: string, status: "in_progress" | "completed") =>
|
|
1111
1103
|
ctx.reportProgress({
|
|
1112
1104
|
title: "Repository reconciliation",
|
|
@@ -1117,19 +1109,35 @@ export function createRepositoryChangePublication<P>(
|
|
|
1117
1109
|
if (reconciliation.status === "conflicts")
|
|
1118
1110
|
report("Resolve reconciliation conflicts", "in_progress");
|
|
1119
1111
|
else report("Repository reconciled", "completed");
|
|
1120
|
-
if (
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1112
|
+
if (
|
|
1113
|
+
targetRebase &&
|
|
1114
|
+
reconciliation.status === "unchanged" &&
|
|
1115
|
+
reconciliation.headSha === current.conflict?.headSha &&
|
|
1116
|
+
!repositoryWorktreeIsDirty({ projectKey: project.key, repoPath: project.fsPath })
|
|
1117
|
+
)
|
|
1118
|
+
return prepareRebase();
|
|
1119
|
+
return {
|
|
1120
|
+
deferredRebase: targetRebase,
|
|
1121
|
+
submoduleWarning:
|
|
1122
|
+
reconciliation.status !== "conflicts" ? await prepareDependencies() : undefined,
|
|
1123
|
+
};
|
|
1130
1124
|
})
|
|
1131
1125
|
.freshPrimary()
|
|
1132
|
-
.
|
|
1126
|
+
.buildPrompt((ctx) => {
|
|
1127
|
+
const current = remote(ctx.state);
|
|
1128
|
+
const repository = adapter.repositories
|
|
1129
|
+
? `Repository: ${activeKey(ctx.state)}. Apply changes only to this checkout. `
|
|
1130
|
+
: "";
|
|
1131
|
+
let prompt: string;
|
|
1132
|
+
if (ctx.prepared?.deferredRebase)
|
|
1133
|
+
prompt = `${repository}${reconciliationPrompt}\nThe source branch or retained local work must be reconciled before the target-branch repair. Resolve any source reconciliation, then use changes_ready. Delivery will restore and validate the result before reassessing current target conflicts.`;
|
|
1134
|
+
else if (current.reconciliationRequired)
|
|
1135
|
+
prompt = `${repository}${reconciliationPrompt}\nValidate the reconciled repository, including any upstream target changes and retained local work, against the requested change and pending feedback: ${JSON.stringify(current.feedbackIds)}. Treat the current remote as authoritative; do not restore deliberately removed code simply to match an older plan. Use changes_ready after validation, even when no further edit is needed, so retained local changes are published. If blocked use cannot_repair.\nOriginal request for context: ${ctx.prompts.initial || "Inspect the current repository and retained request"}`;
|
|
1136
|
+
else if (repairReason(ctx.state, kind) === "rebase")
|
|
1137
|
+
prompt = `${rebasePrompt} Evidence: ${JSON.stringify(current.conflict)}. Call changes_ready or no_changes when verified complete, cannot_repair when blocked.`;
|
|
1138
|
+
else prompt = `${repository}${adapter.prompt(kind, current)}\n\n${reconciliationPrompt}`;
|
|
1139
|
+
return [prompt, ctx.prepared?.submoduleWarning].filter(Boolean).join("\n\n");
|
|
1140
|
+
});
|
|
1133
1141
|
for (const [name, description] of [
|
|
1134
1142
|
["changes_ready", "Repository changes are ready to publish"],
|
|
1135
1143
|
["no_changes", "No repository change is required"],
|
|
@@ -1236,5 +1244,7 @@ export function createRepositoryChangePublication<P>(
|
|
|
1236
1244
|
|
|
1237
1245
|
/** @public */
|
|
1238
1246
|
happyPath: [ids.deliver],
|
|
1247
|
+
/** @internal */
|
|
1248
|
+
prepareSubmodules: adapter.prepareSubmodules,
|
|
1239
1249
|
};
|
|
1240
1250
|
}
|