@sentry/junior-github 0.259.0 → 0.261.0
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.
|
@@ -41,6 +41,9 @@ function gitHubDeploymentSourceSubscribable(input) {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
// src/events/issue.ts
|
|
44
|
+
import {
|
|
45
|
+
eventMatchFieldsSchema
|
|
46
|
+
} from "@sentry/junior-plugin-api";
|
|
44
47
|
var GITHUB_ISSUE_EVENTS = [
|
|
45
48
|
"issue.comment.created",
|
|
46
49
|
"issue.opened",
|
|
@@ -52,6 +55,20 @@ var GITHUB_ISSUE_SUGGESTED_EVENTS = [
|
|
|
52
55
|
"issue.closed",
|
|
53
56
|
"issue.reopened"
|
|
54
57
|
];
|
|
58
|
+
var GITHUB_ISSUE_COMMENT_MATCH_FIELDS = eventMatchFieldsSchema.parse({
|
|
59
|
+
mentionsBot: {
|
|
60
|
+
kind: "boolean",
|
|
61
|
+
description: "true when the issue comment mentions the Junior GitHub App"
|
|
62
|
+
},
|
|
63
|
+
senderId: {
|
|
64
|
+
kind: "number",
|
|
65
|
+
description: "immutable numeric GitHub user id of the issue commenter; prefer over logins"
|
|
66
|
+
},
|
|
67
|
+
senderLogin: {
|
|
68
|
+
kind: "string",
|
|
69
|
+
description: "GitHub login of the issue commenter; logins can be renamed"
|
|
70
|
+
}
|
|
71
|
+
});
|
|
55
72
|
var GITHUB_ISSUE_IDENTIFIER = {
|
|
56
73
|
format: "owner/repo#number",
|
|
57
74
|
pattern: /^[^\s/:#]+\/[^\s/:#]+#\d+$/
|
|
@@ -75,7 +92,7 @@ function gitHubIssueSubscribable(input) {
|
|
|
75
92
|
|
|
76
93
|
// src/events/pull-request.ts
|
|
77
94
|
import {
|
|
78
|
-
eventMatchFieldsSchema
|
|
95
|
+
eventMatchFieldsSchema as eventMatchFieldsSchema2
|
|
79
96
|
} from "@sentry/junior-plugin-api";
|
|
80
97
|
var GITHUB_PULL_REQUEST_EVENTS = [
|
|
81
98
|
"pull_request.checks.failed",
|
|
@@ -128,7 +145,7 @@ var GITHUB_PULL_REQUEST_SUGGESTED_EVENTS = [
|
|
|
128
145
|
"pull_request.merged",
|
|
129
146
|
"pull_request.closed_unmerged"
|
|
130
147
|
];
|
|
131
|
-
var GITHUB_PULL_REQUEST_MATCH_FIELDS =
|
|
148
|
+
var GITHUB_PULL_REQUEST_MATCH_FIELDS = eventMatchFieldsSchema2.parse({
|
|
132
149
|
authorEmail: {
|
|
133
150
|
kind: "string",
|
|
134
151
|
description: "pull request author email when GitHub sends it"
|
|
@@ -1307,6 +1324,7 @@ async function loadCheckSuiteFacts(args) {
|
|
|
1307
1324
|
}
|
|
1308
1325
|
|
|
1309
1326
|
// src/webhooks/ownership.ts
|
|
1327
|
+
import { lexer } from "marked";
|
|
1310
1328
|
var GITHUB_BOT_NOREPLY_EMAIL = /^(?<userId>[1-9]\d*)\+(?<login>[^@]+\[bot\])@users\.noreply\.github\.com$/i;
|
|
1311
1329
|
function parseGitHubBotIdentity(value) {
|
|
1312
1330
|
const match = GITHUB_BOT_NOREPLY_EMAIL.exec(value?.trim() ?? "");
|
|
@@ -1328,6 +1346,32 @@ function isBotLogin(login, botEmail) {
|
|
|
1328
1346
|
function botUserIdFromEmail(value) {
|
|
1329
1347
|
return parseGitHubBotIdentity(value)?.userId;
|
|
1330
1348
|
}
|
|
1349
|
+
var SKIPPED_TOKEN_TYPES = /* @__PURE__ */ new Set(["blockquote", "code", "codespan", "html"]);
|
|
1350
|
+
function ownTokenText(tokens, separator = "") {
|
|
1351
|
+
return tokens.map((token) => {
|
|
1352
|
+
if (SKIPPED_TOKEN_TYPES.has(token.type)) return " ";
|
|
1353
|
+
if (token.type === "list") {
|
|
1354
|
+
return token.items.map((item) => ownTokenText(item.tokens, "\n")).join("\n");
|
|
1355
|
+
}
|
|
1356
|
+
if (token.type === "table") {
|
|
1357
|
+
const table = token;
|
|
1358
|
+
return [table.header, ...table.rows].flat().map((cell) => ownTokenText(cell.tokens)).join(" ");
|
|
1359
|
+
}
|
|
1360
|
+
if ("tokens" in token && token.tokens) return ownTokenText(token.tokens);
|
|
1361
|
+
return "text" in token ? token.text : token.raw;
|
|
1362
|
+
}).join(separator);
|
|
1363
|
+
}
|
|
1364
|
+
function ownCommentText(text) {
|
|
1365
|
+
return ownTokenText(lexer(text, { gfm: true }), "\n");
|
|
1366
|
+
}
|
|
1367
|
+
function mentionsBotLogin(text, botEmail) {
|
|
1368
|
+
const slug = botLoginFromEmail(botEmail)?.replace(/\[bot\]$/i, "");
|
|
1369
|
+
if (!slug) return false;
|
|
1370
|
+
const escaped = slug.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1371
|
+
return new RegExp(`(?:^|[^\\w-])@${escaped}(?![\\w-])`, "i").test(
|
|
1372
|
+
ownCommentText(text)
|
|
1373
|
+
);
|
|
1374
|
+
}
|
|
1331
1375
|
|
|
1332
1376
|
// src/webhooks/events.ts
|
|
1333
1377
|
function gitHubEventKey2(deliveryId, eventType) {
|
|
@@ -1348,6 +1392,10 @@ function pullRequestAuthorData(user) {
|
|
|
1348
1392
|
if (email) data.authorEmail = email;
|
|
1349
1393
|
return data;
|
|
1350
1394
|
}
|
|
1395
|
+
function gitHubDoneBy(login) {
|
|
1396
|
+
const handle = login?.trim();
|
|
1397
|
+
return handle ? { doneBy: { provider: "github", handle } } : void 0;
|
|
1398
|
+
}
|
|
1351
1399
|
function pullRequestMatchData(parts) {
|
|
1352
1400
|
const data = {};
|
|
1353
1401
|
for (const part of parts) {
|
|
@@ -1506,7 +1554,8 @@ var issueCommentWebhookSchema = z2.object({
|
|
|
1506
1554
|
login: z2.string().optional().nullable()
|
|
1507
1555
|
}).optional().nullable()
|
|
1508
1556
|
}),
|
|
1509
|
-
repository: repositorySchema2
|
|
1557
|
+
repository: repositorySchema2,
|
|
1558
|
+
sender: z2.object({ id: z2.number(), login: z2.string().min(1) }).optional()
|
|
1510
1559
|
});
|
|
1511
1560
|
function normalizeIssueCommentEvents(deliveryId, body, botEmail) {
|
|
1512
1561
|
const parsed = issueCommentWebhookSchema.safeParse(body);
|
|
@@ -1520,7 +1569,7 @@ function normalizeIssueCommentEvents(deliveryId, body, botEmail) {
|
|
|
1520
1569
|
if (parsed.data.issue.pull_request) {
|
|
1521
1570
|
const eventType = "pull_request.comment.created";
|
|
1522
1571
|
const resource = gitHubPullRequestResource(input);
|
|
1523
|
-
const
|
|
1572
|
+
const data2 = pullRequestMatchData([
|
|
1524
1573
|
pullRequestDraftData(parsed.data.issue.draft),
|
|
1525
1574
|
pullRequestAuthorData(parsed.data.issue.user),
|
|
1526
1575
|
{
|
|
@@ -1537,7 +1586,8 @@ function normalizeIssueCommentEvents(deliveryId, body, botEmail) {
|
|
|
1537
1586
|
occurredAtMs: Date.now(),
|
|
1538
1587
|
identifier: resource.identifier,
|
|
1539
1588
|
trustedSummary: `${resource.label} received a comment${author ? ` from ${author}` : ""}.`,
|
|
1540
|
-
...
|
|
1589
|
+
...gitHubDoneBy(author),
|
|
1590
|
+
...data2 ? { data: data2 } : void 0,
|
|
1541
1591
|
untrustedText: parsed.data.comment.body
|
|
1542
1592
|
},
|
|
1543
1593
|
input.repo
|
|
@@ -1545,24 +1595,29 @@ function normalizeIssueCommentEvents(deliveryId, body, botEmail) {
|
|
|
1545
1595
|
}
|
|
1546
1596
|
const issue = gitHubIssueResource(input);
|
|
1547
1597
|
const repository = gitHubRepositoryResource(input);
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1598
|
+
const sender = parsed.data.sender;
|
|
1599
|
+
const data = {
|
|
1600
|
+
repo: input.repo,
|
|
1601
|
+
issue: input.number,
|
|
1602
|
+
commentId: parsed.data.comment.id
|
|
1603
|
+
};
|
|
1604
|
+
if (sender) {
|
|
1605
|
+
data.senderId = sender.id;
|
|
1606
|
+
data.senderLogin = sender.login;
|
|
1607
|
+
}
|
|
1608
|
+
if (botEmail) {
|
|
1609
|
+
data.mentionsBot = mentionsBotLogin(parsed.data.comment.body, botEmail);
|
|
1610
|
+
}
|
|
1611
|
+
return [issue, repository].map((resource) => ({
|
|
1612
|
+
eventKey: gitHubEventKey2(deliveryId, "issue.comment.created"),
|
|
1613
|
+
eventType: "issue.comment.created",
|
|
1614
|
+
occurredAtMs: Date.now(),
|
|
1615
|
+
identifier: resource.identifier,
|
|
1616
|
+
trustedSummary: `${issue.label} received a comment${author ? ` from ${author}` : ""}.`,
|
|
1617
|
+
...gitHubDoneBy(author),
|
|
1618
|
+
data,
|
|
1619
|
+
untrustedText: parsed.data.comment.body
|
|
1620
|
+
}));
|
|
1566
1621
|
}
|
|
1567
1622
|
var issueWebhookSchema = z2.object({
|
|
1568
1623
|
action: z2.string(),
|
|
@@ -1666,6 +1721,7 @@ function normalizePullRequestReviewCommentEvent(deliveryId, body, botEmail) {
|
|
|
1666
1721
|
occurredAtMs: Date.now(),
|
|
1667
1722
|
identifier: resource.identifier,
|
|
1668
1723
|
trustedSummary: `${resource.label} received an inline review comment${author ? ` from ${author}` : ""}.`,
|
|
1724
|
+
...gitHubDoneBy(author),
|
|
1669
1725
|
...data ? { data } : void 0,
|
|
1670
1726
|
untrustedText: parsed.data.comment.body
|
|
1671
1727
|
},
|
|
@@ -1716,6 +1772,7 @@ function normalizePullRequestReviewEvent(deliveryId, body, botEmail) {
|
|
|
1716
1772
|
occurredAtMs: Date.now(),
|
|
1717
1773
|
identifier: resource.identifier,
|
|
1718
1774
|
trustedSummary: eventType === "pull_request.review.approved" ? `${resource.label} was approved${reviewer ? ` by ${reviewer}` : ""}.` : eventType === "pull_request.review.changes_requested" ? `${resource.label} received requested changes${reviewer ? ` from ${reviewer}` : ""}.` : `${resource.label} received a review comment${reviewer ? ` from ${reviewer}` : ""}.`,
|
|
1775
|
+
...gitHubDoneBy(reviewer),
|
|
1719
1776
|
...data ? { data } : void 0,
|
|
1720
1777
|
untrustedText: parsed.data.review.body ?? void 0
|
|
1721
1778
|
};
|
|
@@ -1966,6 +2023,7 @@ export {
|
|
|
1966
2023
|
readGrantPermissions,
|
|
1967
2024
|
GITHUB_ISSUE_EVENTS,
|
|
1968
2025
|
GITHUB_ISSUE_SUGGESTED_EVENTS,
|
|
2026
|
+
GITHUB_ISSUE_COMMENT_MATCH_FIELDS,
|
|
1969
2027
|
GITHUB_ISSUE_IDENTIFIER,
|
|
1970
2028
|
gitHubIssueSubscribable,
|
|
1971
2029
|
GITHUB_DEPLOYMENT_EVENTS,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PluginLogger } from "@sentry/junior-plugin-api";
|
|
2
|
+
export interface GitHubReference {
|
|
3
|
+
/** Issue number, pull request number, or commit SHA. */
|
|
4
|
+
id: string;
|
|
5
|
+
/** `issue` also matches pull requests, as GitHub numbers them together. */
|
|
6
|
+
kind: "commit" | "issue" | "pull_request";
|
|
7
|
+
name: string;
|
|
8
|
+
owner: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Describe GitHub issues, pull requests, and commits that message text
|
|
12
|
+
* references, as `owner/repo#123: Title` or `owner/repo@abc1234: Subject`.
|
|
13
|
+
* References that `loadObject` cannot read are left out.
|
|
14
|
+
*/
|
|
15
|
+
export declare function loadGitHubConversationTitleContext(args: {
|
|
16
|
+
config: Record<string, string>;
|
|
17
|
+
loadObject(reference: GitHubReference): Promise<unknown>;
|
|
18
|
+
log: PluginLogger;
|
|
19
|
+
text: string;
|
|
20
|
+
}): Promise<string[]>;
|
package/dist/events/issue.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type SubscribableResource } from "@sentry/junior-plugin-api";
|
|
2
2
|
export declare const GITHUB_ISSUE_EVENTS: string[];
|
|
3
3
|
export declare const GITHUB_ISSUE_SUGGESTED_EVENTS: string[];
|
|
4
|
+
/**
|
|
5
|
+
* Exact values GitHub sets on issue comment event data. Missing keys do not
|
|
6
|
+
* match, so selectors fail closed on other events.
|
|
7
|
+
*/
|
|
8
|
+
export declare const GITHUB_ISSUE_COMMENT_MATCH_FIELDS: Record<string, {
|
|
9
|
+
kind: "boolean" | "number" | "string";
|
|
10
|
+
description: string;
|
|
11
|
+
enum?: string[] | undefined;
|
|
12
|
+
}>;
|
|
4
13
|
/** The identifier shape that `gitHubIssueResource` builds. */
|
|
5
14
|
export declare const GITHUB_ISSUE_IDENTIFIER: {
|
|
6
15
|
format: string;
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
GITHUB_DEPLOYMENT_SUGGESTED_EVENTS,
|
|
10
10
|
GITHUB_GRAPHQL_RESPONSE_BODY_LIMIT_BYTES,
|
|
11
11
|
GITHUB_INSTALLATION_ID_ENV,
|
|
12
|
+
GITHUB_ISSUE_COMMENT_MATCH_FIELDS,
|
|
12
13
|
GITHUB_ISSUE_EVENTS,
|
|
13
14
|
GITHUB_ISSUE_IDENTIFIER,
|
|
14
15
|
GITHUB_ISSUE_SUGGESTED_EVENTS,
|
|
@@ -49,7 +50,7 @@ import {
|
|
|
49
50
|
readGrantPermissions,
|
|
50
51
|
requireEnv,
|
|
51
52
|
resolveUserAccount
|
|
52
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-3PD7XTQH.js";
|
|
53
54
|
|
|
54
55
|
// src/plugin.ts
|
|
55
56
|
import {
|
|
@@ -3596,14 +3597,14 @@ async function withGitHubPullRequestPeople(args) {
|
|
|
3596
3597
|
peopleEvents.map((event) => hasMatch(event))
|
|
3597
3598
|
);
|
|
3598
3599
|
if (!matches.some(Boolean)) return args.events;
|
|
3599
|
-
const { pull_request: pullRequest, repository } = parsed.data;
|
|
3600
|
+
const { pull_request: pullRequest, repository: repository2 } = parsed.data;
|
|
3600
3601
|
const target = {
|
|
3601
3602
|
logins: [
|
|
3602
3603
|
...pullRequest.user ? [pullRequest.user.login] : [],
|
|
3603
3604
|
...(pullRequest.assignees ?? []).map((assignee) => assignee.login)
|
|
3604
3605
|
],
|
|
3605
3606
|
number: pullRequest.number,
|
|
3606
|
-
repositoryFullName:
|
|
3607
|
+
repositoryFullName: repository2.full_name
|
|
3607
3608
|
};
|
|
3608
3609
|
let people;
|
|
3609
3610
|
try {
|
|
@@ -4273,8 +4274,8 @@ function linkifyLine(line) {
|
|
|
4273
4274
|
if (isReferenceBoundary(index2 === 0 ? void 0 : line[index2 - 1])) {
|
|
4274
4275
|
const match = GITHUB_ISSUE_REFERENCE_PATTERN.exec(line.slice(index2));
|
|
4275
4276
|
if (match) {
|
|
4276
|
-
const [reference, owner,
|
|
4277
|
-
output += `[${reference}](https://github.com/${owner}/${
|
|
4277
|
+
const [reference, owner, repository2, number] = match;
|
|
4278
|
+
output += `[${reference}](https://github.com/${owner}/${repository2}/issues/${number})`;
|
|
4278
4279
|
index2 += reference.length;
|
|
4279
4280
|
continue;
|
|
4280
4281
|
}
|
|
@@ -4300,6 +4301,150 @@ function linkifyGitHubReferences(text2) {
|
|
|
4300
4301
|
}).join("\n");
|
|
4301
4302
|
}
|
|
4302
4303
|
|
|
4304
|
+
// src/conversation-title-context.ts
|
|
4305
|
+
var MAX_REFERENCES = 3;
|
|
4306
|
+
var TITLE_MAX_LENGTH = 160;
|
|
4307
|
+
var OWNER = String.raw`([A-Za-z0-9][A-Za-z0-9-]*)`;
|
|
4308
|
+
var REPO = String.raw`([\w.-]*\w)`;
|
|
4309
|
+
var SHA = String.raw`([0-9a-f]{7,40})`;
|
|
4310
|
+
var NOT_AFTER_PATH = String.raw`(?<![\w/.-])`;
|
|
4311
|
+
var REPO_IN_PROSE = String.raw`(?:on|in|from|of|at)\s+${OWNER}\/${REPO}`;
|
|
4312
|
+
var repository = (owner, name) => owner && name ? { owner, name } : void 0;
|
|
4313
|
+
var REFERENCE_PATTERNS = [
|
|
4314
|
+
{
|
|
4315
|
+
pattern: new RegExp(
|
|
4316
|
+
String.raw`https?:\/\/(?:www\.)?github\.com\/${OWNER}\/${REPO}\/(issues|pull)\/(\d+)`,
|
|
4317
|
+
"gi"
|
|
4318
|
+
),
|
|
4319
|
+
read: ([, owner, name, path, id]) => ({
|
|
4320
|
+
id,
|
|
4321
|
+
kind: path.toLowerCase() === "pull" ? "pull_request" : "issue",
|
|
4322
|
+
repository: repository(owner, name)
|
|
4323
|
+
})
|
|
4324
|
+
},
|
|
4325
|
+
{
|
|
4326
|
+
pattern: new RegExp(
|
|
4327
|
+
String.raw`https?:\/\/(?:www\.)?github\.com\/${OWNER}\/${REPO}\/commit\/${SHA}`,
|
|
4328
|
+
"gi"
|
|
4329
|
+
),
|
|
4330
|
+
read: ([, owner, name, id]) => ({
|
|
4331
|
+
id,
|
|
4332
|
+
kind: "commit",
|
|
4333
|
+
repository: repository(owner, name)
|
|
4334
|
+
})
|
|
4335
|
+
},
|
|
4336
|
+
{
|
|
4337
|
+
pattern: new RegExp(
|
|
4338
|
+
String.raw`${NOT_AFTER_PATH}${OWNER}\/${REPO}#(\d+)\b`,
|
|
4339
|
+
"g"
|
|
4340
|
+
),
|
|
4341
|
+
read: ([, owner, name, id]) => ({
|
|
4342
|
+
id,
|
|
4343
|
+
kind: "issue",
|
|
4344
|
+
repository: repository(owner, name)
|
|
4345
|
+
})
|
|
4346
|
+
},
|
|
4347
|
+
{
|
|
4348
|
+
pattern: new RegExp(
|
|
4349
|
+
String.raw`${NOT_AFTER_PATH}${OWNER}\/${REPO}@${SHA}\b`,
|
|
4350
|
+
"g"
|
|
4351
|
+
),
|
|
4352
|
+
read: ([, owner, name, id]) => ({
|
|
4353
|
+
id,
|
|
4354
|
+
kind: "commit",
|
|
4355
|
+
repository: repository(owner, name)
|
|
4356
|
+
})
|
|
4357
|
+
},
|
|
4358
|
+
{
|
|
4359
|
+
pattern: new RegExp(
|
|
4360
|
+
String.raw`\b(issues?|bugs?|tickets?|prs?|pulls?|pull requests?)\s+(?:#|no\.?\s*|number\s+)?(\d+)\b(?:\s+${REPO_IN_PROSE})?`,
|
|
4361
|
+
"gi"
|
|
4362
|
+
),
|
|
4363
|
+
read: ([, noun, id, owner, name]) => ({
|
|
4364
|
+
id,
|
|
4365
|
+
kind: /^(?:prs?|pulls?|pull requests?)$/i.test(noun) ? "pull_request" : "issue",
|
|
4366
|
+
repository: repository(owner, name)
|
|
4367
|
+
})
|
|
4368
|
+
},
|
|
4369
|
+
{
|
|
4370
|
+
pattern: /(?<![\w/&])(?:#|\bGH-)(\d+)\b/gi,
|
|
4371
|
+
read: ([, id]) => ({ id, kind: "issue" })
|
|
4372
|
+
}
|
|
4373
|
+
];
|
|
4374
|
+
function configuredRepository(config) {
|
|
4375
|
+
const [first, second, ...extra] = (config.repo ?? "").trim().split("/");
|
|
4376
|
+
if (extra.length > 0) return void 0;
|
|
4377
|
+
return second ? repository(first, second) : repository(config.org?.trim(), first);
|
|
4378
|
+
}
|
|
4379
|
+
function parseGitHubReferences(text2, config) {
|
|
4380
|
+
const matches = REFERENCE_PATTERNS.flatMap(
|
|
4381
|
+
({ pattern, read }) => [...text2.matchAll(pattern)].map((match) => ({
|
|
4382
|
+
...read(match),
|
|
4383
|
+
end: match.index + match[0].length,
|
|
4384
|
+
start: match.index
|
|
4385
|
+
}))
|
|
4386
|
+
).sort((left, right) => left.start - right.start || right.end - left.end);
|
|
4387
|
+
const accepted = [];
|
|
4388
|
+
for (const match of matches) {
|
|
4389
|
+
const previous = accepted.at(-1);
|
|
4390
|
+
if (!previous || match.start >= previous.end) accepted.push(match);
|
|
4391
|
+
}
|
|
4392
|
+
const namedRepositories = /* @__PURE__ */ new Map();
|
|
4393
|
+
for (const match of accepted) {
|
|
4394
|
+
if (match.repository) {
|
|
4395
|
+
const key = `${match.repository.owner}/${match.repository.name}`;
|
|
4396
|
+
namedRepositories.set(key.toLowerCase(), match.repository);
|
|
4397
|
+
}
|
|
4398
|
+
}
|
|
4399
|
+
for (const match of text2.matchAll(new RegExp(REPO_IN_PROSE, "gi"))) {
|
|
4400
|
+
const named = repository(match[1], match[2]);
|
|
4401
|
+
if (named) {
|
|
4402
|
+
namedRepositories.set(
|
|
4403
|
+
`${named.owner}/${named.name}`.toLowerCase(),
|
|
4404
|
+
named
|
|
4405
|
+
);
|
|
4406
|
+
}
|
|
4407
|
+
}
|
|
4408
|
+
const fallback = namedRepositories.size === 1 ? [...namedRepositories.values()][0] : configuredRepository(config);
|
|
4409
|
+
const references = /* @__PURE__ */ new Map();
|
|
4410
|
+
for (const match of accepted) {
|
|
4411
|
+
const target = match.repository ?? fallback;
|
|
4412
|
+
if (!target) continue;
|
|
4413
|
+
const key = `${target.owner}/${target.name}${match.kind === "commit" ? "@" : "#"}${match.id}`.toLowerCase();
|
|
4414
|
+
if (references.has(key)) continue;
|
|
4415
|
+
references.set(key, { ...target, id: match.id, kind: match.kind });
|
|
4416
|
+
if (references.size >= MAX_REFERENCES) break;
|
|
4417
|
+
}
|
|
4418
|
+
return [...references.values()];
|
|
4419
|
+
}
|
|
4420
|
+
function objectTitle(kind, object) {
|
|
4421
|
+
if (!isRecord(object)) return void 0;
|
|
4422
|
+
const raw = kind === "commit" ? isRecord(object.commit) && typeof object.commit.message === "string" ? object.commit.message.split("\n")[0] : void 0 : typeof object.title === "string" ? object.title : void 0;
|
|
4423
|
+
return raw?.replace(/\s+/g, " ").trim() || void 0;
|
|
4424
|
+
}
|
|
4425
|
+
async function loadGitHubConversationTitleContext(args) {
|
|
4426
|
+
const lines = await Promise.all(
|
|
4427
|
+
parseGitHubReferences(args.text, args.config).map(async (reference) => {
|
|
4428
|
+
try {
|
|
4429
|
+
const title = objectTitle(
|
|
4430
|
+
reference.kind,
|
|
4431
|
+
await args.loadObject(reference)
|
|
4432
|
+
);
|
|
4433
|
+
if (!title) return void 0;
|
|
4434
|
+
const label = reference.kind === "commit" ? `${reference.owner}/${reference.name}@${reference.id.slice(0, 7)}` : `${reference.owner}/${reference.name}#${reference.id}`;
|
|
4435
|
+
return `${label}: ${title.slice(0, TITLE_MAX_LENGTH)}`;
|
|
4436
|
+
} catch (error) {
|
|
4437
|
+
args.log.warn("github.conversation_title_context.load_failed", {
|
|
4438
|
+
"app.github.object_kind": reference.kind,
|
|
4439
|
+
"exception.message": error instanceof Error ? error.message : String(error)
|
|
4440
|
+
});
|
|
4441
|
+
return void 0;
|
|
4442
|
+
}
|
|
4443
|
+
})
|
|
4444
|
+
);
|
|
4445
|
+
return lines.filter((line) => Boolean(line));
|
|
4446
|
+
}
|
|
4447
|
+
|
|
4303
4448
|
// src/workspace-prepare.ts
|
|
4304
4449
|
async function prepareWorkspace(ctx) {
|
|
4305
4450
|
const repos = ctx.repos.map((entry) => {
|
|
@@ -4785,8 +4930,8 @@ function hostGraphqlMutationRepository(operation, method, upstreamUrl, bodyText)
|
|
|
4785
4930
|
) && new RegExp(`\\b${candidate.field}\\b`).test(parsed.normalized)
|
|
4786
4931
|
);
|
|
4787
4932
|
if (!mutation) return void 0;
|
|
4788
|
-
const
|
|
4789
|
-
return /^[^/]+\/[^/]+$/.test(
|
|
4933
|
+
const repository2 = operation.slice(mutation.operationPrefix.length);
|
|
4934
|
+
return /^[^/]+\/[^/]+$/.test(repository2) ? repository2 : void 0;
|
|
4790
4935
|
}
|
|
4791
4936
|
function isGitHubGraphqlMutation(method, upstreamUrl, bodyText, field) {
|
|
4792
4937
|
if (method !== "POST" || !isGitHubGraphqlUrl(upstreamUrl)) return false;
|
|
@@ -4956,7 +5101,8 @@ function githubPlugin(options = {}) {
|
|
|
4956
5101
|
type: "issue",
|
|
4957
5102
|
identifier: GITHUB_ISSUE_IDENTIFIER,
|
|
4958
5103
|
supportedEvents: [...GITHUB_ISSUE_EVENTS],
|
|
4959
|
-
suggestedEvents: [...GITHUB_ISSUE_SUGGESTED_EVENTS]
|
|
5104
|
+
suggestedEvents: [...GITHUB_ISSUE_SUGGESTED_EVENTS],
|
|
5105
|
+
matchFields: GITHUB_ISSUE_COMMENT_MATCH_FIELDS
|
|
4960
5106
|
},
|
|
4961
5107
|
{
|
|
4962
5108
|
type: "pull_request",
|
|
@@ -4987,7 +5133,10 @@ function githubPlugin(options = {}) {
|
|
|
4987
5133
|
...GITHUB_ISSUE_SUGGESTED_EVENTS,
|
|
4988
5134
|
...GITHUB_PULL_REQUEST_SUGGESTED_EVENTS
|
|
4989
5135
|
],
|
|
4990
|
-
matchFields:
|
|
5136
|
+
matchFields: {
|
|
5137
|
+
...GITHUB_ISSUE_COMMENT_MATCH_FIELDS,
|
|
5138
|
+
...GITHUB_PULL_REQUEST_MATCH_FIELDS
|
|
5139
|
+
},
|
|
4991
5140
|
guidance: gitHubPullRequestEventGuidance(
|
|
4992
5141
|
options.pullRequestEvents?.guidance
|
|
4993
5142
|
)
|
|
@@ -5043,6 +5192,46 @@ function githubPlugin(options = {}) {
|
|
|
5043
5192
|
]
|
|
5044
5193
|
},
|
|
5045
5194
|
hooks: {
|
|
5195
|
+
async conversationTitleContext(ctx) {
|
|
5196
|
+
return await loadGitHubConversationTitleContext({
|
|
5197
|
+
config: ctx.config,
|
|
5198
|
+
log: ctx.log,
|
|
5199
|
+
text: ctx.text,
|
|
5200
|
+
loadObject: async (reference) => {
|
|
5201
|
+
const { collection, operation } = {
|
|
5202
|
+
commit: {
|
|
5203
|
+
collection: "commits",
|
|
5204
|
+
operation: "github.commit.get"
|
|
5205
|
+
},
|
|
5206
|
+
issue: { collection: "issues", operation: "github.issue.get" },
|
|
5207
|
+
pull_request: {
|
|
5208
|
+
collection: "pulls",
|
|
5209
|
+
operation: "github.pull.get"
|
|
5210
|
+
}
|
|
5211
|
+
}[reference.kind];
|
|
5212
|
+
const response = await ctx.egress.fetch({
|
|
5213
|
+
provider: "github",
|
|
5214
|
+
operation,
|
|
5215
|
+
request: new Request(
|
|
5216
|
+
`https://api.github.com/repos/${encodeURIComponent(reference.owner)}/${encodeURIComponent(reference.name)}/${collection}/${encodeURIComponent(reference.id)}`,
|
|
5217
|
+
{
|
|
5218
|
+
headers: {
|
|
5219
|
+
Accept: "application/vnd.github+json",
|
|
5220
|
+
"X-GitHub-Api-Version": "2022-11-28"
|
|
5221
|
+
},
|
|
5222
|
+
signal: ctx.signal
|
|
5223
|
+
}
|
|
5224
|
+
)
|
|
5225
|
+
});
|
|
5226
|
+
if (!response.ok) {
|
|
5227
|
+
throw new Error(
|
|
5228
|
+
`GitHub ${reference.kind} lookup failed with HTTP ${response.status}`
|
|
5229
|
+
);
|
|
5230
|
+
}
|
|
5231
|
+
return await response.json();
|
|
5232
|
+
}
|
|
5233
|
+
});
|
|
5234
|
+
},
|
|
5046
5235
|
conversationSidebar(ctx) {
|
|
5047
5236
|
return {
|
|
5048
5237
|
annotationsByConversationId: Object.fromEntries(
|
package/dist/testing.js
CHANGED
|
@@ -4,3 +4,11 @@ export declare function botLoginFromEmail(value: string | undefined): string | u
|
|
|
4
4
|
export declare function isBotLogin(login: string | null | undefined, botEmail: string | undefined): boolean;
|
|
5
5
|
/** Derive the GitHub user id encoded in a standard GitHub noreply address. */
|
|
6
6
|
export declare function botUserIdFromEmail(value: string | undefined): number | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Check whether the author's own text mentions the bot encoded in the
|
|
9
|
+
* configured bot email. GitHub sends mentions only as comment text, with no
|
|
10
|
+
* structured field, so this reads the App slug: the bot login without `[bot]`.
|
|
11
|
+
* This shows only that the comment addresses the bot. It does not grant trust;
|
|
12
|
+
* match the commenter's `senderId` for that.
|
|
13
|
+
*/
|
|
14
|
+
export declare function mentionsBotLogin(text: string, botEmail: string | undefined): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior-github",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.261.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -30,8 +30,9 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@sinclair/typebox": "^0.34.49",
|
|
32
32
|
"drizzle-orm": "^0.45.2",
|
|
33
|
+
"marked": "^18.1.2",
|
|
33
34
|
"zod": "^4.5.4",
|
|
34
|
-
"@sentry/junior-plugin-api": "0.
|
|
35
|
+
"@sentry/junior-plugin-api": "0.261.0"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"@oxlint/plugins": "1.79.0",
|
|
@@ -41,7 +42,7 @@
|
|
|
41
42
|
"oxlint": "^1.79.0",
|
|
42
43
|
"tsup": "^8.5.1",
|
|
43
44
|
"typescript": "^7.0.2",
|
|
44
|
-
"vitest": "^4.1.
|
|
45
|
+
"vitest": "^4.1.12",
|
|
45
46
|
"@sentry/junior-testing": "0.0.0"
|
|
46
47
|
},
|
|
47
48
|
"scripts": {
|