@leitwerk-dev/forgejo-repo-change 0.2.1 → 0.3.1
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 +8 -21
- package/dist/index.d.ts +13 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +108 -1131
- package/dist/index.js.map +1 -1
- package/dist/launcher.d.ts +10 -3
- package/dist/launcher.d.ts.map +1 -1
- package/dist/params.d.ts +3 -23
- package/dist/params.d.ts.map +1 -1
- package/dist/process.d.ts +1 -1
- package/dist/process.d.ts.map +1 -1
- package/dist/profile-bindings.d.ts.map +1 -1
- package/package.json +7 -8
- package/src/launcher.ts +25 -182
- package/src/params.ts +12 -73
- package/src/process.ts +78 -659
- package/src/profile-bindings.ts +5 -39
package/dist/index.js
CHANGED
|
@@ -3,506 +3,40 @@ import { forgejoIntegration } from "@leitwerk-dev/forgejo";
|
|
|
3
3
|
import { gitSshIntegration } from "@leitwerk-dev/git-ssh";
|
|
4
4
|
import { woodpeckerIntegration } from "@leitwerk-dev/woodpecker";
|
|
5
5
|
|
|
6
|
-
// src/launcher.ts
|
|
7
|
-
import { buildAutoWorkBranchFromSeed } from "@leitwerk-dev/coding/auto-work-branch";
|
|
8
|
-
|
|
9
|
-
// ../../node_modules/valibot/dist/index.mjs
|
|
10
|
-
var store$4;
|
|
11
|
-
// @__NO_SIDE_EFFECTS__
|
|
12
|
-
function getGlobalConfig(config$1) {
|
|
13
|
-
return {
|
|
14
|
-
lang: config$1?.lang ?? store$4?.lang,
|
|
15
|
-
message: config$1?.message,
|
|
16
|
-
abortEarly: config$1?.abortEarly ?? store$4?.abortEarly,
|
|
17
|
-
abortPipeEarly: config$1?.abortPipeEarly ?? store$4?.abortPipeEarly
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
var store$3;
|
|
21
|
-
// @__NO_SIDE_EFFECTS__
|
|
22
|
-
function getGlobalMessage(lang) {
|
|
23
|
-
return store$3?.get(lang);
|
|
24
|
-
}
|
|
25
|
-
var store$2;
|
|
26
|
-
// @__NO_SIDE_EFFECTS__
|
|
27
|
-
function getSchemaMessage(lang) {
|
|
28
|
-
return store$2?.get(lang);
|
|
29
|
-
}
|
|
30
|
-
var store$1;
|
|
31
|
-
// @__NO_SIDE_EFFECTS__
|
|
32
|
-
function getSpecificMessage(reference, lang) {
|
|
33
|
-
return store$1?.get(reference)?.get(lang);
|
|
34
|
-
}
|
|
35
|
-
// @__NO_SIDE_EFFECTS__
|
|
36
|
-
function _stringify(input) {
|
|
37
|
-
const type = typeof input;
|
|
38
|
-
if (type === "string") return `"${input}"`;
|
|
39
|
-
if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
|
|
40
|
-
if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
|
|
41
|
-
return type;
|
|
42
|
-
}
|
|
43
|
-
function _addIssue(context, label, dataset, config$1, other) {
|
|
44
|
-
const input = other && "input" in other ? other.input : dataset.value;
|
|
45
|
-
const expected = other?.expected ?? context.expects ?? null;
|
|
46
|
-
const received = other?.received ?? /* @__PURE__ */ _stringify(input);
|
|
47
|
-
const issue = {
|
|
48
|
-
kind: context.kind,
|
|
49
|
-
type: context.type,
|
|
50
|
-
input,
|
|
51
|
-
expected,
|
|
52
|
-
received,
|
|
53
|
-
message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
|
|
54
|
-
requirement: context.requirement,
|
|
55
|
-
path: other?.path,
|
|
56
|
-
issues: other?.issues,
|
|
57
|
-
lang: config$1.lang,
|
|
58
|
-
abortEarly: config$1.abortEarly,
|
|
59
|
-
abortPipeEarly: config$1.abortPipeEarly
|
|
60
|
-
};
|
|
61
|
-
const isSchema = context.kind === "schema";
|
|
62
|
-
const message$1 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config$1.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
|
|
63
|
-
if (message$1 !== void 0) issue.message = typeof message$1 === "function" ? message$1(issue) : message$1;
|
|
64
|
-
if (isSchema) dataset.typed = false;
|
|
65
|
-
if (dataset.issues) dataset.issues.push(issue);
|
|
66
|
-
else dataset.issues = [issue];
|
|
67
|
-
}
|
|
68
|
-
// @__NO_SIDE_EFFECTS__
|
|
69
|
-
function _getStandardProps(context) {
|
|
70
|
-
return {
|
|
71
|
-
version: 1,
|
|
72
|
-
vendor: "valibot",
|
|
73
|
-
validate(value$1) {
|
|
74
|
-
return context["~run"]({ value: value$1 }, /* @__PURE__ */ getGlobalConfig());
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
// @__NO_SIDE_EFFECTS__
|
|
79
|
-
function _isValidObjectKey(object$1, key) {
|
|
80
|
-
return Object.hasOwn(object$1, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
|
|
81
|
-
}
|
|
82
|
-
// @__NO_SIDE_EFFECTS__
|
|
83
|
-
function check(requirement, message$1) {
|
|
84
|
-
return {
|
|
85
|
-
kind: "validation",
|
|
86
|
-
type: "check",
|
|
87
|
-
reference: check,
|
|
88
|
-
async: false,
|
|
89
|
-
expects: null,
|
|
90
|
-
requirement,
|
|
91
|
-
message: message$1,
|
|
92
|
-
"~run"(dataset, config$1) {
|
|
93
|
-
if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "input", dataset, config$1);
|
|
94
|
-
return dataset;
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
// @__NO_SIDE_EFFECTS__
|
|
99
|
-
function parseJson(config$1, message$1) {
|
|
100
|
-
return {
|
|
101
|
-
kind: "transformation",
|
|
102
|
-
type: "parse_json",
|
|
103
|
-
reference: parseJson,
|
|
104
|
-
config: config$1,
|
|
105
|
-
message: message$1,
|
|
106
|
-
async: false,
|
|
107
|
-
"~run"(dataset, config$2) {
|
|
108
|
-
try {
|
|
109
|
-
dataset.value = JSON.parse(dataset.value, this.config?.reviver);
|
|
110
|
-
} catch (error) {
|
|
111
|
-
if (error instanceof Error) {
|
|
112
|
-
_addIssue(this, "JSON", dataset, config$2, { received: `"${error.message}"` });
|
|
113
|
-
dataset.typed = false;
|
|
114
|
-
} else throw error;
|
|
115
|
-
}
|
|
116
|
-
return dataset;
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
// @__NO_SIDE_EFFECTS__
|
|
121
|
-
function getFallback(schema, dataset, config$1) {
|
|
122
|
-
return typeof schema.fallback === "function" ? schema.fallback(dataset, config$1) : schema.fallback;
|
|
123
|
-
}
|
|
124
|
-
// @__NO_SIDE_EFFECTS__
|
|
125
|
-
function getDefault(schema, dataset, config$1) {
|
|
126
|
-
return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
|
|
127
|
-
}
|
|
128
|
-
// @__NO_SIDE_EFFECTS__
|
|
129
|
-
function custom(check$1, message$1) {
|
|
130
|
-
return {
|
|
131
|
-
kind: "schema",
|
|
132
|
-
type: "custom",
|
|
133
|
-
reference: custom,
|
|
134
|
-
expects: "unknown",
|
|
135
|
-
async: false,
|
|
136
|
-
check: check$1,
|
|
137
|
-
message: message$1,
|
|
138
|
-
get "~standard"() {
|
|
139
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
140
|
-
},
|
|
141
|
-
"~run"(dataset, config$1) {
|
|
142
|
-
if (this.check(dataset.value)) dataset.typed = true;
|
|
143
|
-
else _addIssue(this, "type", dataset, config$1);
|
|
144
|
-
return dataset;
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
// @__NO_SIDE_EFFECTS__
|
|
149
|
-
function object(entries$1, message$1) {
|
|
150
|
-
return {
|
|
151
|
-
kind: "schema",
|
|
152
|
-
type: "object",
|
|
153
|
-
reference: object,
|
|
154
|
-
expects: "Object",
|
|
155
|
-
async: false,
|
|
156
|
-
entries: entries$1,
|
|
157
|
-
message: message$1,
|
|
158
|
-
get "~standard"() {
|
|
159
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
160
|
-
},
|
|
161
|
-
"~run"(dataset, config$1) {
|
|
162
|
-
const input = dataset.value;
|
|
163
|
-
if (input && typeof input === "object") {
|
|
164
|
-
dataset.typed = true;
|
|
165
|
-
dataset.value = {};
|
|
166
|
-
for (const key in this.entries) {
|
|
167
|
-
const valueSchema = this.entries[key];
|
|
168
|
-
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
|
|
169
|
-
const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
|
|
170
|
-
const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
|
|
171
|
-
if (valueDataset.issues) {
|
|
172
|
-
const pathItem = {
|
|
173
|
-
type: "object",
|
|
174
|
-
origin: "value",
|
|
175
|
-
input,
|
|
176
|
-
key,
|
|
177
|
-
value: value$1
|
|
178
|
-
};
|
|
179
|
-
for (const issue of valueDataset.issues) {
|
|
180
|
-
if (issue.path) issue.path.unshift(pathItem);
|
|
181
|
-
else issue.path = [pathItem];
|
|
182
|
-
dataset.issues?.push(issue);
|
|
183
|
-
}
|
|
184
|
-
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
185
|
-
if (config$1.abortEarly) {
|
|
186
|
-
dataset.typed = false;
|
|
187
|
-
break;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
if (!valueDataset.typed) dataset.typed = false;
|
|
191
|
-
dataset.value[key] = valueDataset.value;
|
|
192
|
-
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
|
|
193
|
-
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
|
|
194
|
-
_addIssue(this, "key", dataset, config$1, {
|
|
195
|
-
input: void 0,
|
|
196
|
-
expected: `"${key}"`,
|
|
197
|
-
path: [{
|
|
198
|
-
type: "object",
|
|
199
|
-
origin: "key",
|
|
200
|
-
input,
|
|
201
|
-
key,
|
|
202
|
-
value: input[key]
|
|
203
|
-
}]
|
|
204
|
-
});
|
|
205
|
-
if (config$1.abortEarly) break;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
} else _addIssue(this, "type", dataset, config$1);
|
|
209
|
-
return dataset;
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
// @__NO_SIDE_EFFECTS__
|
|
214
|
-
function optional(wrapped, default_) {
|
|
215
|
-
return {
|
|
216
|
-
kind: "schema",
|
|
217
|
-
type: "optional",
|
|
218
|
-
reference: optional,
|
|
219
|
-
expects: `(${wrapped.expects} | undefined)`,
|
|
220
|
-
async: false,
|
|
221
|
-
wrapped,
|
|
222
|
-
default: default_,
|
|
223
|
-
get "~standard"() {
|
|
224
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
225
|
-
},
|
|
226
|
-
"~run"(dataset, config$1) {
|
|
227
|
-
if (dataset.value === void 0) {
|
|
228
|
-
if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
|
|
229
|
-
if (dataset.value === void 0) {
|
|
230
|
-
dataset.typed = true;
|
|
231
|
-
return dataset;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
return this.wrapped["~run"](dataset, config$1);
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
// @__NO_SIDE_EFFECTS__
|
|
239
|
-
function record(key, value$1, message$1) {
|
|
240
|
-
return {
|
|
241
|
-
kind: "schema",
|
|
242
|
-
type: "record",
|
|
243
|
-
reference: record,
|
|
244
|
-
expects: "Object",
|
|
245
|
-
async: false,
|
|
246
|
-
key,
|
|
247
|
-
value: value$1,
|
|
248
|
-
message: message$1,
|
|
249
|
-
get "~standard"() {
|
|
250
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
251
|
-
},
|
|
252
|
-
"~run"(dataset, config$1) {
|
|
253
|
-
const input = dataset.value;
|
|
254
|
-
if (input && typeof input === "object") {
|
|
255
|
-
dataset.typed = true;
|
|
256
|
-
dataset.value = {};
|
|
257
|
-
for (const entryKey in input) if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
|
|
258
|
-
const entryValue = input[entryKey];
|
|
259
|
-
const keyDataset = this.key["~run"]({ value: entryKey }, config$1);
|
|
260
|
-
if (keyDataset.issues) {
|
|
261
|
-
const pathItem = {
|
|
262
|
-
type: "object",
|
|
263
|
-
origin: "key",
|
|
264
|
-
input,
|
|
265
|
-
key: entryKey,
|
|
266
|
-
value: entryValue
|
|
267
|
-
};
|
|
268
|
-
for (const issue of keyDataset.issues) {
|
|
269
|
-
issue.path = [pathItem];
|
|
270
|
-
dataset.issues?.push(issue);
|
|
271
|
-
}
|
|
272
|
-
if (!dataset.issues) dataset.issues = keyDataset.issues;
|
|
273
|
-
if (config$1.abortEarly) {
|
|
274
|
-
dataset.typed = false;
|
|
275
|
-
break;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
const valueDataset = this.value["~run"]({ value: entryValue }, config$1);
|
|
279
|
-
if (valueDataset.issues) {
|
|
280
|
-
const pathItem = {
|
|
281
|
-
type: "object",
|
|
282
|
-
origin: "value",
|
|
283
|
-
input,
|
|
284
|
-
key: entryKey,
|
|
285
|
-
value: entryValue
|
|
286
|
-
};
|
|
287
|
-
for (const issue of valueDataset.issues) {
|
|
288
|
-
if (issue.path) issue.path.unshift(pathItem);
|
|
289
|
-
else issue.path = [pathItem];
|
|
290
|
-
dataset.issues?.push(issue);
|
|
291
|
-
}
|
|
292
|
-
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
293
|
-
if (config$1.abortEarly) {
|
|
294
|
-
dataset.typed = false;
|
|
295
|
-
break;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
if (!keyDataset.typed || !valueDataset.typed) dataset.typed = false;
|
|
299
|
-
if (keyDataset.typed) dataset.value[keyDataset.value] = valueDataset.value;
|
|
300
|
-
}
|
|
301
|
-
} else _addIssue(this, "type", dataset, config$1);
|
|
302
|
-
return dataset;
|
|
303
|
-
}
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
// @__NO_SIDE_EFFECTS__
|
|
307
|
-
function string(message$1) {
|
|
308
|
-
return {
|
|
309
|
-
kind: "schema",
|
|
310
|
-
type: "string",
|
|
311
|
-
reference: string,
|
|
312
|
-
expects: "string",
|
|
313
|
-
async: false,
|
|
314
|
-
message: message$1,
|
|
315
|
-
get "~standard"() {
|
|
316
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
317
|
-
},
|
|
318
|
-
"~run"(dataset, config$1) {
|
|
319
|
-
if (typeof dataset.value === "string") dataset.typed = true;
|
|
320
|
-
else _addIssue(this, "type", dataset, config$1);
|
|
321
|
-
return dataset;
|
|
322
|
-
}
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
// @__NO_SIDE_EFFECTS__
|
|
326
|
-
function unknown() {
|
|
327
|
-
return {
|
|
328
|
-
kind: "schema",
|
|
329
|
-
type: "unknown",
|
|
330
|
-
reference: unknown,
|
|
331
|
-
expects: "unknown",
|
|
332
|
-
async: false,
|
|
333
|
-
get "~standard"() {
|
|
334
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
335
|
-
},
|
|
336
|
-
"~run"(dataset) {
|
|
337
|
-
dataset.typed = true;
|
|
338
|
-
return dataset;
|
|
339
|
-
}
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
// @__NO_SIDE_EFFECTS__
|
|
343
|
-
function pipe(...pipe$1) {
|
|
344
|
-
return {
|
|
345
|
-
...pipe$1[0],
|
|
346
|
-
pipe: pipe$1,
|
|
347
|
-
get "~standard"() {
|
|
348
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
349
|
-
},
|
|
350
|
-
"~run"(dataset, config$1) {
|
|
351
|
-
for (const item of pipe$1) if (item.kind !== "metadata") {
|
|
352
|
-
if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
|
|
353
|
-
dataset.typed = false;
|
|
354
|
-
break;
|
|
355
|
-
}
|
|
356
|
-
if (!dataset.issues || !config$1.abortEarly && !config$1.abortPipeEarly) dataset = item["~run"](dataset, config$1);
|
|
357
|
-
}
|
|
358
|
-
return dataset;
|
|
359
|
-
}
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
// ../../packages/domain/dist/index.js
|
|
364
|
-
function trimString(value) {
|
|
365
|
-
return typeof value === "string" ? value.trim() : "";
|
|
366
|
-
}
|
|
367
|
-
var SYSTEM_ACTOR = { id: "system", kind: "system", provider: null };
|
|
368
|
-
function serializeActor(actor) {
|
|
369
|
-
return JSON.stringify({
|
|
370
|
-
id: actor.id,
|
|
371
|
-
kind: actor.kind,
|
|
372
|
-
provider: actor.provider,
|
|
373
|
-
...actor.displayName !== void 0 ? { displayName: actor.displayName } : {}
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
var SERIALIZED_SYSTEM_ACTOR = serializeActor(SYSTEM_ACTOR);
|
|
377
|
-
var jsonObjectSchema = custom(
|
|
378
|
-
(value) => typeof value === "object" && value !== null && !Array.isArray(value),
|
|
379
|
-
"Expected object"
|
|
380
|
-
);
|
|
381
|
-
var instanceTurnConfigSchema = pipe(
|
|
382
|
-
jsonObjectSchema,
|
|
383
|
-
object({
|
|
384
|
-
modelProfileId: optional(unknown())
|
|
385
|
-
})
|
|
386
|
-
);
|
|
387
|
-
var strictInstanceTurnConfigsJsonSchema = pipe(
|
|
388
|
-
string(),
|
|
389
|
-
parseJson(),
|
|
390
|
-
jsonObjectSchema,
|
|
391
|
-
record(string(), instanceTurnConfigSchema)
|
|
392
|
-
);
|
|
393
|
-
var copiedUnknownRecordSchema = pipe(
|
|
394
|
-
unknown(),
|
|
395
|
-
check(isUnknownRecord, "Expected object"),
|
|
396
|
-
record(string(), unknown())
|
|
397
|
-
);
|
|
398
|
-
function isUnknownRecord(value) {
|
|
399
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
400
|
-
}
|
|
401
|
-
function asUnknownRecord(value) {
|
|
402
|
-
return isUnknownRecord(value) ? value : null;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
6
|
// src/launcher.ts
|
|
406
7
|
import {
|
|
407
|
-
|
|
408
|
-
|
|
8
|
+
createRepositoryChangeUiLauncher,
|
|
9
|
+
repositoryVisibilityCheck
|
|
10
|
+
} from "@leitwerk-dev/coding/repository-change-launch";
|
|
11
|
+
import { createGitSshPreparationCheck } from "@leitwerk-dev/git-ssh";
|
|
409
12
|
|
|
410
13
|
// src/params.ts
|
|
411
14
|
import {
|
|
412
15
|
createRepositoryChangeParamsCodec,
|
|
413
|
-
|
|
414
|
-
repositoryChangeParamsRecord
|
|
16
|
+
normalizeRepositoryIssueChangeParams
|
|
415
17
|
} from "@leitwerk-dev/coding/repository-change-launch";
|
|
416
18
|
function isIssueOrigin(params) {
|
|
417
19
|
return params.origin === "issue";
|
|
418
20
|
}
|
|
419
21
|
var forgejoRepoChangeParamsCodec = createRepositoryChangeParamsCodec({
|
|
420
|
-
displayName: "Forgejo Repo Change",
|
|
421
22
|
normalize(value) {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
const common = {
|
|
430
|
-
...shared,
|
|
431
|
-
forgejoProfile: text("forgejoProfile"),
|
|
432
|
-
woodpeckerProfile: text("woodpeckerProfile"),
|
|
433
|
-
sshCredentialRef: text("sshCredentialRef"),
|
|
434
|
-
owner: text("owner"),
|
|
435
|
-
repo: text("repo")
|
|
436
|
-
};
|
|
437
|
-
const origin = trimString(record3.origin);
|
|
438
|
-
if (origin === "ui") {
|
|
439
|
-
return {
|
|
440
|
-
...common,
|
|
441
|
-
origin: "ui",
|
|
442
|
-
issueNumber: null,
|
|
443
|
-
issueUrl: null,
|
|
444
|
-
triggerLabel: null,
|
|
445
|
-
doneLabel: null
|
|
446
|
-
};
|
|
447
|
-
}
|
|
448
|
-
if (origin && origin !== "issue") {
|
|
449
|
-
throw new Error("Forgejo Repo Change requires a valid origin");
|
|
450
|
-
}
|
|
451
|
-
if (typeof record3.issueNumber !== "number" || !Number.isInteger(record3.issueNumber) || record3.issueNumber <= 0)
|
|
452
|
-
throw new Error("Forgejo Repo Change requires issueNumber");
|
|
453
|
-
return {
|
|
454
|
-
...common,
|
|
455
|
-
origin: "issue",
|
|
456
|
-
issueNumber: record3.issueNumber,
|
|
457
|
-
issueUrl: text("issueUrl"),
|
|
458
|
-
triggerLabel: text("triggerLabel"),
|
|
459
|
-
doneLabel: text("doneLabel")
|
|
460
|
-
};
|
|
23
|
+
return normalizeRepositoryIssueChangeParams(value, "Forgejo Repo Change", [
|
|
24
|
+
"forgejoProfile",
|
|
25
|
+
"woodpeckerProfile",
|
|
26
|
+
"sshCredentialRef",
|
|
27
|
+
"owner",
|
|
28
|
+
"repo"
|
|
29
|
+
]);
|
|
461
30
|
}
|
|
462
31
|
});
|
|
463
32
|
|
|
464
33
|
// src/profile-bindings.ts
|
|
465
|
-
|
|
466
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
467
|
-
throw new Error(`${label} must be an object`);
|
|
468
|
-
return value;
|
|
469
|
-
}
|
|
470
|
-
function field(value, fallback, label) {
|
|
471
|
-
if (value === void 0) return fallback;
|
|
472
|
-
if (typeof value !== "string" || !value.trim())
|
|
473
|
-
throw new Error(`${label} must be a non-empty string`);
|
|
474
|
-
return value.trim();
|
|
475
|
-
}
|
|
34
|
+
import { parseRepositoryProfileBindings } from "@leitwerk-dev/coding/repository-change-launch";
|
|
476
35
|
function parseProfileBindings(raw) {
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
const entries = Object.entries(mappings).map(([profile, value]) => {
|
|
481
|
-
if (!profile.trim() || profile.trim() !== profile)
|
|
482
|
-
throw new Error(
|
|
483
|
-
"profile_bindings keys must be non-empty profile names without surrounding whitespace"
|
|
484
|
-
);
|
|
485
|
-
const mapping = record2(value, `profile_bindings.${profile}`);
|
|
486
|
-
for (const key of Object.keys(mapping))
|
|
487
|
-
if (key !== "woodpecker_profile" && key !== "ssh_credential_ref")
|
|
488
|
-
throw new Error(`Unknown profile_bindings.${profile}.${key}`);
|
|
489
|
-
return [
|
|
490
|
-
profile,
|
|
491
|
-
Object.freeze({
|
|
492
|
-
woodpeckerProfile: field(
|
|
493
|
-
mapping.woodpecker_profile,
|
|
494
|
-
profile,
|
|
495
|
-
`profile_bindings.${profile}.woodpecker_profile`
|
|
496
|
-
),
|
|
497
|
-
sshCredentialRef: field(
|
|
498
|
-
mapping.ssh_credential_ref,
|
|
499
|
-
profile,
|
|
500
|
-
`profile_bindings.${profile}.ssh_credential_ref`
|
|
501
|
-
)
|
|
502
|
-
})
|
|
503
|
-
];
|
|
36
|
+
return parseRepositoryProfileBindings(raw, "forgejo-repo-change", {
|
|
37
|
+
woodpeckerProfile: "woodpecker_profile",
|
|
38
|
+
sshCredentialRef: "ssh_credential_ref"
|
|
504
39
|
});
|
|
505
|
-
return Object.freeze(Object.fromEntries(entries));
|
|
506
40
|
}
|
|
507
41
|
function resolveProfileBinding(bindings, profile) {
|
|
508
42
|
return Object.hasOwn(bindings, profile) ? { ...bindings[profile] } : { woodpeckerProfile: profile, sshCredentialRef: profile };
|
|
@@ -512,7 +46,6 @@ function resolveProfileBinding(bindings, profile) {
|
|
|
512
46
|
var forgejoRepoChangeUiLauncherId = "forgejo_repo_change_process.ui_launcher";
|
|
513
47
|
function forgejoRepoChangeParams(repository, input) {
|
|
514
48
|
return {
|
|
515
|
-
launchKind: "requested_change",
|
|
516
49
|
repoLocator: repository.ssh_url,
|
|
517
50
|
baseBranch: repository.default_branch,
|
|
518
51
|
workBranch: input.workBranch,
|
|
@@ -566,56 +99,18 @@ function createForgejoRepoChangeLauncher() {
|
|
|
566
99
|
if (!dependencies) throw new Error("Forgejo repository launcher is not configured");
|
|
567
100
|
return dependencies;
|
|
568
101
|
}
|
|
569
|
-
function sshPreparationCheck(access, params) {
|
|
570
|
-
return {
|
|
571
|
-
id: `ssh_${access}`,
|
|
572
|
-
label: `Verify SSH ${access} access`,
|
|
573
|
-
async run({ signal, logger }) {
|
|
574
|
-
signal.throwIfAborted();
|
|
575
|
-
const result = await requireDependencies().gitSsh.preflight({
|
|
576
|
-
credentialRef: params.sshCredentialRef,
|
|
577
|
-
repoLocator: params.repoLocator,
|
|
578
|
-
baseBranch: params.baseBranch,
|
|
579
|
-
requireWrite: access === "write"
|
|
580
|
-
});
|
|
581
|
-
signal.throwIfAborted();
|
|
582
|
-
if (!result.ok) {
|
|
583
|
-
logger.warn(`Git SSH ${result.access} preflight failed: ${result.detail}`);
|
|
584
|
-
throw new SafeLaunchPreparationError(
|
|
585
|
-
`SSH ${result.access} access failed: ${result.detail}`,
|
|
586
|
-
`Authorize Git SSH profile '${params.sshCredentialRef}' for '${params.owner}/${params.repo}' with read/write access, then try again.`
|
|
587
|
-
);
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
};
|
|
591
|
-
}
|
|
592
102
|
function forgejoRepositoryPreparationChecks(_input, { params }) {
|
|
593
103
|
return [
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
);
|
|
603
|
-
signal.throwIfAborted();
|
|
604
|
-
if (!visible) {
|
|
605
|
-
throw new SafeLaunchPreparationError(
|
|
606
|
-
"Repository is not visible",
|
|
607
|
-
"Grant the selected Forgejo profile access to the repository, then try again."
|
|
608
|
-
);
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
},
|
|
612
|
-
sshPreparationCheck("read", params),
|
|
613
|
-
sshPreparationCheck("write", params)
|
|
104
|
+
repositoryVisibilityCheck(
|
|
105
|
+
"Forgejo",
|
|
106
|
+
async () => (await repositories(params.forgejoProfile)).some(
|
|
107
|
+
(candidate) => candidate.full_name === `${params.owner}/${params.repo}`
|
|
108
|
+
)
|
|
109
|
+
),
|
|
110
|
+
createGitSshPreparationCheck("read", params, () => requireDependencies().gitSsh),
|
|
111
|
+
createGitSshPreparationCheck("write", params, () => requireDependencies().gitSsh)
|
|
614
112
|
];
|
|
615
113
|
}
|
|
616
|
-
function validationError(fieldId, message, code = "required") {
|
|
617
|
-
return { code, fieldId, message };
|
|
618
|
-
}
|
|
619
114
|
function resolveProfiles(profile) {
|
|
620
115
|
const { forgejo, woodpecker, gitSsh, profileBindings = {} } = requireDependencies();
|
|
621
116
|
if (!forgejo.profiles().includes(profile)) throw new Error("Forgejo profile is not available");
|
|
@@ -639,121 +134,19 @@ function createForgejoRepoChangeLauncher() {
|
|
|
639
134
|
if (!forgejo.profiles().includes(profile)) return [];
|
|
640
135
|
return forgejo.client(profile).listRepositories();
|
|
641
136
|
}
|
|
642
|
-
const forgejoRepoChangeUiLauncher = {
|
|
137
|
+
const forgejoRepoChangeUiLauncher = createRepositoryChangeUiLauncher({
|
|
643
138
|
id: forgejoRepoChangeUiLauncherId,
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
fields: [
|
|
656
|
-
{
|
|
657
|
-
id: "forgejoProfile",
|
|
658
|
-
label: "Forgejo profile",
|
|
659
|
-
kind: "select",
|
|
660
|
-
required: true,
|
|
661
|
-
description: "Forgejo profile with server-configured CI and Git SSH access."
|
|
662
|
-
},
|
|
663
|
-
{
|
|
664
|
-
id: "repository",
|
|
665
|
-
label: "Repository",
|
|
666
|
-
kind: "select",
|
|
667
|
-
required: true,
|
|
668
|
-
description: "Repository visible to the selected Forgejo profile."
|
|
669
|
-
},
|
|
670
|
-
{
|
|
671
|
-
id: "prompt",
|
|
672
|
-
label: "Requested change",
|
|
673
|
-
kind: "textarea",
|
|
674
|
-
required: true,
|
|
675
|
-
placeholder: "Describe the change to plan, implement, review, and publish."
|
|
676
|
-
}
|
|
677
|
-
],
|
|
678
|
-
submitLabel: "Start change"
|
|
679
|
-
},
|
|
680
|
-
resolveDefaults() {
|
|
681
|
-
return {
|
|
682
|
-
forgejoProfile: requireDependencies().forgejo.profiles()[0] ?? "",
|
|
683
|
-
repository: "",
|
|
684
|
-
prompt: ""
|
|
685
|
-
};
|
|
686
|
-
},
|
|
687
|
-
async resolveOptions(input) {
|
|
688
|
-
const { forgejo } = requireDependencies();
|
|
689
|
-
const profile = trimString(input.forgejoProfile);
|
|
690
|
-
return {
|
|
691
|
-
forgejoProfile: forgejo.profiles().map((value) => ({ value, label: value })),
|
|
692
|
-
repository: (await repositories(profile)).map((repository) => ({
|
|
693
|
-
value: repository.full_name,
|
|
694
|
-
label: repository.full_name,
|
|
695
|
-
description: repository.html_url
|
|
696
|
-
}))
|
|
697
|
-
};
|
|
698
|
-
},
|
|
699
|
-
preparationChecks: forgejoRepositoryPreparationChecks,
|
|
700
|
-
resolveRelaunchInput(previousInput) {
|
|
701
|
-
return {
|
|
702
|
-
forgejoProfile: trimString(previousInput.forgejoProfile),
|
|
703
|
-
repository: trimString(previousInput.repository),
|
|
704
|
-
prompt: trimString(previousInput.prompt)
|
|
705
|
-
};
|
|
706
|
-
},
|
|
707
|
-
async resolveLaunchConfig(input) {
|
|
708
|
-
const profile = trimString(input.forgejoProfile);
|
|
709
|
-
const repositoryName = trimString(input.repository);
|
|
710
|
-
const prompt = trimString(input.prompt);
|
|
711
|
-
const errors = [];
|
|
712
|
-
const invalid = (fieldId, message) => ({
|
|
713
|
-
ok: false,
|
|
714
|
-
errors: [validationError(fieldId, message, "custom_rule")]
|
|
715
|
-
});
|
|
716
|
-
const { forgejo } = requireDependencies();
|
|
717
|
-
if (!profile) errors.push(validationError("forgejoProfile", "Forgejo profile is required"));
|
|
718
|
-
else if (!forgejo.profiles().includes(profile))
|
|
719
|
-
errors.push(
|
|
720
|
-
validationError("forgejoProfile", "Forgejo profile is not available", "custom_rule")
|
|
721
|
-
);
|
|
722
|
-
if (!repositoryName) errors.push(validationError("repository", "Repository is required"));
|
|
723
|
-
if (!prompt) errors.push(validationError("prompt", "Requested change is required"));
|
|
724
|
-
if (errors.length > 0) return { ok: false, errors };
|
|
725
|
-
const repository = (await repositories(profile)).find(
|
|
726
|
-
(candidate) => candidate.full_name === repositoryName
|
|
727
|
-
);
|
|
728
|
-
if (!repository)
|
|
729
|
-
return invalid(
|
|
730
|
-
"repository",
|
|
731
|
-
"Repository is not available to the selected Forgejo profile"
|
|
732
|
-
);
|
|
733
|
-
let binding;
|
|
734
|
-
try {
|
|
735
|
-
binding = resolveProfiles(profile);
|
|
736
|
-
} catch (error) {
|
|
737
|
-
return invalid("forgejoProfile", error.message);
|
|
738
|
-
}
|
|
739
|
-
const gitIdentity = await resolveForgejoGitIdentity(profile);
|
|
740
|
-
const workBranch = buildAutoWorkBranchFromSeed(
|
|
741
|
-
prompt,
|
|
742
|
-
`${repository.ssh_url}:${repository.default_branch}`
|
|
743
|
-
);
|
|
744
|
-
const params = forgejoRepoChangeParams(repository, {
|
|
745
|
-
...binding,
|
|
746
|
-
profile,
|
|
747
|
-
prompt,
|
|
748
|
-
workBranch
|
|
749
|
-
});
|
|
750
|
-
return {
|
|
751
|
-
ok: true,
|
|
752
|
-
launchConfig: forgejoRepoChangeLaunchConfig(params, prompt, gitIdentity)
|
|
753
|
-
};
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
};
|
|
139
|
+
provider: "Forgejo",
|
|
140
|
+
providerId: "forgejo",
|
|
141
|
+
assertConfigured: requireDependencies,
|
|
142
|
+
profiles: () => requireDependencies().forgejo.profiles(),
|
|
143
|
+
repositories,
|
|
144
|
+
resolveProfiles,
|
|
145
|
+
resolveGitIdentity: resolveForgejoGitIdentity,
|
|
146
|
+
params: forgejoRepoChangeParams,
|
|
147
|
+
launchConfig: forgejoRepoChangeLaunchConfig,
|
|
148
|
+
preparationChecks: forgejoRepositoryPreparationChecks
|
|
149
|
+
});
|
|
757
150
|
return {
|
|
758
151
|
/** @internal */
|
|
759
152
|
configure: configureForgejoRepoChangeLauncher,
|
|
@@ -770,18 +163,16 @@ function createForgejoRepoChangeLauncher() {
|
|
|
770
163
|
|
|
771
164
|
// src/process.ts
|
|
772
165
|
import { createRepositoryChangeProcess } from "@leitwerk-dev/coding";
|
|
773
|
-
import { commitAndPushWorkBranch } from "@leitwerk-dev/coding/finalization-git";
|
|
774
|
-
import {
|
|
775
|
-
forgejoExternal,
|
|
776
|
-
forgejoIssueWatcherSource
|
|
777
|
-
} from "@leitwerk-dev/forgejo";
|
|
778
|
-
import { flow } from "@leitwerk-dev/process-sdk";
|
|
779
166
|
import {
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
167
|
+
createRepositoryChangePublication,
|
|
168
|
+
publicationObject as object,
|
|
169
|
+
pullRequestPublicationCallbacks,
|
|
170
|
+
pullRequestPublicationSources,
|
|
171
|
+
readPublicationState,
|
|
172
|
+
reconcilePullRequestSourceIssue,
|
|
173
|
+
resolvePullRequestGitIdentity
|
|
174
|
+
} from "@leitwerk-dev/coding/repository-change-publication";
|
|
175
|
+
import { forgejoExternal, forgejoIssueWatcherSource } from "@leitwerk-dev/forgejo";
|
|
785
176
|
import { woodpeckerExternal } from "@leitwerk-dev/woodpecker";
|
|
786
177
|
var processId = "forgejo_repo_change_process";
|
|
787
178
|
var ids = {
|
|
@@ -790,125 +181,7 @@ var ids = {
|
|
|
790
181
|
ciRepair: "repair_woodpecker_pipeline",
|
|
791
182
|
operator: "ci_operator_action"
|
|
792
183
|
};
|
|
793
|
-
var
|
|
794
|
-
stage: "not_started",
|
|
795
|
-
issueLinked: false,
|
|
796
|
-
adjustment: null,
|
|
797
|
-
terminalPullRequest: null
|
|
798
|
-
};
|
|
799
|
-
var initialRemoteState = {
|
|
800
|
-
headSha: null,
|
|
801
|
-
prNumber: null,
|
|
802
|
-
prUrl: null,
|
|
803
|
-
conversationCursor: 0,
|
|
804
|
-
reviewCursor: 0,
|
|
805
|
-
inlineCursor: 0,
|
|
806
|
-
feedbackIds: [],
|
|
807
|
-
pipeline: null,
|
|
808
|
-
ciRecoveryCycles: 0,
|
|
809
|
-
delivery: initialDeliveryState
|
|
810
|
-
};
|
|
811
|
-
var object2 = (value) => asUnknownRecord(value) ?? {};
|
|
812
|
-
function remote(state) {
|
|
813
|
-
const stored = object2(object2(state.extensionState).forgejoRepoChange);
|
|
814
|
-
return {
|
|
815
|
-
...initialRemoteState,
|
|
816
|
-
...stored,
|
|
817
|
-
delivery: {
|
|
818
|
-
...initialDeliveryState,
|
|
819
|
-
...object2(stored.delivery)
|
|
820
|
-
}
|
|
821
|
-
};
|
|
822
|
-
}
|
|
823
|
-
function patchRemote(state, patch) {
|
|
824
|
-
const current = remote(state);
|
|
825
|
-
return {
|
|
826
|
-
...state,
|
|
827
|
-
extensionState: {
|
|
828
|
-
...state.extensionState,
|
|
829
|
-
forgejoRepoChange: {
|
|
830
|
-
...current,
|
|
831
|
-
...patch,
|
|
832
|
-
delivery: { ...current.delivery, ...patch.delivery }
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
};
|
|
836
|
-
}
|
|
837
|
-
function requirePr(state) {
|
|
838
|
-
const value = remote(state);
|
|
839
|
-
const { headSha, prNumber, prUrl } = value;
|
|
840
|
-
if (!headSha || !prNumber || !prUrl) {
|
|
841
|
-
throw new Error("Pull request delivery state is incomplete");
|
|
842
|
-
}
|
|
843
|
-
return { ...value, headSha, prNumber, prUrl };
|
|
844
|
-
}
|
|
845
|
-
function feedbackKey(value) {
|
|
846
|
-
return `${value.kind}:${value.id}`;
|
|
847
|
-
}
|
|
848
|
-
function requireIssueOrigin(params) {
|
|
849
|
-
if (!isIssueOrigin(params)) throw new Error("Forgejo source issue metadata is unavailable");
|
|
850
|
-
return params;
|
|
851
|
-
}
|
|
852
|
-
function pinnedGitIdentity(ctx) {
|
|
853
|
-
const project = ctx.projects.find((candidate2) => candidate2.key === "repo");
|
|
854
|
-
const candidate = object2(project?.metadata)?.["leitwerk.gitIdentity"];
|
|
855
|
-
const identity = object2(candidate);
|
|
856
|
-
if (identity.provider !== "forgejo" || identity.profile !== ctx.params.forgejoProfile || typeof identity.login !== "string" || !identity.login.trim() || typeof identity.name !== "string" || !identity.name.trim() || typeof identity.email !== "string" || !identity.email.trim()) {
|
|
857
|
-
return null;
|
|
858
|
-
}
|
|
859
|
-
return identity;
|
|
860
|
-
}
|
|
861
|
-
async function commitWorkBranch(ctx, commitMessage) {
|
|
862
|
-
const repo = ctx.repo.get("repo");
|
|
863
|
-
const gitIdentity = pinnedGitIdentity(ctx) ?? await ctx.callIntegrationTool("forgejo_resolve_git_identity", {
|
|
864
|
-
projectKey: "repo"
|
|
865
|
-
});
|
|
866
|
-
return commitAndPushWorkBranch({
|
|
867
|
-
repoPath: repo.fsPath,
|
|
868
|
-
workBranch: repo.workBranch,
|
|
869
|
-
commitMessage,
|
|
870
|
-
gitIdentity
|
|
871
|
-
});
|
|
872
|
-
}
|
|
873
|
-
function deliveryProgress(value, activeStepId) {
|
|
874
|
-
const delivery = value.delivery;
|
|
875
|
-
const step = (id, label, done) => ({
|
|
876
|
-
id,
|
|
877
|
-
label,
|
|
878
|
-
status: activeStepId === id ? "in_progress" : done ? "completed" : "incomplete"
|
|
879
|
-
});
|
|
880
|
-
const adjustmentHandled = delivery.adjustment === null && delivery.stage === "awaiting" && value.headSha !== null;
|
|
881
|
-
return {
|
|
882
|
-
title: "Delivery progress",
|
|
883
|
-
steps: [
|
|
884
|
-
step("publish_branch", "Publish work branch", value.headSha !== null),
|
|
885
|
-
step("open_pr", "Create or find pull request", value.prNumber !== null),
|
|
886
|
-
step("link_issue", "Link source issue when applicable", delivery.issueLinked),
|
|
887
|
-
step("publish_adjustment", "Publish an adjustment when applicable", adjustmentHandled),
|
|
888
|
-
step(
|
|
889
|
-
"reply_feedback",
|
|
890
|
-
"Acknowledge or reply to feedback when applicable",
|
|
891
|
-
value.feedbackIds.length === 0
|
|
892
|
-
),
|
|
893
|
-
step("await_evidence", "Await external evidence", delivery.stage === "awaiting"),
|
|
894
|
-
step(
|
|
895
|
-
"reconcile_terminal",
|
|
896
|
-
"Reconcile terminal pull request",
|
|
897
|
-
delivery.terminalPullRequest !== null
|
|
898
|
-
)
|
|
899
|
-
],
|
|
900
|
-
...value.prNumber && value.prUrl ? {
|
|
901
|
-
links: [
|
|
902
|
-
{
|
|
903
|
-
id: `forgejo-pr-${value.prNumber}`,
|
|
904
|
-
label: `Forgejo PR #${value.prNumber}`,
|
|
905
|
-
url: value.prUrl,
|
|
906
|
-
kind: "pull_request"
|
|
907
|
-
}
|
|
908
|
-
]
|
|
909
|
-
} : {}
|
|
910
|
-
};
|
|
911
|
-
}
|
|
184
|
+
var remote = (state) => readPublicationState(state, "forgejoRepoChange");
|
|
912
185
|
var deliveryTools = [
|
|
913
186
|
"forgejo_get_pull_request",
|
|
914
187
|
"forgejo_add_pull_request_comment",
|
|
@@ -922,9 +195,14 @@ var deliveryTools = [
|
|
|
922
195
|
"forgejo_update_issue"
|
|
923
196
|
];
|
|
924
197
|
function createForgejoRepoChangeProcess(launcher, docker) {
|
|
925
|
-
const
|
|
926
|
-
"forgejo
|
|
198
|
+
const sharedSources = pullRequestPublicationSources(
|
|
199
|
+
"forgejo",
|
|
200
|
+
"Forgejo",
|
|
201
|
+
forgejoExternal,
|
|
202
|
+
(params) => params.forgejoProfile,
|
|
203
|
+
(params) => isIssueOrigin(params) ? params : void 0
|
|
927
204
|
);
|
|
205
|
+
const { requirePr } = sharedSources;
|
|
928
206
|
const failedPipeline = woodpeckerExternal.pipeline(({ params, state }) => {
|
|
929
207
|
const current = requirePr(state);
|
|
930
208
|
return {
|
|
@@ -938,376 +216,80 @@ function createForgejoRepoChangeProcess(launcher, docker) {
|
|
|
938
216
|
pollInterval: "30s"
|
|
939
217
|
};
|
|
940
218
|
});
|
|
941
|
-
const
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
const result = (outcome) => ({
|
|
948
|
-
outcome,
|
|
949
|
-
params: { nextState: patchRemote(ctx.state, current) }
|
|
950
|
-
});
|
|
951
|
-
ctx.reportProgress(deliveryProgress(current));
|
|
952
|
-
if (current.delivery.terminalPullRequest) {
|
|
953
|
-
ctx.reportProgress(deliveryProgress(current, "reconcile_terminal"));
|
|
954
|
-
const pr = current.delivery.terminalPullRequest;
|
|
955
|
-
if (isIssueOrigin(ctx.params)) {
|
|
956
|
-
const issue = await call("forgejo_get_issue", {
|
|
957
|
-
issueNumber: ctx.params.issueNumber
|
|
958
|
-
});
|
|
959
|
-
let labels = issue.labels.filter((label) => label.name !== ctx.params.triggerLabel).map((label) => label.id);
|
|
960
|
-
if (pr.merged) {
|
|
961
|
-
const done = await call("forgejo_ensure_label", {
|
|
962
|
-
name: ctx.params.doneLabel
|
|
963
|
-
});
|
|
964
|
-
labels = [.../* @__PURE__ */ new Set([...labels, done.id])];
|
|
965
|
-
}
|
|
966
|
-
await call("forgejo_update_issue", {
|
|
967
|
-
issueNumber: ctx.params.issueNumber,
|
|
968
|
-
patch: { labels, ...pr.merged ? { state: "closed" } : {} },
|
|
969
|
-
writeKey: `forgejo:${ctx.process.id}:${pr.merged ? "complete-source-issue" : "remove-source-trigger"}`
|
|
970
|
-
});
|
|
971
|
-
await call("forgejo_add_issue_comment", {
|
|
972
|
-
issueNumber: ctx.params.issueNumber,
|
|
973
|
-
body: pr.merged ? `Merged ${pr.html_url}${pr.merge_commit_sha ? ` at ${pr.merge_commit_sha}` : ""}.` : `Leitwerk stopped because ${pr.html_url} was closed without merge.`,
|
|
974
|
-
writeKey: `forgejo:${ctx.process.id}:${pr.merged ? "merged" : "closed"}-pr-comment`
|
|
975
|
-
});
|
|
976
|
-
}
|
|
977
|
-
ctx.reportProgress(deliveryProgress(current));
|
|
978
|
-
return result(pr.merged ? "completed" : "aborted");
|
|
979
|
-
}
|
|
980
|
-
if (!current.headSha) {
|
|
981
|
-
ctx.reportProgress(deliveryProgress(current, "publish_branch"));
|
|
982
|
-
const published = await commitWorkBranch(
|
|
983
|
-
ctx,
|
|
984
|
-
ctx.state.finalization.generatedCommitMessage ?? ""
|
|
985
|
-
);
|
|
986
|
-
update({ headSha: published.headSha, pipeline: null });
|
|
987
|
-
}
|
|
988
|
-
if (!current.prNumber || !current.prUrl) {
|
|
989
|
-
ctx.reportProgress(deliveryProgress(current, "open_pr"));
|
|
990
|
-
const project = ctx.repo.get("repo");
|
|
991
|
-
const issueOrigin = isIssueOrigin(ctx.params);
|
|
992
|
-
const pr = await call("forgejo_ensure_pull_request", {
|
|
993
|
-
title: ctx.process.title ?? (issueOrigin ? `Issue #${ctx.params.issueNumber}` : "Leitwerk change"),
|
|
994
|
-
body: issueOrigin ? `Implements ${ctx.params.issueUrl}
|
|
995
|
-
|
|
996
|
-
Leitwerk process: ${ctx.process.id}` : `Leitwerk process: ${ctx.process.id}`,
|
|
997
|
-
head: project.workBranch,
|
|
998
|
-
base: project.baseBranch
|
|
999
|
-
});
|
|
1000
|
-
if (!pr) throw new Error("Forgejo pull request could not be created or found");
|
|
1001
|
-
update({ prNumber: pr.number, prUrl: pr.html_url });
|
|
1002
|
-
}
|
|
1003
|
-
if (!current.delivery.issueLinked) {
|
|
1004
|
-
ctx.reportProgress(deliveryProgress(current, "link_issue"));
|
|
1005
|
-
if (isIssueOrigin(ctx.params)) {
|
|
1006
|
-
await call("forgejo_add_issue_comment", {
|
|
1007
|
-
issueNumber: ctx.params.issueNumber,
|
|
1008
|
-
body: `Leitwerk opened pull request ${current.prUrl}.`,
|
|
1009
|
-
writeKey: `forgejo:${ctx.process.id}:source-pr-link:${current.prNumber}`
|
|
1010
|
-
});
|
|
1011
|
-
}
|
|
1012
|
-
update({ delivery: { issueLinked: true } });
|
|
1013
|
-
}
|
|
1014
|
-
if (current.delivery.adjustment) {
|
|
1015
|
-
const adjustment = current.delivery.adjustment;
|
|
1016
|
-
if (adjustment.publishRequired || adjustment.origin === "rebase") {
|
|
1017
|
-
ctx.reportProgress(deliveryProgress(current, "publish_adjustment"));
|
|
1018
|
-
const published = adjustment.origin === "rebase" ? publishRebase(rebaseInput(ctx)) : await commitWorkBranch(
|
|
1019
|
-
ctx,
|
|
1020
|
-
adjustment.origin === "feedback" ? "fix: address Forgejo review feedback" : "fix: repair Woodpecker pipeline"
|
|
1021
|
-
);
|
|
1022
|
-
if (adjustment.origin === "rebase") {
|
|
1023
|
-
const refreshed = await call("forgejo_get_pull_request", {
|
|
1024
|
-
pullRequestNumber: current.prNumber
|
|
1025
|
-
});
|
|
1026
|
-
if (refreshed.head.sha !== published.headSha)
|
|
1027
|
-
throw new Error("Pull request head has not caught up with rebase publication");
|
|
1028
|
-
}
|
|
1029
|
-
update({ headSha: published.headSha, pipeline: null });
|
|
1030
|
-
}
|
|
1031
|
-
if (adjustment.origin === "rebase")
|
|
1032
|
-
await call("forgejo_add_pull_request_comment", {
|
|
1033
|
-
pullRequestNumber: current.prNumber,
|
|
1034
|
-
body: `Merge conflict repair completed at ${current.headSha}; base ${current.conflict?.baseSha}.`,
|
|
1035
|
-
writeKey: `rebase:${ctx.process.id}:${current.lastConflictKey}:${current.headSha}`
|
|
1036
|
-
});
|
|
1037
|
-
if (adjustment.origin === "feedback") {
|
|
1038
|
-
ctx.reportProgress(deliveryProgress(current, "reply_feedback"));
|
|
1039
|
-
for (const feedback of current.feedbackIds) {
|
|
1040
|
-
await call("forgejo_reply_to_pull_request_feedback", {
|
|
1041
|
-
pullRequestNumber: current.prNumber,
|
|
1042
|
-
feedbackKind: feedback.kind,
|
|
1043
|
-
feedbackId: feedback.id,
|
|
1044
|
-
body: `Addressed in ${current.headSha?.slice(0, 8) ?? "the current revision"}.`,
|
|
1045
|
-
writeKey: `forgejo:${ctx.process.id}:feedback-reply:${feedbackKey(feedback)}:${current.headSha}`
|
|
1046
|
-
});
|
|
1047
|
-
}
|
|
1048
|
-
}
|
|
1049
|
-
update({
|
|
1050
|
-
...adjustment.origin === "feedback" ? { feedbackIds: [] } : {},
|
|
1051
|
-
delivery: { adjustment: null }
|
|
1052
|
-
});
|
|
1053
|
-
}
|
|
1054
|
-
if (current.feedbackIds.length > 0) {
|
|
1055
|
-
ctx.reportProgress(deliveryProgress(current, "reply_feedback"));
|
|
1056
|
-
for (const feedback of current.feedbackIds) {
|
|
1057
|
-
if (feedback.kind === "review") continue;
|
|
1058
|
-
await call("forgejo_add_pull_request_feedback_reaction", {
|
|
1059
|
-
pullRequestNumber: current.prNumber,
|
|
1060
|
-
feedbackKind: feedback.kind,
|
|
1061
|
-
feedbackId: feedback.id,
|
|
1062
|
-
writeKey: `forgejo:${ctx.process.id}:feedback-eyes:${feedbackKey(feedback)}`
|
|
1063
|
-
});
|
|
1064
|
-
}
|
|
1065
|
-
return result("feedback_ready");
|
|
1066
|
-
}
|
|
1067
|
-
update({ delivery: { stage: "awaiting" } });
|
|
1068
|
-
ctx.reportProgress(deliveryProgress(current, "await_evidence"));
|
|
1069
|
-
return result("awaiting");
|
|
1070
|
-
}).outcome(
|
|
1071
|
-
"awaiting",
|
|
1072
|
-
(outcome) => outcome.description("Delivery is waiting for external evidence").object("nextState").wait().state(({ event }) => event.params.nextState)
|
|
1073
|
-
).outcome(
|
|
1074
|
-
"feedback_ready",
|
|
1075
|
-
(outcome) => outcome.description("Pull request feedback is acknowledged and ready for revision").object("nextState").to(ids.feedback).state(({ event }) => event.params.nextState)
|
|
1076
|
-
).outcome(
|
|
1077
|
-
"completed",
|
|
1078
|
-
(outcome) => outcome.description("Merged pull request was reconciled").object("nextState").complete().state(({ event }) => event.params.nextState)
|
|
1079
|
-
).outcome(
|
|
1080
|
-
"aborted",
|
|
1081
|
-
(outcome) => outcome.description("Closed pull request was reconciled").object("nextState").lifecycleStatus("aborted").state(({ event }) => event.params.nextState)
|
|
1082
|
-
).externalAction(
|
|
1083
|
-
"forgejo_merge_conflict",
|
|
1084
|
-
forgejoExternal.pullRequestConflict(({ params, state }) => ({
|
|
1085
|
-
profile: params.forgejoProfile,
|
|
1086
|
-
owner: params.owner,
|
|
1087
|
-
repo: params.repo,
|
|
1088
|
-
prNumber: requirePr(state).prNumber,
|
|
1089
|
-
headSha: requirePr(state).headSha,
|
|
1090
|
-
lastConflictKey: remote(state).lastConflictKey,
|
|
1091
|
-
pollInterval: "30s"
|
|
1092
|
-
})),
|
|
1093
|
-
(external) => external.label("Rebase conflicting pull request").to(ids.feedback).effect(({ params, state, event }) => {
|
|
1094
|
-
const current = requirePr(state);
|
|
1095
|
-
const conflict = validateConflict(
|
|
1096
|
-
object2(event).conflict,
|
|
1097
|
-
{
|
|
1098
|
-
owner: params.owner,
|
|
1099
|
-
repo: params.repo,
|
|
1100
|
-
prNumber: current.prNumber,
|
|
1101
|
-
headSha: current.headSha,
|
|
1102
|
-
headBranch: params.workBranch,
|
|
1103
|
-
baseBranch: params.baseBranch
|
|
1104
|
-
},
|
|
1105
|
-
current.lastConflictKey
|
|
1106
|
-
);
|
|
1107
|
-
return {
|
|
1108
|
-
state: patchRemote(state, {
|
|
1109
|
-
lastConflictKey: conflictKey(conflict),
|
|
1110
|
-
conflict,
|
|
1111
|
-
repairReason: "rebase"
|
|
1112
|
-
})
|
|
1113
|
-
};
|
|
1114
|
-
})
|
|
1115
|
-
).externalAction(
|
|
1116
|
-
"forgejo_feedback",
|
|
1117
|
-
forgejoExternal.pullRequestFeedback(({ params, state }) => {
|
|
1118
|
-
const current = requirePr(state);
|
|
1119
|
-
return {
|
|
1120
|
-
profile: params.forgejoProfile,
|
|
1121
|
-
owner: params.owner,
|
|
1122
|
-
repo: params.repo,
|
|
1123
|
-
prNumber: current.prNumber,
|
|
1124
|
-
conversationCursor: current.conversationCursor,
|
|
1125
|
-
reviewCursor: current.reviewCursor,
|
|
1126
|
-
inlineCursor: current.inlineCursor,
|
|
1127
|
-
quietPeriodMs: 12e4,
|
|
1128
|
-
pollInterval: "30s"
|
|
1129
|
-
};
|
|
1130
|
-
}),
|
|
1131
|
-
(external) => external.label("Forgejo pull request feedback").to(ids.deliver).effect(({ state, event }) => {
|
|
1132
|
-
const value = object2(event);
|
|
1133
|
-
const cursors = object2(value.cursors);
|
|
1134
|
-
return {
|
|
1135
|
-
state: patchRemote(state, {
|
|
1136
|
-
repairReason: "feedback",
|
|
1137
|
-
conversationCursor: Number(
|
|
1138
|
-
cursors.conversationCursor ?? remote(state).conversationCursor
|
|
1139
|
-
),
|
|
1140
|
-
reviewCursor: Number(cursors.reviewCursor ?? remote(state).reviewCursor),
|
|
1141
|
-
inlineCursor: Number(cursors.inlineCursor ?? remote(state).inlineCursor),
|
|
1142
|
-
feedbackIds: Array.isArray(value.feedbackIds) ? value.feedbackIds : []
|
|
1143
|
-
})
|
|
1144
|
-
};
|
|
1145
|
-
})
|
|
1146
|
-
).externalAction(
|
|
1147
|
-
"woodpecker_failure_repair",
|
|
1148
|
-
failedPipeline,
|
|
1149
|
-
(external) => external.label("Repair failed Woodpecker pipeline").when(({ state }) => remote(state).ciRecoveryCycles < 3).to(ids.ciRepair).effect(({ state, event }) => ({
|
|
1150
|
-
state: patchRemote(state, {
|
|
1151
|
-
repairReason: "ci",
|
|
1152
|
-
pipeline: object2(event).pipeline,
|
|
1153
|
-
ciRecoveryCycles: remote(state).ciRecoveryCycles + 1
|
|
1154
|
-
})
|
|
1155
|
-
}))
|
|
1156
|
-
).externalAction(
|
|
1157
|
-
"woodpecker_failure_operator",
|
|
1158
|
-
failedPipeline,
|
|
1159
|
-
(external) => external.label("Escalate failed Woodpecker pipeline").when(({ state }) => remote(state).ciRecoveryCycles >= 3).to(ids.operator).effect(({ state, event }) => ({
|
|
1160
|
-
state: patchRemote(state, {
|
|
1161
|
-
repairReason: "ci",
|
|
1162
|
-
pipeline: object2(event).pipeline
|
|
1163
|
-
})
|
|
1164
|
-
}))
|
|
1165
|
-
);
|
|
1166
|
-
for (const [terminalOutcome, label] of [
|
|
1167
|
-
["merged", "Forgejo pull request merged"],
|
|
1168
|
-
["closed", "Forgejo pull request closed without merge"]
|
|
1169
|
-
]) {
|
|
1170
|
-
delivery.externalAction(
|
|
1171
|
-
`forgejo_pr_${terminalOutcome}`,
|
|
1172
|
-
forgejoExternal.pullRequestTerminal(({ params, state }) => ({
|
|
219
|
+
const sources = [
|
|
220
|
+
{
|
|
221
|
+
id: "forgejo_merge_conflict",
|
|
222
|
+
kind: "conflict",
|
|
223
|
+
label: "Rebase conflicting pull request",
|
|
224
|
+
source: forgejoExternal.pullRequestConflict(({ params, state }) => ({
|
|
1173
225
|
profile: params.forgejoProfile,
|
|
1174
226
|
owner: params.owner,
|
|
1175
227
|
repo: params.repo,
|
|
1176
228
|
prNumber: requirePr(state).prNumber,
|
|
1177
|
-
|
|
229
|
+
headSha: requirePr(state).headSha,
|
|
230
|
+
lastConflictKey: remote(state).lastConflictKey,
|
|
1178
231
|
pollInterval: "30s"
|
|
1179
232
|
})),
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
"
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
}
|
|
1210
|
-
function repairReason(state, kind) {
|
|
1211
|
-
return kind === "feedback" && remote(state).repairReason === "rebase" ? "rebase" : kind;
|
|
1212
|
-
}
|
|
1213
|
-
function revisionPrompt(kind) {
|
|
1214
|
-
return (ctx) => {
|
|
1215
|
-
const current = remote(ctx.state);
|
|
1216
|
-
if (repairReason(ctx.state, kind) === "rebase")
|
|
1217
|
-
return `${rebasePrompt} Evidence: ${JSON.stringify(current.conflict)}. Call changes_ready or no_changes when verified complete, cannot_repair when blocked.`;
|
|
1218
|
-
return kind === "feedback" ? `Address the unseen Forgejo pull-request feedback batch for PR #${current.prNumber}. Feedback identifiers: ${JSON.stringify(current.feedbackIds)}. Inspect the current checkout and use Forgejo tools to read the full feedback. Do not rely on an earlier plan or conversation. Make only justified repository changes. Call changes_ready if files need publishing, no_changes after an explicit diagnosis that no repository change is needed, or cannot_repair when operator action is required.` : `Diagnose Woodpecker pipeline #${current.pipeline?.number ?? "unknown"} (${current.pipeline?.status ?? "unknown"}) for the current checkout. Use Woodpecker tools to inspect pipeline metadata and bounded failed-step logs before changing anything. Fix repository causes. Call changes_ready for repository changes, no_changes only after an explicit provider restart or a justified diagnosis that no repository change is needed, or cannot_repair when operator action is required.`;
|
|
1219
|
-
};
|
|
1220
|
-
}
|
|
1221
|
-
function revisionTurn(id, kind) {
|
|
1222
|
-
const turn = flow.llm(id).description(kind === "feedback" ? "Address Feedback" : "Fix CI").tools("read", "bash", "edit", "write").resolveIntegrationTools(
|
|
1223
|
-
(_params, state) => repairReason(state, kind) === "rebase" ? [] : kind === "feedback" ? ["forgejo_get_pull_request", "forgejo_list_pull_request_feedback"] : [
|
|
233
|
+
read: ({ event }) => ({
|
|
234
|
+
kind: "conflict",
|
|
235
|
+
conflict: object(event).conflict
|
|
236
|
+
})
|
|
237
|
+
},
|
|
238
|
+
sharedSources.feedback,
|
|
239
|
+
{
|
|
240
|
+
id: "woodpecker_failure_repair",
|
|
241
|
+
operatorId: "woodpecker_failure_operator",
|
|
242
|
+
kind: "failure",
|
|
243
|
+
label: "Repair failed Woodpecker pipeline",
|
|
244
|
+
source: failedPipeline,
|
|
245
|
+
read: ({ event }) => ({
|
|
246
|
+
kind: "failure",
|
|
247
|
+
pipeline: object(event).pipeline
|
|
248
|
+
})
|
|
249
|
+
},
|
|
250
|
+
...sharedSources.terminal,
|
|
251
|
+
sharedSources.cancelled
|
|
252
|
+
];
|
|
253
|
+
const publicationConfig = createRepositoryChangePublication({
|
|
254
|
+
namespace: "forgejoRepoChange",
|
|
255
|
+
label: "Forgejo PR",
|
|
256
|
+
ids,
|
|
257
|
+
sources,
|
|
258
|
+
tools: {
|
|
259
|
+
delivery: deliveryTools,
|
|
260
|
+
feedback: ["forgejo_get_pull_request", "forgejo_list_pull_request_feedback"],
|
|
261
|
+
ci: [
|
|
1224
262
|
"woodpecker_lookup_repository",
|
|
1225
263
|
"woodpecker_list_pipelines",
|
|
1226
264
|
"woodpecker_get_pipeline",
|
|
1227
265
|
"woodpecker_get_step_logs",
|
|
1228
266
|
"woodpecker_restart_pipeline"
|
|
1229
267
|
]
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
)
|
|
1245
|
-
}
|
|
1246
|
-
return turn.outcomeTool(
|
|
1247
|
-
"cannot_repair",
|
|
1248
|
-
(tool) => tool.description("The adjustment requires operator action").to(ids.operator)
|
|
1249
|
-
);
|
|
1250
|
-
}
|
|
1251
|
-
publication.turn(revisionTurn(ids.feedback, "feedback"));
|
|
1252
|
-
publication.turn(revisionTurn(ids.ciRepair, "ci"));
|
|
1253
|
-
publication.turn({
|
|
1254
|
-
id: ids.operator,
|
|
1255
|
-
definition: {
|
|
1256
|
-
kind: "human",
|
|
1257
|
-
description: "Repository repair needs operator action",
|
|
1258
|
-
operatorAttention: "required",
|
|
1259
|
-
actions: {
|
|
1260
|
-
retry_repair: {
|
|
1261
|
-
label: "Retry repair",
|
|
1262
|
-
acceptanceState: "accepted",
|
|
1263
|
-
branches: { feedback: { to: ids.feedback }, ci: { to: ids.ciRepair } },
|
|
1264
|
-
choose: ({ ctx }) => remote(ctx.state).repairReason === "rebase" || remote(ctx.state).repairReason === "feedback" ? "feedback" : "ci"
|
|
1265
|
-
},
|
|
1266
|
-
resume_waiting: {
|
|
1267
|
-
label: "Resume waiting",
|
|
1268
|
-
acceptanceState: "accepted",
|
|
1269
|
-
to: ids.deliver,
|
|
1270
|
-
effect: ({ ctx }) => ({
|
|
1271
|
-
state: patchRemote(ctx.state, {
|
|
1272
|
-
feedbackIds: [],
|
|
1273
|
-
delivery: { adjustment: null }
|
|
1274
|
-
})
|
|
1275
|
-
})
|
|
1276
|
-
},
|
|
1277
|
-
abort: { label: "Abort process", acceptanceState: "neutral", lifecycleStatus: "aborted" }
|
|
1278
|
-
}
|
|
268
|
+
},
|
|
269
|
+
identity: (ctx) => resolvePullRequestGitIdentity(ctx, "forgejo", ctx.params.forgejoProfile),
|
|
270
|
+
reconcileTerminal: reconcilePullRequestSourceIssue(
|
|
271
|
+
"forgejo",
|
|
272
|
+
"id",
|
|
273
|
+
(params) => isIssueOrigin(params) ? params : void 0
|
|
274
|
+
),
|
|
275
|
+
...pullRequestPublicationCallbacks(
|
|
276
|
+
"forgejo",
|
|
277
|
+
"Forgejo",
|
|
278
|
+
(params) => isIssueOrigin(params) ? params : void 0
|
|
279
|
+
),
|
|
280
|
+
commitMessage: (kind) => kind === "feedback" ? "fix: address Forgejo review feedback" : "fix: repair Woodpecker pipeline",
|
|
281
|
+
prompt(kind, current) {
|
|
282
|
+
return kind === "feedback" ? `Address the unseen Forgejo pull-request feedback batch for PR #${current.prNumber}. Feedback identifiers: ${JSON.stringify(current.feedbackIds)}. Inspect the current checkout and use Forgejo tools to read the full feedback. Do not rely on an earlier plan or conversation. Make only justified repository changes. Call changes_ready if files need publishing, no_changes after an explicit diagnosis that no repository change is needed, or cannot_repair when operator action is required.` : `Diagnose Woodpecker pipeline #${current.pipeline?.number ?? "unknown"} (${current.pipeline?.status ?? "unknown"}) for the current checkout. Use Woodpecker tools to inspect pipeline metadata and bounded failed-step logs before changing anything. Fix repository causes. Call changes_ready for repository changes, no_changes only after an explicit provider restart or a justified diagnosis that no repository change is needed, or cannot_repair when operator action is required.`;
|
|
1279
283
|
}
|
|
1280
284
|
});
|
|
285
|
+
const publication = publicationConfig.fragment;
|
|
1281
286
|
publication.watcher({
|
|
1282
287
|
id: "use_leitwerk",
|
|
1283
288
|
label: "Forgejo use-leitwerk issues",
|
|
1284
289
|
description: "Launch a remote repository change for Forgejo issues carrying the trigger label",
|
|
1285
290
|
source: forgejoIssueWatcherSource,
|
|
1286
291
|
preparationChecks: launcher.preparationChecks,
|
|
1287
|
-
|
|
1288
|
-
const issueNumber = issue.number;
|
|
1289
|
-
const title = issue.title.trim();
|
|
1290
|
-
const body = issue.body?.trim() ?? "";
|
|
1291
|
-
const issueUrl = issue.html_url;
|
|
1292
|
-
const binding = launcher.resolveProfiles(profile);
|
|
1293
|
-
const gitIdentity = await launcher.resolveGitIdentity(profile);
|
|
1294
|
-
const params = {
|
|
1295
|
-
...forgejoRepoChangeParams(repository, {
|
|
1296
|
-
...binding,
|
|
1297
|
-
profile,
|
|
1298
|
-
workBranch: `leitwerk/issue-${issueNumber}`,
|
|
1299
|
-
prompt: `${title}${body ? `
|
|
1300
|
-
|
|
1301
|
-
${body}` : ""}`
|
|
1302
|
-
}),
|
|
1303
|
-
origin: "issue",
|
|
1304
|
-
issueNumber,
|
|
1305
|
-
issueUrl,
|
|
1306
|
-
triggerLabel: labels.trigger,
|
|
1307
|
-
doneLabel: labels.done
|
|
1308
|
-
};
|
|
1309
|
-
return forgejoRepoChangeLaunchConfig(params, title, gitIdentity);
|
|
1310
|
-
}
|
|
292
|
+
resolveLaunchConfig: launcher.launcher.resolveIssueLaunchConfig
|
|
1311
293
|
});
|
|
1312
294
|
const definition = createRepositoryChangeProcess({
|
|
1313
295
|
processId,
|
|
@@ -1321,7 +303,6 @@ ${body}` : ""}`
|
|
|
1321
303
|
fields: [],
|
|
1322
304
|
submitLabel: "Publish"
|
|
1323
305
|
},
|
|
1324
|
-
finalizationDescription: "Publish feature branch",
|
|
1325
306
|
repositoryCredentials: ({ params }) => [
|
|
1326
307
|
{
|
|
1327
308
|
projectKey: "repo",
|
|
@@ -1329,11 +310,7 @@ ${body}` : ""}`
|
|
|
1329
310
|
credentialRef: params.sshCredentialRef
|
|
1330
311
|
}
|
|
1331
312
|
],
|
|
1332
|
-
publication:
|
|
1333
|
-
entryTurnId: ids.deliver,
|
|
1334
|
-
fragment: publication,
|
|
1335
|
-
happyPath: [ids.deliver]
|
|
1336
|
-
}
|
|
313
|
+
publication: publicationConfig
|
|
1337
314
|
});
|
|
1338
315
|
definition.process.runtime = { ...definition.process.runtime, docker };
|
|
1339
316
|
return definition.process;
|