@yemi33/minions 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/engine/ado.js +6 -0
- package/engine/github.js +14 -3
- package/engine/lifecycle.js +1 -0
- package/engine.js +9 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/engine/ado.js
CHANGED
|
@@ -339,6 +339,11 @@ async function reconcilePrs(config) {
|
|
|
339
339
|
// PR already tracked — write link to pr-links.json if we can extract an ID
|
|
340
340
|
if (confirmedItemId) {
|
|
341
341
|
addPrLink(prId, confirmedItemId);
|
|
342
|
+
const existing = existingPrs.find(p => p.id === prId);
|
|
343
|
+
if (existing && !(existing.prdItems || []).includes(confirmedItemId)) {
|
|
344
|
+
existing.prdItems = Array.isArray(existing.prdItems) ? existing.prdItems : [];
|
|
345
|
+
existing.prdItems.push(confirmedItemId);
|
|
346
|
+
}
|
|
342
347
|
projectUpdated++;
|
|
343
348
|
}
|
|
344
349
|
continue;
|
|
@@ -354,6 +359,7 @@ async function reconcilePrs(config) {
|
|
|
354
359
|
status: 'active',
|
|
355
360
|
created: (adoPr.creationDate || '').slice(0, 10) || e.dateStamp(),
|
|
356
361
|
url: prUrl,
|
|
362
|
+
prdItems: confirmedItemId ? [confirmedItemId] : [],
|
|
357
363
|
});
|
|
358
364
|
if (confirmedItemId) addPrLink(prId, confirmedItemId);
|
|
359
365
|
existingIds.add(prId);
|
package/engine/github.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
const shared = require('./shared');
|
|
8
|
-
const { exec, getProjects, projectPrPath, projectWorkItemsPath, safeJson, safeWrite, MINIONS_DIR } = shared;
|
|
8
|
+
const { exec, getProjects, projectPrPath, projectWorkItemsPath, safeJson, safeWrite, MINIONS_DIR, addPrLink } = shared;
|
|
9
9
|
const { getPrs } = require('./queries');
|
|
10
10
|
const path = require('path');
|
|
11
11
|
|
|
@@ -285,14 +285,24 @@ async function reconcilePrs(config) {
|
|
|
285
285
|
|
|
286
286
|
for (const ghPr of ghPrs) {
|
|
287
287
|
const prId = `PR-${ghPr.number}`;
|
|
288
|
-
if (existingIds.has(prId)) continue;
|
|
289
|
-
|
|
290
288
|
const branch = ghPr.head?.ref || '';
|
|
291
289
|
const wiMatch = branch.match(/(P-[a-f0-9]{6,})/i) || branch.match(/(PL-W\d+)/i);
|
|
292
290
|
const linkedItemId = wiMatch ? wiMatch[1] : null;
|
|
293
291
|
const linkedItem = linkedItemId ? allItems.find(i => i.id === linkedItemId) : null;
|
|
294
292
|
const confirmedItemId = linkedItem ? linkedItemId : null;
|
|
295
293
|
|
|
294
|
+
if (existingIds.has(prId)) {
|
|
295
|
+
if (confirmedItemId) {
|
|
296
|
+
addPrLink(prId, confirmedItemId);
|
|
297
|
+
const existing = existingPrs.find(p => p.id === prId);
|
|
298
|
+
if (existing && !(existing.prdItems || []).includes(confirmedItemId)) {
|
|
299
|
+
existing.prdItems = Array.isArray(existing.prdItems) ? existing.prdItems : [];
|
|
300
|
+
existing.prdItems.push(confirmedItemId);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
|
|
296
306
|
const prUrl = project.prUrlBase ? project.prUrlBase + ghPr.number : ghPr.html_url || '';
|
|
297
307
|
|
|
298
308
|
existingPrs.push({
|
|
@@ -306,6 +316,7 @@ async function reconcilePrs(config) {
|
|
|
306
316
|
url: prUrl,
|
|
307
317
|
prdItems: confirmedItemId ? [confirmedItemId] : [],
|
|
308
318
|
});
|
|
319
|
+
if (confirmedItemId) addPrLink(prId, confirmedItemId);
|
|
309
320
|
existingIds.add(prId);
|
|
310
321
|
projectAdded++;
|
|
311
322
|
|
package/engine/lifecycle.js
CHANGED
|
@@ -586,6 +586,7 @@ function syncPrsFromOutput(output, agentId, meta, config) {
|
|
|
586
586
|
status: 'active',
|
|
587
587
|
created: e.dateStamp(),
|
|
588
588
|
url: targetProject.prUrlBase ? targetProject.prUrlBase + prId : '',
|
|
589
|
+
prdItems: meta?.item?.id ? [meta.item.id] : [],
|
|
589
590
|
sourcePlan: meta?.item?.sourcePlan || '',
|
|
590
591
|
itemType: meta?.item?.itemType || ''
|
|
591
592
|
});
|
package/engine.js
CHANGED
|
@@ -1211,17 +1211,22 @@ function writeInboxAlert(slug, content) {
|
|
|
1211
1211
|
} catch {}
|
|
1212
1212
|
}
|
|
1213
1213
|
|
|
1214
|
-
// Reconciles work items against known PRs
|
|
1215
|
-
//
|
|
1216
|
-
//
|
|
1214
|
+
// Reconciles work items against known PRs.
|
|
1215
|
+
// Primary linkage comes from prdItems in pull-requests.json; fallback linkage
|
|
1216
|
+
// uses engine/pr-links.json so matching does not depend on branch/title parsing.
|
|
1217
1217
|
// onlyIds: if provided, only items whose ID is in this Set are eligible.
|
|
1218
1218
|
function reconcileItemsWithPrs(items, allPrs, { onlyIds } = {}) {
|
|
1219
|
+
const prLinks = shared.getPrLinks();
|
|
1219
1220
|
let reconciled = 0;
|
|
1220
1221
|
for (const wi of items) {
|
|
1221
1222
|
if (wi.status !== 'pending' || wi._pr) continue;
|
|
1222
1223
|
if (onlyIds && !onlyIds.has(wi.id)) continue;
|
|
1223
1224
|
|
|
1224
|
-
|
|
1225
|
+
let exactPr = allPrs.find(pr => (pr.prdItems || []).includes(wi.id));
|
|
1226
|
+
if (!exactPr) {
|
|
1227
|
+
const linkedPrId = Object.keys(prLinks).find(prId => prLinks[prId] === wi.id);
|
|
1228
|
+
if (linkedPrId) exactPr = allPrs.find(pr => pr.id === linkedPrId) || { id: linkedPrId };
|
|
1229
|
+
}
|
|
1225
1230
|
if (exactPr) {
|
|
1226
1231
|
wi.status = 'done';
|
|
1227
1232
|
wi._pr = exactPr.id;
|
package/package.json
CHANGED