Skip to content

Commit 94bf401

Browse files
committed
1 parent acd0c17 commit 94bf401

3 files changed

Lines changed: 18 additions & 18 deletions

File tree

ai/mcp/server/github-workflow/services/sync/IssueSyncer.mjs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,7 @@ class IssueSyncer extends Base {
142142
// For issues without a milestone, find the earliest release that was published after it was closed.
143143
const closed = new Date(issue.closedAt);
144144

145-
// The releases object is a map of tagName -> releaseData. We need to convert it to an
146-
// array of objects that include the tagName for sorting and finding.
147-
const releasesWithTags = Object.entries(ReleaseSyncer.releases || {}).map(([tagName, releaseData]) => ({
148-
tagName: tagName,
149-
...releaseData
150-
}));
151-
152-
const sortedReleases = releasesWithTags.sort((a, b) => new Date(a.publishedAt) - new Date(b.publishedAt));
153-
const release = sortedReleases.find(r => new Date(r.publishedAt) > closed);
145+
const release = (ReleaseSyncer.sortedReleases || []).find(r => new Date(r.publishedAt) > closed);
154146

155147
// If a subsequent release exists, archive the issue under that release tag.
156148
if (release) {
@@ -283,7 +275,7 @@ class IssueSyncer extends Base {
283275
newMetadata.issues[issueNumber] = {
284276
state : issue.state,
285277
path : targetPath,
286-
updated : issue.updatedAt,
278+
updatedAt: issue.updatedAt,
287279
closedAt : issue.closedAt || null,
288280
milestone: issue.milestone?.title || null,
289281
title : issue.title,
@@ -418,7 +410,7 @@ class IssueSyncer extends Base {
418410
const stats = { count: 0, issues: [] };
419411

420412
// Ensure releases are loaded
421-
if (!ReleaseSyncer.releases || Object.keys(ReleaseSyncer.releases).length === 0) {
413+
if (!ReleaseSyncer.sortedReleases || ReleaseSyncer.sortedReleases.length === 0) {
422414
logger.warn('No releases available for reconciliation, skipping.');
423415
return stats;
424416
}
@@ -440,9 +432,9 @@ class IssueSyncer extends Base {
440432
const correctPath = this.#getIssuePath({
441433
number : parseInt(issueNumber),
442434
state : issueData.state,
443-
labels : [], // Dropped labels are already handled, not relevant here
444435
milestone: issueData.milestone ? { title: issueData.milestone } : null,
445-
closedAt : issueData.closedAt
436+
closedAt : issueData.closedAt,
437+
updatedAt: issueData.updatedAt
446438
});
447439

448440
// If the correct path is null, the issue should be dropped (shouldn't happen here)
@@ -453,8 +445,6 @@ class IssueSyncer extends Base {
453445

454446
// Check if the issue needs to be moved to an archive
455447
if (issueData.path !== correctPath) {
456-
logger.debug(issueNumber, issueData.path, correctPath);
457-
458448
// Verify the correct path is actually in an archive, not back to active directory
459449
if (correctPath.startsWith(issueSyncConfig.issuesDir) &&
460450
!correctPath.includes(issueSyncConfig.archiveDir)) {

ai/mcp/server/github-workflow/services/sync/MetadataManager.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ class MetadataManager extends Base {
6969
prunedMetadata.issues[key] = {
7070
state : value.state,
7171
path : value.path,
72-
updated : value.updated,
72+
closedAt : value.closedAt,
73+
updatedAt : value.updatedAt,
7374
contentHash: value.contentHash
7475
};
7576
}

ai/mcp/server/github-workflow/services/sync/ReleaseSyncer.mjs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@ class ReleaseSyncer extends Base {
3232

3333
/**
3434
* @member {Object} releases=null
35-
* @protected
3635
*/
3736
releases = null;
37+
/**
38+
* @member {Array} sortedReleases=null
39+
*/
40+
sortedReleases = null;
3841

3942
/**
4043
* Calculates a SHA-256 hash of the given content for change detection.
@@ -140,9 +143,15 @@ class ReleaseSyncer extends Base {
140143
.filter(release => new Date(release.publishedAt) >= startDate)
141144
.sort((a, b) => new Date(a.publishedAt) - new Date(b.publishedAt));
142145

143-
this.releases = {};
146+
this.releases = {};
147+
this.sortedReleases = [];
148+
144149
filteredAndSortedReleases.forEach(release => {
145150
this.releases[release.tagName] = release;
151+
this.sortedReleases.push({
152+
tagName : release.tagName,
153+
publishedAt: release.publishedAt
154+
});
146155
});
147156

148157
if (Object.keys(this.releases).length === 0) {

0 commit comments

Comments
 (0)