paperclip-github-plugin 0.5.2 → 0.5.3
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 -1
- package/dist/manifest.js +1 -1
- package/dist/worker.js +234 -28
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -154,7 +154,7 @@ Additional behavior:
|
|
|
154
154
|
- Sync-driven handoffs to agent assignees best-effort enqueue an explicit wakeup so the next reviewer, approver, or executor can pick the issue up even when their agent is not running heartbeats.
|
|
155
155
|
- Open imported issues that are already in `backlog` stay in `backlog` until someone changes them in Paperclip.
|
|
156
156
|
- If an imported issue is `done` or `cancelled` and GitHub shows it open again with no linked pull request, sync moves it to `todo` so agents can pick it up again.
|
|
157
|
-
- Trusted new GitHub comments from the original issue author or a verified maintainer/admin can move an open imported issue back into active work,
|
|
157
|
+
- Trusted new GitHub comments from the original issue author or a verified maintainer/admin can move an open imported issue back into active work, whether the new comment lands on the source issue, in a linked pull request's top-level comment stream, or in a linked pull request review thread; GitHub Sync uses `in_progress` when it can route the issue to an executor and otherwise `todo`.
|
|
158
158
|
- When the sync changes a Paperclip issue status, it adds a Paperclip comment explaining what changed and why.
|
|
159
159
|
|
|
160
160
|
## Security and authentication
|
package/dist/manifest.js
CHANGED
|
@@ -511,7 +511,7 @@ var require2 = createRequire(import.meta.url);
|
|
|
511
511
|
var packageJson = require2("../package.json");
|
|
512
512
|
var DASHBOARD_WIDGET_CAPABILITY = "ui.dashboardWidget.register";
|
|
513
513
|
var SCHEDULE_TICK_CRON = "* * * * *";
|
|
514
|
-
var MANIFEST_VERSION = "0.5.
|
|
514
|
+
var MANIFEST_VERSION = "0.5.3"?.trim() || typeof packageJson.version === "string" && packageJson.version.trim() || process.env.npm_package_version?.trim() || "0.0.0-dev";
|
|
515
515
|
var manifest = {
|
|
516
516
|
id: "paperclip-github-plugin",
|
|
517
517
|
apiVersion: 1,
|
package/dist/worker.js
CHANGED
|
@@ -3722,6 +3722,9 @@ function normalizeImportRegistry(value) {
|
|
|
3722
3722
|
const paperclipProjectId = typeof record.paperclipProjectId === "string" && record.paperclipProjectId.trim() ? record.paperclipProjectId.trim() : void 0;
|
|
3723
3723
|
const companyId = typeof record.companyId === "string" && record.companyId.trim() ? record.companyId.trim() : void 0;
|
|
3724
3724
|
const lastSeenCommentCount = typeof record.lastSeenCommentCount === "number" && record.lastSeenCommentCount >= 0 ? Math.floor(record.lastSeenCommentCount) : void 0;
|
|
3725
|
+
const linkedPullRequestCommentCounts = normalizeGitHubPullRequestCommentCountRecords(
|
|
3726
|
+
record.linkedPullRequestCommentCounts
|
|
3727
|
+
);
|
|
3725
3728
|
if (!mappingId || Number.isNaN(githubIssueId) || !paperclipIssueId || !importedAt) {
|
|
3726
3729
|
return null;
|
|
3727
3730
|
}
|
|
@@ -3734,7 +3737,8 @@ function normalizeImportRegistry(value) {
|
|
|
3734
3737
|
...repositoryUrl ? { repositoryUrl } : {},
|
|
3735
3738
|
...paperclipProjectId ? { paperclipProjectId } : {},
|
|
3736
3739
|
...companyId ? { companyId } : {},
|
|
3737
|
-
...lastSeenCommentCount !== void 0 ? { lastSeenCommentCount } : {}
|
|
3740
|
+
...lastSeenCommentCount !== void 0 ? { lastSeenCommentCount } : {},
|
|
3741
|
+
...linkedPullRequestCommentCounts.length > 0 ? { linkedPullRequestCommentCounts } : {}
|
|
3738
3742
|
};
|
|
3739
3743
|
}).filter((entry) => entry !== null);
|
|
3740
3744
|
}
|
|
@@ -3780,6 +3784,7 @@ function buildImportedIssueRecord(mapping, issue, paperclipIssueId, importedAt)
|
|
|
3780
3784
|
paperclipIssueId,
|
|
3781
3785
|
importedAt,
|
|
3782
3786
|
lastSeenCommentCount: issue.commentsCount,
|
|
3787
|
+
linkedPullRequestCommentCounts: [],
|
|
3783
3788
|
repositoryUrl: getNormalizedMappingRepositoryUrl(mapping),
|
|
3784
3789
|
paperclipProjectId: mapping.paperclipProjectId,
|
|
3785
3790
|
companyId: mapping.companyId
|
|
@@ -4612,7 +4617,7 @@ function buildSyncFallbackExecutionStatePatch(params) {
|
|
|
4612
4617
|
return void 0;
|
|
4613
4618
|
}
|
|
4614
4619
|
function describeGitHubStatusTransitionReason(params) {
|
|
4615
|
-
const { snapshot,
|
|
4620
|
+
const { snapshot, hasTrustedNewComment, maintainerAuthoredImportedIssue } = params;
|
|
4616
4621
|
if (snapshot.state === "closed") {
|
|
4617
4622
|
switch (snapshot.stateReason) {
|
|
4618
4623
|
case "duplicate":
|
|
@@ -4623,8 +4628,7 @@ function describeGitHubStatusTransitionReason(params) {
|
|
|
4623
4628
|
return "the GitHub issue was closed as completed work";
|
|
4624
4629
|
}
|
|
4625
4630
|
}
|
|
4626
|
-
|
|
4627
|
-
if (snapshot.commentCount > baselineCommentCount && hasTrustedNewComment) {
|
|
4631
|
+
if (hasTrustedNewComment) {
|
|
4628
4632
|
return "a new GitHub comment from the issue author or a repository maintainer was added";
|
|
4629
4633
|
}
|
|
4630
4634
|
if (snapshot.linkedPullRequests.length === 0) {
|
|
@@ -4675,13 +4679,11 @@ function buildPaperclipIssueStatusTransitionComment(params) {
|
|
|
4675
4679
|
nextStatus,
|
|
4676
4680
|
repository,
|
|
4677
4681
|
snapshot,
|
|
4678
|
-
previousCommentCount,
|
|
4679
4682
|
hasTrustedNewComment,
|
|
4680
4683
|
maintainerAuthoredImportedIssue
|
|
4681
4684
|
} = params;
|
|
4682
4685
|
const reason = describeGitHubStatusTransitionReason({
|
|
4683
4686
|
snapshot,
|
|
4684
|
-
previousCommentCount,
|
|
4685
4687
|
hasTrustedNewComment,
|
|
4686
4688
|
maintainerAuthoredImportedIssue
|
|
4687
4689
|
});
|
|
@@ -4700,7 +4702,6 @@ function resolvePaperclipIssueStatus(params) {
|
|
|
4700
4702
|
const {
|
|
4701
4703
|
currentStatus,
|
|
4702
4704
|
snapshot,
|
|
4703
|
-
previousCommentCount,
|
|
4704
4705
|
hasTrustedNewComment,
|
|
4705
4706
|
wasImportedThisRun,
|
|
4706
4707
|
defaultImportedStatus,
|
|
@@ -4713,8 +4714,7 @@ function resolvePaperclipIssueStatus(params) {
|
|
|
4713
4714
|
if (currentStatus === "backlog" && !wasImportedThisRun) {
|
|
4714
4715
|
return "backlog";
|
|
4715
4716
|
}
|
|
4716
|
-
|
|
4717
|
-
if (snapshot.commentCount > baselineCommentCount && hasTrustedNewComment) {
|
|
4717
|
+
if (hasTrustedNewComment) {
|
|
4718
4718
|
return hasExecutorHandoffTarget ? "in_progress" : "todo";
|
|
4719
4719
|
}
|
|
4720
4720
|
if (snapshot.linkedPullRequests.length > 0) {
|
|
@@ -5214,25 +5214,58 @@ async function listNewGitHubIssueCommentsSinceCount(octokit, repository, issueNu
|
|
|
5214
5214
|
}
|
|
5215
5215
|
return comments;
|
|
5216
5216
|
}
|
|
5217
|
-
async function
|
|
5218
|
-
const normalizedPreviousCommentCount =
|
|
5219
|
-
const normalizedCurrentCommentCount = Math.max(0, Math.floor(
|
|
5217
|
+
async function listNewGitHubPullRequestReviewCommentsSinceCount(octokit, repository, pullRequestNumber, previousCommentCount, currentCommentCount) {
|
|
5218
|
+
const normalizedPreviousCommentCount = Math.max(0, Math.floor(previousCommentCount));
|
|
5219
|
+
const normalizedCurrentCommentCount = Math.max(0, Math.floor(currentCommentCount));
|
|
5220
5220
|
if (normalizedCurrentCommentCount <= normalizedPreviousCommentCount) {
|
|
5221
|
-
return
|
|
5221
|
+
return [];
|
|
5222
5222
|
}
|
|
5223
|
-
const
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5223
|
+
const newCommentCount = normalizedCurrentCommentCount - normalizedPreviousCommentCount;
|
|
5224
|
+
const comments = [];
|
|
5225
|
+
const perPage = 100;
|
|
5226
|
+
let page = Math.floor(normalizedPreviousCommentCount / perPage) + 1;
|
|
5227
|
+
let remainingOffset = normalizedPreviousCommentCount % perPage;
|
|
5228
|
+
while (comments.length < newCommentCount) {
|
|
5229
|
+
const response = await octokit.rest.pulls.listReviewComments({
|
|
5230
|
+
owner: repository.owner,
|
|
5231
|
+
repo: repository.repo,
|
|
5232
|
+
pull_number: pullRequestNumber,
|
|
5233
|
+
page,
|
|
5234
|
+
per_page: perPage,
|
|
5235
|
+
headers: {
|
|
5236
|
+
accept: "application/vnd.github+json",
|
|
5237
|
+
"X-GitHub-Api-Version": GITHUB_API_VERSION
|
|
5238
|
+
}
|
|
5239
|
+
});
|
|
5240
|
+
if (response.data.length === 0) {
|
|
5241
|
+
break;
|
|
5242
|
+
}
|
|
5243
|
+
for (const comment of response.data.slice(remainingOffset)) {
|
|
5244
|
+
comments.push({
|
|
5245
|
+
id: comment.id,
|
|
5246
|
+
body: typeof comment.body === "string" ? stripNullBytes(comment.body) : "",
|
|
5247
|
+
url: comment.html_url ?? void 0,
|
|
5248
|
+
authorLogin: normalizeGitHubUserLogin(comment.user?.login),
|
|
5249
|
+
...normalizeGitHubLowercaseString(comment.author_association) ? { authorAssociation: normalizeGitHubLowercaseString(comment.author_association) } : {},
|
|
5250
|
+
createdAt: comment.created_at ?? void 0,
|
|
5251
|
+
updatedAt: comment.updated_at ?? void 0
|
|
5252
|
+
});
|
|
5253
|
+
if (comments.length >= newCommentCount) {
|
|
5254
|
+
break;
|
|
5255
|
+
}
|
|
5256
|
+
}
|
|
5257
|
+
if (response.data.length < perPage) {
|
|
5258
|
+
break;
|
|
5259
|
+
}
|
|
5260
|
+
page += 1;
|
|
5261
|
+
remainingOffset = 0;
|
|
5232
5262
|
}
|
|
5233
|
-
|
|
5263
|
+
return comments;
|
|
5264
|
+
}
|
|
5265
|
+
async function hasTrustedGitHubCommentRecords(params) {
|
|
5266
|
+
const originalPosterLogin = normalizeGitHubUserLogin(params.originalPosterLogin);
|
|
5234
5267
|
const unseenAuthors = /* @__PURE__ */ new Set();
|
|
5235
|
-
for (const comment of
|
|
5268
|
+
for (const comment of params.comments) {
|
|
5236
5269
|
const authorLogin = normalizeGitHubUserLogin(comment.authorLogin);
|
|
5237
5270
|
if (!authorLogin) {
|
|
5238
5271
|
continue;
|
|
@@ -5266,6 +5299,122 @@ async function hasTrustedNewGitHubIssueComment(params) {
|
|
|
5266
5299
|
}
|
|
5267
5300
|
return false;
|
|
5268
5301
|
}
|
|
5302
|
+
async function hasTrustedNewGitHubIssueComment(params) {
|
|
5303
|
+
const normalizedPreviousCommentCount = typeof params.previousCommentCount === "number" && params.previousCommentCount >= 0 ? Math.floor(params.previousCommentCount) : params.currentCommentCount;
|
|
5304
|
+
const normalizedCurrentCommentCount = Math.max(0, Math.floor(params.currentCommentCount));
|
|
5305
|
+
if (normalizedCurrentCommentCount <= normalizedPreviousCommentCount) {
|
|
5306
|
+
return false;
|
|
5307
|
+
}
|
|
5308
|
+
const newComments = await listNewGitHubIssueCommentsSinceCount(
|
|
5309
|
+
params.octokit,
|
|
5310
|
+
params.repository,
|
|
5311
|
+
params.githubIssue.number,
|
|
5312
|
+
normalizedPreviousCommentCount,
|
|
5313
|
+
normalizedCurrentCommentCount
|
|
5314
|
+
);
|
|
5315
|
+
if (newComments.length === 0) {
|
|
5316
|
+
return false;
|
|
5317
|
+
}
|
|
5318
|
+
return hasTrustedGitHubCommentRecords({
|
|
5319
|
+
octokit: params.octokit,
|
|
5320
|
+
repository: params.repository,
|
|
5321
|
+
comments: newComments,
|
|
5322
|
+
originalPosterLogin: params.githubIssue.authorLogin,
|
|
5323
|
+
maintainerCache: params.maintainerCache
|
|
5324
|
+
});
|
|
5325
|
+
}
|
|
5326
|
+
async function getGitHubPullRequestCommentCountRecord(octokit, repository, pullRequestNumber, cache) {
|
|
5327
|
+
const pullRequestReference = {
|
|
5328
|
+
number: pullRequestNumber,
|
|
5329
|
+
repositoryUrl: repository.url
|
|
5330
|
+
};
|
|
5331
|
+
const cacheKey = buildGitHubPullRequestReferenceKey(pullRequestReference);
|
|
5332
|
+
const cachedRecord = cache.get(cacheKey);
|
|
5333
|
+
if (cachedRecord) {
|
|
5334
|
+
return cachedRecord;
|
|
5335
|
+
}
|
|
5336
|
+
const response = await octokit.rest.pulls.get({
|
|
5337
|
+
owner: repository.owner,
|
|
5338
|
+
repo: repository.repo,
|
|
5339
|
+
pull_number: pullRequestNumber,
|
|
5340
|
+
headers: {
|
|
5341
|
+
"X-GitHub-Api-Version": GITHUB_API_VERSION
|
|
5342
|
+
}
|
|
5343
|
+
});
|
|
5344
|
+
const record = {
|
|
5345
|
+
...pullRequestReference,
|
|
5346
|
+
topLevelCommentCount: typeof response.data.comments === "number" && response.data.comments >= 0 ? Math.floor(response.data.comments) : 0,
|
|
5347
|
+
reviewCommentCount: typeof response.data.review_comments === "number" && response.data.review_comments >= 0 ? Math.floor(response.data.review_comments) : 0
|
|
5348
|
+
};
|
|
5349
|
+
cache.set(cacheKey, record);
|
|
5350
|
+
return record;
|
|
5351
|
+
}
|
|
5352
|
+
async function listGitHubPullRequestCommentCountRecords(octokit, linkedPullRequests, cache) {
|
|
5353
|
+
const commentCounts = [];
|
|
5354
|
+
for (const pullRequest of linkedPullRequests) {
|
|
5355
|
+
commentCounts.push(
|
|
5356
|
+
await getGitHubPullRequestCommentCountRecord(
|
|
5357
|
+
octokit,
|
|
5358
|
+
requireRepositoryReference(pullRequest.repositoryUrl),
|
|
5359
|
+
pullRequest.number,
|
|
5360
|
+
cache
|
|
5361
|
+
)
|
|
5362
|
+
);
|
|
5363
|
+
}
|
|
5364
|
+
return normalizeGitHubPullRequestCommentCountRecords(commentCounts);
|
|
5365
|
+
}
|
|
5366
|
+
async function hasTrustedNewLinkedPullRequestComments(params) {
|
|
5367
|
+
if ((params.currentCommentCounts?.length ?? 0) === 0 || (params.previousCommentCounts?.length ?? 0) === 0) {
|
|
5368
|
+
return false;
|
|
5369
|
+
}
|
|
5370
|
+
const previousCommentCountsByKey = new Map(
|
|
5371
|
+
(params.previousCommentCounts ?? []).map((record) => [buildGitHubPullRequestReferenceKey(record), record])
|
|
5372
|
+
);
|
|
5373
|
+
for (const currentCommentCount of params.currentCommentCounts) {
|
|
5374
|
+
const previousCommentCount = previousCommentCountsByKey.get(buildGitHubPullRequestReferenceKey(currentCommentCount));
|
|
5375
|
+
if (!previousCommentCount) {
|
|
5376
|
+
continue;
|
|
5377
|
+
}
|
|
5378
|
+
const pullRequestRepository = requireRepositoryReference(currentCommentCount.repositoryUrl);
|
|
5379
|
+
if (currentCommentCount.topLevelCommentCount > previousCommentCount.topLevelCommentCount) {
|
|
5380
|
+
const newTopLevelComments = await listNewGitHubIssueCommentsSinceCount(
|
|
5381
|
+
params.octokit,
|
|
5382
|
+
pullRequestRepository,
|
|
5383
|
+
currentCommentCount.number,
|
|
5384
|
+
previousCommentCount.topLevelCommentCount,
|
|
5385
|
+
currentCommentCount.topLevelCommentCount
|
|
5386
|
+
);
|
|
5387
|
+
if (await hasTrustedGitHubCommentRecords({
|
|
5388
|
+
octokit: params.octokit,
|
|
5389
|
+
repository: pullRequestRepository,
|
|
5390
|
+
comments: newTopLevelComments,
|
|
5391
|
+
originalPosterLogin: params.githubIssue.authorLogin,
|
|
5392
|
+
maintainerCache: params.maintainerCache
|
|
5393
|
+
})) {
|
|
5394
|
+
return true;
|
|
5395
|
+
}
|
|
5396
|
+
}
|
|
5397
|
+
if (currentCommentCount.reviewCommentCount > previousCommentCount.reviewCommentCount) {
|
|
5398
|
+
const newReviewComments = await listNewGitHubPullRequestReviewCommentsSinceCount(
|
|
5399
|
+
params.octokit,
|
|
5400
|
+
pullRequestRepository,
|
|
5401
|
+
currentCommentCount.number,
|
|
5402
|
+
previousCommentCount.reviewCommentCount,
|
|
5403
|
+
currentCommentCount.reviewCommentCount
|
|
5404
|
+
);
|
|
5405
|
+
if (await hasTrustedGitHubCommentRecords({
|
|
5406
|
+
octokit: params.octokit,
|
|
5407
|
+
repository: pullRequestRepository,
|
|
5408
|
+
comments: newReviewComments,
|
|
5409
|
+
originalPosterLogin: params.githubIssue.authorLogin,
|
|
5410
|
+
maintainerCache: params.maintainerCache
|
|
5411
|
+
})) {
|
|
5412
|
+
return true;
|
|
5413
|
+
}
|
|
5414
|
+
}
|
|
5415
|
+
}
|
|
5416
|
+
return false;
|
|
5417
|
+
}
|
|
5269
5418
|
async function isMaintainerAuthoredGitHubIssue(params) {
|
|
5270
5419
|
const authorLogin = normalizeGitHubUserLogin(params.githubIssue.authorLogin);
|
|
5271
5420
|
if (!authorLogin) {
|
|
@@ -5375,6 +5524,41 @@ function normalizeLinkedPullRequestNumbers(values) {
|
|
|
5375
5524
|
function buildGitHubPullRequestReferenceKey(pullRequest) {
|
|
5376
5525
|
return `${getNormalizedMappingRepositoryUrl({ repositoryUrl: pullRequest.repositoryUrl }).toLowerCase()}#${Math.max(1, Math.floor(pullRequest.number))}`;
|
|
5377
5526
|
}
|
|
5527
|
+
function normalizeGitHubPullRequestCommentCountRecords(value) {
|
|
5528
|
+
if (!Array.isArray(value)) {
|
|
5529
|
+
return [];
|
|
5530
|
+
}
|
|
5531
|
+
const recordsByKey = /* @__PURE__ */ new Map();
|
|
5532
|
+
for (const entry of value) {
|
|
5533
|
+
if (!entry || typeof entry !== "object") {
|
|
5534
|
+
continue;
|
|
5535
|
+
}
|
|
5536
|
+
const record = entry;
|
|
5537
|
+
const pullRequestNumber = typeof record.number === "number" && Number.isInteger(record.number) && record.number > 0 ? Math.floor(record.number) : void 0;
|
|
5538
|
+
const repositoryUrl = typeof record.repositoryUrl === "string" && record.repositoryUrl.trim() ? getNormalizedMappingRepositoryUrl({
|
|
5539
|
+
repositoryUrl: record.repositoryUrl
|
|
5540
|
+
}) : void 0;
|
|
5541
|
+
const topLevelCommentCount = typeof record.topLevelCommentCount === "number" && record.topLevelCommentCount >= 0 ? Math.floor(record.topLevelCommentCount) : void 0;
|
|
5542
|
+
const reviewCommentCount = typeof record.reviewCommentCount === "number" && record.reviewCommentCount >= 0 ? Math.floor(record.reviewCommentCount) : void 0;
|
|
5543
|
+
if (pullRequestNumber === void 0 || !repositoryUrl || topLevelCommentCount === void 0 || reviewCommentCount === void 0) {
|
|
5544
|
+
continue;
|
|
5545
|
+
}
|
|
5546
|
+
const normalizedRecord = {
|
|
5547
|
+
number: pullRequestNumber,
|
|
5548
|
+
repositoryUrl,
|
|
5549
|
+
topLevelCommentCount,
|
|
5550
|
+
reviewCommentCount
|
|
5551
|
+
};
|
|
5552
|
+
recordsByKey.set(buildGitHubPullRequestReferenceKey(normalizedRecord), normalizedRecord);
|
|
5553
|
+
}
|
|
5554
|
+
return [...recordsByKey.values()].sort((left, right) => {
|
|
5555
|
+
const repositoryComparison = left.repositoryUrl.toLowerCase().localeCompare(right.repositoryUrl.toLowerCase());
|
|
5556
|
+
if (repositoryComparison !== 0) {
|
|
5557
|
+
return repositoryComparison;
|
|
5558
|
+
}
|
|
5559
|
+
return left.number - right.number;
|
|
5560
|
+
});
|
|
5561
|
+
}
|
|
5378
5562
|
function normalizeLinkedPullRequestReferences(values, fallbackRepositoryUrl) {
|
|
5379
5563
|
const references = [];
|
|
5380
5564
|
const seenKeys = /* @__PURE__ */ new Set();
|
|
@@ -7172,6 +7356,7 @@ async function synchronizePaperclipIssueStatuses(ctx, octokit, repository, mappi
|
|
|
7172
7356
|
let completedIssueCount = 0;
|
|
7173
7357
|
const totalIssueCount = importedIssues.length;
|
|
7174
7358
|
const queuedIssueWakeups = [];
|
|
7359
|
+
const pullRequestCommentCountCache = /* @__PURE__ */ new Map();
|
|
7175
7360
|
for (const importedIssue of importedIssues) {
|
|
7176
7361
|
if (assertNotCancelled) {
|
|
7177
7362
|
await assertNotCancelled();
|
|
@@ -7278,8 +7463,8 @@ async function synchronizePaperclipIssueStatuses(ctx, octokit, repository, mappi
|
|
|
7278
7463
|
snapshot.linkedPullRequests
|
|
7279
7464
|
);
|
|
7280
7465
|
const previousCommentCount = importedIssue.lastSeenCommentCount;
|
|
7281
|
-
const
|
|
7282
|
-
const
|
|
7466
|
+
const hasNewIssueComments = snapshot.commentCount > (previousCommentCount ?? snapshot.commentCount);
|
|
7467
|
+
const hasTrustedNewIssueComment = paperclipIssue.status === "backlog" || !hasNewIssueComments ? false : await hasTrustedNewGitHubIssueComment({
|
|
7283
7468
|
octokit,
|
|
7284
7469
|
repository,
|
|
7285
7470
|
githubIssue,
|
|
@@ -7287,6 +7472,28 @@ async function synchronizePaperclipIssueStatuses(ctx, octokit, repository, mappi
|
|
|
7287
7472
|
currentCommentCount: snapshot.commentCount,
|
|
7288
7473
|
maintainerCache: repositoryMaintainerCache
|
|
7289
7474
|
});
|
|
7475
|
+
let currentLinkedPullRequestCommentCounts = snapshot.linkedPullRequests.length === 0 ? [] : importedIssue.linkedPullRequestCommentCounts ?? [];
|
|
7476
|
+
if (snapshot.linkedPullRequests.length > 0) {
|
|
7477
|
+
try {
|
|
7478
|
+
currentLinkedPullRequestCommentCounts = await listGitHubPullRequestCommentCountRecords(
|
|
7479
|
+
octokit,
|
|
7480
|
+
snapshot.linkedPullRequests,
|
|
7481
|
+
pullRequestCommentCountCache
|
|
7482
|
+
);
|
|
7483
|
+
} catch (error) {
|
|
7484
|
+
if (isGitHubRateLimitError(error)) {
|
|
7485
|
+
throw error;
|
|
7486
|
+
}
|
|
7487
|
+
}
|
|
7488
|
+
}
|
|
7489
|
+
const hasTrustedNewLinkedPullRequestComment = paperclipIssue.status === "backlog" || currentLinkedPullRequestCommentCounts.length === 0 ? false : await hasTrustedNewLinkedPullRequestComments({
|
|
7490
|
+
octokit,
|
|
7491
|
+
githubIssue,
|
|
7492
|
+
previousCommentCounts: importedIssue.linkedPullRequestCommentCounts,
|
|
7493
|
+
currentCommentCounts: currentLinkedPullRequestCommentCounts,
|
|
7494
|
+
maintainerCache: repositoryMaintainerCache
|
|
7495
|
+
});
|
|
7496
|
+
const hasTrustedNewComment = hasTrustedNewIssueComment || hasTrustedNewLinkedPullRequestComment;
|
|
7290
7497
|
const wasImportedThisRun = createdIssueIds.has(importedIssue.githubIssueId);
|
|
7291
7498
|
const maintainerAuthoredImportedIssue = wasImportedThisRun && advancedSettings.defaultStatus !== "todo" && snapshot.state === "open" && snapshot.linkedPullRequests.length === 0 ? await isMaintainerAuthoredGitHubIssue({
|
|
7292
7499
|
octokit,
|
|
@@ -7302,7 +7509,6 @@ async function synchronizePaperclipIssueStatuses(ctx, octokit, repository, mappi
|
|
|
7302
7509
|
const nextStatus = resolvePaperclipIssueStatus({
|
|
7303
7510
|
currentStatus: paperclipIssue.status,
|
|
7304
7511
|
snapshot,
|
|
7305
|
-
previousCommentCount,
|
|
7306
7512
|
hasTrustedNewComment,
|
|
7307
7513
|
wasImportedThisRun,
|
|
7308
7514
|
defaultImportedStatus: advancedSettings.defaultStatus,
|
|
@@ -7320,6 +7526,7 @@ async function synchronizePaperclipIssueStatuses(ctx, octokit, repository, mappi
|
|
|
7320
7526
|
const shouldWakeTransitionAssignee = paperclipIssue.status !== nextStatus && nextTransitionAssignee?.principal.kind === "agent" && isActionablePaperclipIssueStatus(nextStatus) && (nextAssigneeChanged || paperclipIssue.status !== nextStatus);
|
|
7321
7527
|
importedIssue.githubIssueNumber = githubIssue.number;
|
|
7322
7528
|
importedIssue.lastSeenCommentCount = snapshot.commentCount;
|
|
7529
|
+
importedIssue.linkedPullRequestCommentCounts = currentLinkedPullRequestCommentCounts;
|
|
7323
7530
|
if (paperclipIssue.status === nextStatus) {
|
|
7324
7531
|
if (shouldClearTransitionAssignee) {
|
|
7325
7532
|
updateSyncFailureContext(syncFailureContext, {
|
|
@@ -7353,7 +7560,6 @@ async function synchronizePaperclipIssueStatuses(ctx, octokit, repository, mappi
|
|
|
7353
7560
|
nextStatus,
|
|
7354
7561
|
repository,
|
|
7355
7562
|
snapshot,
|
|
7356
|
-
previousCommentCount,
|
|
7357
7563
|
hasTrustedNewComment,
|
|
7358
7564
|
maintainerAuthoredImportedIssue
|
|
7359
7565
|
});
|