@sentry/junior-github 0.258.0 → 0.260.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.
- package/dist/{chunk-XN3WOI7O.js → chunk-3PD7XTQH.js} +111 -28
- package/dist/conversation-title-context.d.ts +20 -0
- package/dist/credential-support.d.ts +14 -4
- package/dist/events/issue.d.ts +10 -1
- package/dist/index.js +267 -97
- package/dist/testing.js +1 -1
- package/dist/webhooks/installation-requests.d.ts +17 -0
- package/dist/webhooks/ownership.d.ts +8 -0
- package/package.json +3 -2
|
@@ -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"
|
|
@@ -855,6 +872,35 @@ async function issueInstallationCredential(options) {
|
|
|
855
872
|
expiresAtMs: token.expiresAtMs
|
|
856
873
|
});
|
|
857
874
|
}
|
|
875
|
+
async function issueGitHubCredential(ctx, options) {
|
|
876
|
+
const installation = {
|
|
877
|
+
appIdEnv: options.appIdEnv,
|
|
878
|
+
installationIdEnv: options.installationIdEnv,
|
|
879
|
+
privateKeyEnv: options.privateKeyEnv
|
|
880
|
+
};
|
|
881
|
+
try {
|
|
882
|
+
if (ctx.grant.name === "installation-read") {
|
|
883
|
+
return await issueInstallationCredential({
|
|
884
|
+
...installation,
|
|
885
|
+
...options.readPermissions
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
if (ctx.grant.name === "installation-write") {
|
|
889
|
+
return await issueInstallationCredential(installation);
|
|
890
|
+
}
|
|
891
|
+
if (USER_TOKEN_GRANTS.has(ctx.grant.name)) {
|
|
892
|
+
return await issueUserCredential(ctx, options);
|
|
893
|
+
}
|
|
894
|
+
} catch (error) {
|
|
895
|
+
if (error instanceof GitHubPluginSetupError) {
|
|
896
|
+
return credentialUnavailable(error.message);
|
|
897
|
+
}
|
|
898
|
+
throw error;
|
|
899
|
+
}
|
|
900
|
+
throw new Error(
|
|
901
|
+
`GitHub plugin cannot issue unknown grant "${ctx.grant.name}".`
|
|
902
|
+
);
|
|
903
|
+
}
|
|
858
904
|
function createPermissionCache() {
|
|
859
905
|
let cached;
|
|
860
906
|
let pending;
|
|
@@ -1278,6 +1324,7 @@ async function loadCheckSuiteFacts(args) {
|
|
|
1278
1324
|
}
|
|
1279
1325
|
|
|
1280
1326
|
// src/webhooks/ownership.ts
|
|
1327
|
+
import { lexer } from "marked";
|
|
1281
1328
|
var GITHUB_BOT_NOREPLY_EMAIL = /^(?<userId>[1-9]\d*)\+(?<login>[^@]+\[bot\])@users\.noreply\.github\.com$/i;
|
|
1282
1329
|
function parseGitHubBotIdentity(value) {
|
|
1283
1330
|
const match = GITHUB_BOT_NOREPLY_EMAIL.exec(value?.trim() ?? "");
|
|
@@ -1299,6 +1346,32 @@ function isBotLogin(login, botEmail) {
|
|
|
1299
1346
|
function botUserIdFromEmail(value) {
|
|
1300
1347
|
return parseGitHubBotIdentity(value)?.userId;
|
|
1301
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
|
+
}
|
|
1302
1375
|
|
|
1303
1376
|
// src/webhooks/events.ts
|
|
1304
1377
|
function gitHubEventKey2(deliveryId, eventType) {
|
|
@@ -1319,6 +1392,10 @@ function pullRequestAuthorData(user) {
|
|
|
1319
1392
|
if (email) data.authorEmail = email;
|
|
1320
1393
|
return data;
|
|
1321
1394
|
}
|
|
1395
|
+
function gitHubDoneBy(login) {
|
|
1396
|
+
const handle = login?.trim();
|
|
1397
|
+
return handle ? { doneBy: { provider: "github", handle } } : void 0;
|
|
1398
|
+
}
|
|
1322
1399
|
function pullRequestMatchData(parts) {
|
|
1323
1400
|
const data = {};
|
|
1324
1401
|
for (const part of parts) {
|
|
@@ -1477,7 +1554,8 @@ var issueCommentWebhookSchema = z2.object({
|
|
|
1477
1554
|
login: z2.string().optional().nullable()
|
|
1478
1555
|
}).optional().nullable()
|
|
1479
1556
|
}),
|
|
1480
|
-
repository: repositorySchema2
|
|
1557
|
+
repository: repositorySchema2,
|
|
1558
|
+
sender: z2.object({ id: z2.number(), login: z2.string().min(1) }).optional()
|
|
1481
1559
|
});
|
|
1482
1560
|
function normalizeIssueCommentEvents(deliveryId, body, botEmail) {
|
|
1483
1561
|
const parsed = issueCommentWebhookSchema.safeParse(body);
|
|
@@ -1491,7 +1569,7 @@ function normalizeIssueCommentEvents(deliveryId, body, botEmail) {
|
|
|
1491
1569
|
if (parsed.data.issue.pull_request) {
|
|
1492
1570
|
const eventType = "pull_request.comment.created";
|
|
1493
1571
|
const resource = gitHubPullRequestResource(input);
|
|
1494
|
-
const
|
|
1572
|
+
const data2 = pullRequestMatchData([
|
|
1495
1573
|
pullRequestDraftData(parsed.data.issue.draft),
|
|
1496
1574
|
pullRequestAuthorData(parsed.data.issue.user),
|
|
1497
1575
|
{
|
|
@@ -1508,7 +1586,8 @@ function normalizeIssueCommentEvents(deliveryId, body, botEmail) {
|
|
|
1508
1586
|
occurredAtMs: Date.now(),
|
|
1509
1587
|
identifier: resource.identifier,
|
|
1510
1588
|
trustedSummary: `${resource.label} received a comment${author ? ` from ${author}` : ""}.`,
|
|
1511
|
-
...
|
|
1589
|
+
...gitHubDoneBy(author),
|
|
1590
|
+
...data2 ? { data: data2 } : void 0,
|
|
1512
1591
|
untrustedText: parsed.data.comment.body
|
|
1513
1592
|
},
|
|
1514
1593
|
input.repo
|
|
@@ -1516,24 +1595,29 @@ function normalizeIssueCommentEvents(deliveryId, body, botEmail) {
|
|
|
1516
1595
|
}
|
|
1517
1596
|
const issue = gitHubIssueResource(input);
|
|
1518
1597
|
const repository = gitHubRepositoryResource(input);
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
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
|
+
}));
|
|
1537
1621
|
}
|
|
1538
1622
|
var issueWebhookSchema = z2.object({
|
|
1539
1623
|
action: z2.string(),
|
|
@@ -1637,6 +1721,7 @@ function normalizePullRequestReviewCommentEvent(deliveryId, body, botEmail) {
|
|
|
1637
1721
|
occurredAtMs: Date.now(),
|
|
1638
1722
|
identifier: resource.identifier,
|
|
1639
1723
|
trustedSummary: `${resource.label} received an inline review comment${author ? ` from ${author}` : ""}.`,
|
|
1724
|
+
...gitHubDoneBy(author),
|
|
1640
1725
|
...data ? { data } : void 0,
|
|
1641
1726
|
untrustedText: parsed.data.comment.body
|
|
1642
1727
|
},
|
|
@@ -1687,6 +1772,7 @@ function normalizePullRequestReviewEvent(deliveryId, body, botEmail) {
|
|
|
1687
1772
|
occurredAtMs: Date.now(),
|
|
1688
1773
|
identifier: resource.identifier,
|
|
1689
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),
|
|
1690
1776
|
...data ? { data } : void 0,
|
|
1691
1777
|
untrustedText: parsed.data.review.body ?? void 0
|
|
1692
1778
|
};
|
|
@@ -1937,6 +2023,7 @@ export {
|
|
|
1937
2023
|
readGrantPermissions,
|
|
1938
2024
|
GITHUB_ISSUE_EVENTS,
|
|
1939
2025
|
GITHUB_ISSUE_SUGGESTED_EVENTS,
|
|
2026
|
+
GITHUB_ISSUE_COMMENT_MATCH_FIELDS,
|
|
1940
2027
|
GITHUB_ISSUE_IDENTIFIER,
|
|
1941
2028
|
gitHubIssueSubscribable,
|
|
1942
2029
|
GITHUB_DEPLOYMENT_EVENTS,
|
|
@@ -1966,22 +2053,18 @@ export {
|
|
|
1966
2053
|
GITHUB_AUTH_TOKEN_PLACEHOLDER,
|
|
1967
2054
|
GITHUB_GRAPHQL_RESPONSE_BODY_LIMIT_BYTES,
|
|
1968
2055
|
HTTP_READ_METHODS,
|
|
1969
|
-
USER_TOKEN_GRANTS,
|
|
1970
2056
|
CREATE_TOOL_ROUTING_GUIDANCE,
|
|
1971
2057
|
USER_WRITE_REQUIREMENTS,
|
|
1972
|
-
GitHubPluginSetupError,
|
|
1973
2058
|
isRecord,
|
|
1974
2059
|
readEnv,
|
|
1975
2060
|
requireEnv,
|
|
1976
2061
|
normalizeScopeList,
|
|
1977
2062
|
githubRequest,
|
|
1978
|
-
credentialUnavailable,
|
|
1979
2063
|
githubRepositoryFromUrl,
|
|
1980
2064
|
resolveUserAccount,
|
|
1981
2065
|
listVerifiedUserEmails,
|
|
1982
|
-
issueUserCredential,
|
|
1983
2066
|
issueInstallationToken,
|
|
1984
|
-
|
|
2067
|
+
issueGitHubCredential,
|
|
1985
2068
|
createPermissionCache,
|
|
1986
2069
|
parseCheckSuitePublishTargets,
|
|
1987
2070
|
needsCheckSuitePullRequestFacts,
|
|
@@ -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[]>;
|
|
@@ -75,15 +75,25 @@ export declare function resolveUserAccount(tokens: PluginStoredTokens): Promise<
|
|
|
75
75
|
* Return an empty list when the App does not have it.
|
|
76
76
|
*/
|
|
77
77
|
export declare function listVerifiedUserEmails(tokens: PluginStoredTokens): Promise<string[]>;
|
|
78
|
-
/** Issue a bounded GitHub user credential for an approved grant. */
|
|
79
|
-
export declare function issueUserCredential(ctx: IssueCredentialHookContext, options: UserCredentialOptions): Promise<PluginCredentialResult>;
|
|
80
78
|
/** Issue a bounded raw token for plugin-owned GitHub API calls. */
|
|
81
79
|
export declare function issueInstallationToken(options: InstallationCredentialOptions): Promise<{
|
|
82
80
|
expiresAtMs: number;
|
|
83
81
|
token: string;
|
|
84
82
|
}>;
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
interface GitHubCredentialOptions extends InstallationCredentialBaseOptions, UserCredentialOptions {
|
|
84
|
+
/** Declared read permissions, or a loader for the installed ones. */
|
|
85
|
+
readPermissions: {
|
|
86
|
+
permissions: GitHubAppPermissions;
|
|
87
|
+
} | {
|
|
88
|
+
loadPermissions: LoadInstallationReadPermissions;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Issue the credential for one GitHub grant that host egress selected. Only
|
|
93
|
+
* the `issueCredential` hook may call this. Other code reads and writes GitHub
|
|
94
|
+
* through host egress.
|
|
95
|
+
*/
|
|
96
|
+
export declare function issueGitHubCredential(ctx: IssueCredentialHookContext, options: GitHubCredentialOptions): Promise<PluginCredentialResult>;
|
|
87
97
|
/** Cache the installation's read permissions for one lease period. */
|
|
88
98
|
export declare function createPermissionCache(): LoadInstallationReadPermissions;
|
|
89
99
|
export {};
|
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,
|
|
@@ -20,14 +21,11 @@ import {
|
|
|
20
21
|
GITHUB_RELEASE_SOURCE_IDENTIFIER,
|
|
21
22
|
GITHUB_RELEASE_SUGGESTED_EVENTS,
|
|
22
23
|
GITHUB_REPOSITORY_IDENTIFIER,
|
|
23
|
-
GitHubPluginSetupError,
|
|
24
24
|
HTTP_READ_METHODS,
|
|
25
|
-
USER_TOKEN_GRANTS,
|
|
26
25
|
USER_WRITE_REQUIREMENTS,
|
|
27
26
|
botLoginFromEmail,
|
|
28
27
|
botUserIdFromEmail,
|
|
29
28
|
createPermissionCache,
|
|
30
|
-
credentialUnavailable,
|
|
31
29
|
gitHubDeploymentSourceSubscribable,
|
|
32
30
|
gitHubIssueSubscribable,
|
|
33
31
|
gitHubPullRequestCreateWatch,
|
|
@@ -39,9 +37,8 @@ import {
|
|
|
39
37
|
githubRequest,
|
|
40
38
|
isBotLogin,
|
|
41
39
|
isRecord,
|
|
42
|
-
|
|
40
|
+
issueGitHubCredential,
|
|
43
41
|
issueInstallationToken,
|
|
44
|
-
issueUserCredential,
|
|
45
42
|
listVerifiedUserEmails,
|
|
46
43
|
loadCheckSuiteFacts,
|
|
47
44
|
needsCheckSuitePullRequestFacts,
|
|
@@ -53,7 +50,7 @@ import {
|
|
|
53
50
|
readGrantPermissions,
|
|
54
51
|
requireEnv,
|
|
55
52
|
resolveUserAccount
|
|
56
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-3PD7XTQH.js";
|
|
57
54
|
|
|
58
55
|
// src/plugin.ts
|
|
59
56
|
import {
|
|
@@ -3600,14 +3597,14 @@ async function withGitHubPullRequestPeople(args) {
|
|
|
3600
3597
|
peopleEvents.map((event) => hasMatch(event))
|
|
3601
3598
|
);
|
|
3602
3599
|
if (!matches.some(Boolean)) return args.events;
|
|
3603
|
-
const { pull_request: pullRequest, repository } = parsed.data;
|
|
3600
|
+
const { pull_request: pullRequest, repository: repository2 } = parsed.data;
|
|
3604
3601
|
const target = {
|
|
3605
3602
|
logins: [
|
|
3606
3603
|
...pullRequest.user ? [pullRequest.user.login] : [],
|
|
3607
3604
|
...(pullRequest.assignees ?? []).map((assignee) => assignee.login)
|
|
3608
3605
|
],
|
|
3609
3606
|
number: pullRequest.number,
|
|
3610
|
-
repositoryFullName:
|
|
3607
|
+
repositoryFullName: repository2.full_name
|
|
3611
3608
|
};
|
|
3612
3609
|
let people;
|
|
3613
3610
|
try {
|
|
@@ -3864,6 +3861,52 @@ function createGitHubWebhookRoute(args) {
|
|
|
3864
3861
|
};
|
|
3865
3862
|
}
|
|
3866
3863
|
|
|
3864
|
+
// src/webhooks/installation-requests.ts
|
|
3865
|
+
function splitRepository(fullName, label) {
|
|
3866
|
+
const [owner, name, ...extra] = fullName.split("/");
|
|
3867
|
+
if (!owner || !name || extra.length > 0) {
|
|
3868
|
+
throw new Error(`GitHub ${label} received an invalid repository name`);
|
|
3869
|
+
}
|
|
3870
|
+
return { owner, name };
|
|
3871
|
+
}
|
|
3872
|
+
async function loadPullRequestCommitPages(env, pullRequest) {
|
|
3873
|
+
const { owner, name } = splitRepository(
|
|
3874
|
+
pullRequest.repositoryFullName,
|
|
3875
|
+
"pull request commits"
|
|
3876
|
+
);
|
|
3877
|
+
const token = await issueInstallationToken({
|
|
3878
|
+
...env,
|
|
3879
|
+
permissions: { pull_requests: "read" },
|
|
3880
|
+
repositories: [name]
|
|
3881
|
+
});
|
|
3882
|
+
return async (page, perPage) => await githubRequest(
|
|
3883
|
+
"https://api.github.com",
|
|
3884
|
+
`/repos/${encodeURIComponent(owner)}/${encodeURIComponent(name)}/pulls/${pullRequest.number}/commits?per_page=${perPage}&page=${page}`,
|
|
3885
|
+
{ token: token.token }
|
|
3886
|
+
);
|
|
3887
|
+
}
|
|
3888
|
+
async function markPullRequestFeedbackReviewing(env, target) {
|
|
3889
|
+
const { owner, name } = splitRepository(target.repo, "pull request feedback");
|
|
3890
|
+
const token = await issueInstallationToken({
|
|
3891
|
+
...env,
|
|
3892
|
+
repositories: [name]
|
|
3893
|
+
});
|
|
3894
|
+
await githubRequest(
|
|
3895
|
+
"https://api.github.com",
|
|
3896
|
+
pullRequestCommentReactionsPath({
|
|
3897
|
+
owner,
|
|
3898
|
+
name,
|
|
3899
|
+
commentKind: target.commentKind,
|
|
3900
|
+
commentId: target.commentId
|
|
3901
|
+
}),
|
|
3902
|
+
{
|
|
3903
|
+
body: { content: pullRequestFeedbackReactionContent("reviewing") },
|
|
3904
|
+
method: "POST",
|
|
3905
|
+
token: token.token
|
|
3906
|
+
}
|
|
3907
|
+
);
|
|
3908
|
+
}
|
|
3909
|
+
|
|
3867
3910
|
// src/pull-request-outcomes/commit-composition.ts
|
|
3868
3911
|
import { z as z20 } from "zod";
|
|
3869
3912
|
var canonicalCommitSchema = z20.object({
|
|
@@ -4231,8 +4274,8 @@ function linkifyLine(line) {
|
|
|
4231
4274
|
if (isReferenceBoundary(index2 === 0 ? void 0 : line[index2 - 1])) {
|
|
4232
4275
|
const match = GITHUB_ISSUE_REFERENCE_PATTERN.exec(line.slice(index2));
|
|
4233
4276
|
if (match) {
|
|
4234
|
-
const [reference, owner,
|
|
4235
|
-
output += `[${reference}](https://github.com/${owner}/${
|
|
4277
|
+
const [reference, owner, repository2, number] = match;
|
|
4278
|
+
output += `[${reference}](https://github.com/${owner}/${repository2}/issues/${number})`;
|
|
4236
4279
|
index2 += reference.length;
|
|
4237
4280
|
continue;
|
|
4238
4281
|
}
|
|
@@ -4258,6 +4301,150 @@ function linkifyGitHubReferences(text2) {
|
|
|
4258
4301
|
}).join("\n");
|
|
4259
4302
|
}
|
|
4260
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
|
+
|
|
4261
4448
|
// src/workspace-prepare.ts
|
|
4262
4449
|
async function prepareWorkspace(ctx) {
|
|
4263
4450
|
const repos = ctx.repos.map((entry) => {
|
|
@@ -4743,8 +4930,8 @@ function hostGraphqlMutationRepository(operation, method, upstreamUrl, bodyText)
|
|
|
4743
4930
|
) && new RegExp(`\\b${candidate.field}\\b`).test(parsed.normalized)
|
|
4744
4931
|
);
|
|
4745
4932
|
if (!mutation) return void 0;
|
|
4746
|
-
const
|
|
4747
|
-
return /^[^/]+\/[^/]+$/.test(
|
|
4933
|
+
const repository2 = operation.slice(mutation.operationPrefix.length);
|
|
4934
|
+
return /^[^/]+\/[^/]+$/.test(repository2) ? repository2 : void 0;
|
|
4748
4935
|
}
|
|
4749
4936
|
function isGitHubGraphqlMutation(method, upstreamUrl, bodyText, field) {
|
|
4750
4937
|
if (method !== "POST" || !isGitHubGraphqlUrl(upstreamUrl)) return false;
|
|
@@ -4914,7 +5101,8 @@ function githubPlugin(options = {}) {
|
|
|
4914
5101
|
type: "issue",
|
|
4915
5102
|
identifier: GITHUB_ISSUE_IDENTIFIER,
|
|
4916
5103
|
supportedEvents: [...GITHUB_ISSUE_EVENTS],
|
|
4917
|
-
suggestedEvents: [...GITHUB_ISSUE_SUGGESTED_EVENTS]
|
|
5104
|
+
suggestedEvents: [...GITHUB_ISSUE_SUGGESTED_EVENTS],
|
|
5105
|
+
matchFields: GITHUB_ISSUE_COMMENT_MATCH_FIELDS
|
|
4918
5106
|
},
|
|
4919
5107
|
{
|
|
4920
5108
|
type: "pull_request",
|
|
@@ -4945,7 +5133,10 @@ function githubPlugin(options = {}) {
|
|
|
4945
5133
|
...GITHUB_ISSUE_SUGGESTED_EVENTS,
|
|
4946
5134
|
...GITHUB_PULL_REQUEST_SUGGESTED_EVENTS
|
|
4947
5135
|
],
|
|
4948
|
-
matchFields:
|
|
5136
|
+
matchFields: {
|
|
5137
|
+
...GITHUB_ISSUE_COMMENT_MATCH_FIELDS,
|
|
5138
|
+
...GITHUB_PULL_REQUEST_MATCH_FIELDS
|
|
5139
|
+
},
|
|
4949
5140
|
guidance: gitHubPullRequestEventGuidance(
|
|
4950
5141
|
options.pullRequestEvents?.guidance
|
|
4951
5142
|
)
|
|
@@ -5001,6 +5192,46 @@ function githubPlugin(options = {}) {
|
|
|
5001
5192
|
]
|
|
5002
5193
|
},
|
|
5003
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
|
+
},
|
|
5004
5235
|
conversationSidebar(ctx) {
|
|
5005
5236
|
return {
|
|
5006
5237
|
annotationsByConversationId: Object.fromEntries(
|
|
@@ -5034,25 +5265,10 @@ function githubPlugin(options = {}) {
|
|
|
5034
5265
|
};
|
|
5035
5266
|
},
|
|
5036
5267
|
routes(ctx) {
|
|
5037
|
-
const
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
"GitHub pull request commits received an invalid repository name"
|
|
5042
|
-
);
|
|
5043
|
-
}
|
|
5044
|
-
const token = await issueInstallationToken({
|
|
5045
|
-
appIdEnv,
|
|
5046
|
-
privateKeyEnv,
|
|
5047
|
-
installationIdEnv,
|
|
5048
|
-
permissions: { pull_requests: "read" },
|
|
5049
|
-
repositories: [name]
|
|
5050
|
-
});
|
|
5051
|
-
return async (page, perPage) => await githubRequest(
|
|
5052
|
-
"https://api.github.com",
|
|
5053
|
-
`/repos/${encodeURIComponent(owner)}/${encodeURIComponent(name)}/pulls/${pullRequest.number}/commits?per_page=${perPage}&page=${page}`,
|
|
5054
|
-
{ token: token.token }
|
|
5055
|
-
);
|
|
5268
|
+
const installationEnv = {
|
|
5269
|
+
appIdEnv,
|
|
5270
|
+
installationIdEnv,
|
|
5271
|
+
privateKeyEnv
|
|
5056
5272
|
};
|
|
5057
5273
|
return [
|
|
5058
5274
|
createGitHubWebhookRoute({
|
|
@@ -5061,7 +5277,10 @@ function githubPlugin(options = {}) {
|
|
|
5061
5277
|
botEmail: () => readEnv(botEmailEnv),
|
|
5062
5278
|
classifyPullRequestCommits: async (pullRequest) => await classifyGitHubPullRequestCommitComposition({
|
|
5063
5279
|
botEmail: requireEnv(botEmailEnv),
|
|
5064
|
-
loadPage: await
|
|
5280
|
+
loadPage: await loadPullRequestCommitPages(
|
|
5281
|
+
installationEnv,
|
|
5282
|
+
pullRequest
|
|
5283
|
+
)
|
|
5065
5284
|
}),
|
|
5066
5285
|
codeChanges: ctx.codeChanges,
|
|
5067
5286
|
db: ctx.db,
|
|
@@ -5069,39 +5288,13 @@ function githubPlugin(options = {}) {
|
|
|
5069
5288
|
installationIdEnv,
|
|
5070
5289
|
loadPullRequestPeople: async (pullRequest) => await loadGitHubPullRequestPeople({
|
|
5071
5290
|
logins: pullRequest.logins,
|
|
5072
|
-
loadPage: await
|
|
5291
|
+
loadPage: await loadPullRequestCommitPages(
|
|
5292
|
+
installationEnv,
|
|
5293
|
+
pullRequest
|
|
5294
|
+
)
|
|
5073
5295
|
}),
|
|
5074
5296
|
log: ctx.log,
|
|
5075
|
-
markFeedbackReviewing: async (
|
|
5076
|
-
const [owner, name, ...extra] = repo.split("/");
|
|
5077
|
-
if (!owner || !name || extra.length > 0) {
|
|
5078
|
-
throw new Error(
|
|
5079
|
-
"GitHub pull request feedback received an invalid repository name"
|
|
5080
|
-
);
|
|
5081
|
-
}
|
|
5082
|
-
const token = await issueInstallationToken({
|
|
5083
|
-
appIdEnv,
|
|
5084
|
-
privateKeyEnv,
|
|
5085
|
-
installationIdEnv,
|
|
5086
|
-
repositories: [name]
|
|
5087
|
-
});
|
|
5088
|
-
await githubRequest(
|
|
5089
|
-
"https://api.github.com",
|
|
5090
|
-
pullRequestCommentReactionsPath({
|
|
5091
|
-
owner,
|
|
5092
|
-
name,
|
|
5093
|
-
commentKind,
|
|
5094
|
-
commentId
|
|
5095
|
-
}),
|
|
5096
|
-
{
|
|
5097
|
-
body: {
|
|
5098
|
-
content: pullRequestFeedbackReactionContent("reviewing")
|
|
5099
|
-
},
|
|
5100
|
-
method: "POST",
|
|
5101
|
-
token: token.token
|
|
5102
|
-
}
|
|
5103
|
-
);
|
|
5104
|
-
},
|
|
5297
|
+
markFeedbackReviewing: async (target) => await markPullRequestFeedbackReviewing(installationEnv, target),
|
|
5105
5298
|
privateKeyEnv,
|
|
5106
5299
|
events: ctx.events,
|
|
5107
5300
|
webhookSecret: () => readEnv("GITHUB_WEBHOOK_SECRET")
|
|
@@ -5191,38 +5384,15 @@ function githubPlugin(options = {}) {
|
|
|
5191
5384
|
return verifiedEmails.length > 0 ? { ...account, verifiedEmails } : account;
|
|
5192
5385
|
},
|
|
5193
5386
|
async issueCredential(ctx) {
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
if (ctx.grant.name === "installation-write") {
|
|
5204
|
-
return await issueInstallationCredential({
|
|
5205
|
-
appIdEnv,
|
|
5206
|
-
privateKeyEnv,
|
|
5207
|
-
installationIdEnv
|
|
5208
|
-
});
|
|
5209
|
-
}
|
|
5210
|
-
if (USER_TOKEN_GRANTS.has(ctx.grant.name)) {
|
|
5211
|
-
return await issueUserCredential(ctx, {
|
|
5212
|
-
clientIdEnv,
|
|
5213
|
-
clientSecretEnv,
|
|
5214
|
-
userScope
|
|
5215
|
-
});
|
|
5216
|
-
}
|
|
5217
|
-
} catch (error) {
|
|
5218
|
-
if (error instanceof GitHubPluginSetupError) {
|
|
5219
|
-
return credentialUnavailable(error.message);
|
|
5220
|
-
}
|
|
5221
|
-
throw error;
|
|
5222
|
-
}
|
|
5223
|
-
throw new Error(
|
|
5224
|
-
`GitHub plugin cannot issue unknown grant "${ctx.grant.name}".`
|
|
5225
|
-
);
|
|
5387
|
+
return await issueGitHubCredential(ctx, {
|
|
5388
|
+
appIdEnv,
|
|
5389
|
+
clientIdEnv,
|
|
5390
|
+
clientSecretEnv,
|
|
5391
|
+
installationIdEnv,
|
|
5392
|
+
privateKeyEnv,
|
|
5393
|
+
readPermissions: declaredReadPermissions ? { permissions: declaredReadPermissions } : { loadPermissions: loadReadPermissions },
|
|
5394
|
+
userScope
|
|
5395
|
+
});
|
|
5226
5396
|
}
|
|
5227
5397
|
}
|
|
5228
5398
|
});
|
package/dist/testing.js
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Environment variable names for the GitHub App installation. */
|
|
2
|
+
export interface GitHubInstallationEnv {
|
|
3
|
+
appIdEnv: string;
|
|
4
|
+
installationIdEnv: string;
|
|
5
|
+
privateKeyEnv: string;
|
|
6
|
+
}
|
|
7
|
+
/** Return a reader for pages of a pull request's commits, with a read-only token. */
|
|
8
|
+
export declare function loadPullRequestCommitPages(env: GitHubInstallationEnv, pullRequest: {
|
|
9
|
+
number: number;
|
|
10
|
+
repositoryFullName: string;
|
|
11
|
+
}): Promise<(page: number, perPage: number) => Promise<unknown>>;
|
|
12
|
+
/** Add the "reviewing" reaction to one pull request feedback comment. */
|
|
13
|
+
export declare function markPullRequestFeedbackReviewing(env: GitHubInstallationEnv, target: {
|
|
14
|
+
commentId: number;
|
|
15
|
+
commentKind: "conversation" | "review";
|
|
16
|
+
repo: string;
|
|
17
|
+
}): Promise<void>;
|
|
@@ -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.260.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.260.0"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"@oxlint/plugins": "1.79.0",
|