@sentry/junior-github 0.257.0 → 0.259.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-JF4WIM23.js → chunk-6F62DDRZ.js} +35 -8
- package/dist/credential-support.d.ts +14 -4
- package/dist/db/schema.d.ts +19 -19
- package/dist/events/pull-request.d.ts +1 -1
- package/dist/index.js +87 -95
- package/dist/pull-request-outcomes/store.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/dist/tool-support/attribution.d.ts +5 -1
- package/dist/tools/clone-repository.d.ts +8 -8
- package/dist/tools/create-issue.d.ts +11 -11
- package/dist/tools/create-pull-request.d.ts +12 -12
- package/dist/tools/get-deployment.d.ts +38 -38
- package/dist/tools/get-pull-request.d.ts +24 -24
- package/dist/tools/get-release.d.ts +28 -28
- package/dist/tools/get-repository.d.ts +17 -17
- package/dist/tools/resolve-pull-request-review-thread.d.ts +11 -11
- package/dist/tools/submit-pull-request-review.d.ts +12 -12
- package/dist/tools/update-issue.d.ts +21 -17
- package/dist/tools/update-pull-request-feedback.d.ts +12 -12
- package/dist/tools/update-pull-request.d.ts +25 -21
- package/dist/webhooks/installation-requests.d.ts +17 -0
- package/package.json +3 -3
|
@@ -855,6 +855,35 @@ async function issueInstallationCredential(options) {
|
|
|
855
855
|
expiresAtMs: token.expiresAtMs
|
|
856
856
|
});
|
|
857
857
|
}
|
|
858
|
+
async function issueGitHubCredential(ctx, options) {
|
|
859
|
+
const installation = {
|
|
860
|
+
appIdEnv: options.appIdEnv,
|
|
861
|
+
installationIdEnv: options.installationIdEnv,
|
|
862
|
+
privateKeyEnv: options.privateKeyEnv
|
|
863
|
+
};
|
|
864
|
+
try {
|
|
865
|
+
if (ctx.grant.name === "installation-read") {
|
|
866
|
+
return await issueInstallationCredential({
|
|
867
|
+
...installation,
|
|
868
|
+
...options.readPermissions
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
if (ctx.grant.name === "installation-write") {
|
|
872
|
+
return await issueInstallationCredential(installation);
|
|
873
|
+
}
|
|
874
|
+
if (USER_TOKEN_GRANTS.has(ctx.grant.name)) {
|
|
875
|
+
return await issueUserCredential(ctx, options);
|
|
876
|
+
}
|
|
877
|
+
} catch (error) {
|
|
878
|
+
if (error instanceof GitHubPluginSetupError) {
|
|
879
|
+
return credentialUnavailable(error.message);
|
|
880
|
+
}
|
|
881
|
+
throw error;
|
|
882
|
+
}
|
|
883
|
+
throw new Error(
|
|
884
|
+
`GitHub plugin cannot issue unknown grant "${ctx.grant.name}".`
|
|
885
|
+
);
|
|
886
|
+
}
|
|
858
887
|
function createPermissionCache() {
|
|
859
888
|
let cached;
|
|
860
889
|
let pending;
|
|
@@ -1281,10 +1310,12 @@ async function loadCheckSuiteFacts(args) {
|
|
|
1281
1310
|
var GITHUB_BOT_NOREPLY_EMAIL = /^(?<userId>[1-9]\d*)\+(?<login>[^@]+\[bot\])@users\.noreply\.github\.com$/i;
|
|
1282
1311
|
function parseGitHubBotIdentity(value) {
|
|
1283
1312
|
const match = GITHUB_BOT_NOREPLY_EMAIL.exec(value?.trim() ?? "");
|
|
1284
|
-
|
|
1313
|
+
const login = match?.groups?.login;
|
|
1314
|
+
const userId = match?.groups?.userId;
|
|
1315
|
+
if (!login || !userId) return void 0;
|
|
1285
1316
|
return {
|
|
1286
|
-
login
|
|
1287
|
-
userId: Number(
|
|
1317
|
+
login,
|
|
1318
|
+
userId: Number(userId)
|
|
1288
1319
|
};
|
|
1289
1320
|
}
|
|
1290
1321
|
function botLoginFromEmail(value) {
|
|
@@ -1964,22 +1995,18 @@ export {
|
|
|
1964
1995
|
GITHUB_AUTH_TOKEN_PLACEHOLDER,
|
|
1965
1996
|
GITHUB_GRAPHQL_RESPONSE_BODY_LIMIT_BYTES,
|
|
1966
1997
|
HTTP_READ_METHODS,
|
|
1967
|
-
USER_TOKEN_GRANTS,
|
|
1968
1998
|
CREATE_TOOL_ROUTING_GUIDANCE,
|
|
1969
1999
|
USER_WRITE_REQUIREMENTS,
|
|
1970
|
-
GitHubPluginSetupError,
|
|
1971
2000
|
isRecord,
|
|
1972
2001
|
readEnv,
|
|
1973
2002
|
requireEnv,
|
|
1974
2003
|
normalizeScopeList,
|
|
1975
2004
|
githubRequest,
|
|
1976
|
-
credentialUnavailable,
|
|
1977
2005
|
githubRepositoryFromUrl,
|
|
1978
2006
|
resolveUserAccount,
|
|
1979
2007
|
listVerifiedUserEmails,
|
|
1980
|
-
issueUserCredential,
|
|
1981
2008
|
issueInstallationToken,
|
|
1982
|
-
|
|
2009
|
+
issueGitHubCredential,
|
|
1983
2010
|
createPermissionCache,
|
|
1984
2011
|
parseCheckSuitePublishTargets,
|
|
1985
2012
|
needsCheckSuitePullRequestFacts,
|
|
@@ -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/db/schema.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const githubPullRequestStateSchema: z.ZodEnum<{
|
|
3
|
+
closed_unmerged: "closed_unmerged";
|
|
3
4
|
merged: "merged";
|
|
4
5
|
open: "open";
|
|
5
|
-
closed_unmerged: "closed_unmerged";
|
|
6
6
|
}>;
|
|
7
7
|
export type GitHubPullRequestState = z.output<typeof githubPullRequestStateSchema>;
|
|
8
8
|
export declare const githubPullRequestCommitCompositionSchema: z.ZodEnum<{
|
|
@@ -168,8 +168,8 @@ export declare const juniorGitHubIssues: import("drizzle-orm/pg-core").PgTableWi
|
|
|
168
168
|
}, {}, {
|
|
169
169
|
baseBuilder: import("drizzle-orm/pg-core").PgColumnBuilder<{
|
|
170
170
|
name: "conversation_ids";
|
|
171
|
-
dataType:
|
|
172
|
-
columnType:
|
|
171
|
+
dataType: 'string';
|
|
172
|
+
columnType: 'PgText';
|
|
173
173
|
data: string;
|
|
174
174
|
enumValues: [string, ...string[]];
|
|
175
175
|
driverParam: string;
|
|
@@ -228,7 +228,7 @@ export declare const juniorGitHubIssues: import("drizzle-orm/pg-core").PgTableWi
|
|
|
228
228
|
generated: undefined;
|
|
229
229
|
}, {}, {}>;
|
|
230
230
|
};
|
|
231
|
-
dialect:
|
|
231
|
+
dialect: 'pg';
|
|
232
232
|
}>;
|
|
233
233
|
/** Current provider projection for pull requests classified as Junior-owned. */
|
|
234
234
|
export declare const juniorGitHubPullRequests: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
@@ -308,7 +308,7 @@ export declare const juniorGitHubPullRequests: import("drizzle-orm/pg-core").PgT
|
|
|
308
308
|
tableName: "junior_github_pull_requests";
|
|
309
309
|
dataType: "string";
|
|
310
310
|
columnType: "PgText";
|
|
311
|
-
data: "
|
|
311
|
+
data: "closed_unmerged" | "merged" | "open";
|
|
312
312
|
driverParam: string;
|
|
313
313
|
notNull: true;
|
|
314
314
|
hasDefault: false;
|
|
@@ -320,7 +320,7 @@ export declare const juniorGitHubPullRequests: import("drizzle-orm/pg-core").PgT
|
|
|
320
320
|
identity: undefined;
|
|
321
321
|
generated: undefined;
|
|
322
322
|
}, {}, {
|
|
323
|
-
$type: "
|
|
323
|
+
$type: "closed_unmerged" | "merged" | "open";
|
|
324
324
|
}>;
|
|
325
325
|
commitComposition: import("drizzle-orm/pg-core").PgColumn<{
|
|
326
326
|
name: "commit_composition";
|
|
@@ -376,8 +376,8 @@ export declare const juniorGitHubPullRequests: import("drizzle-orm/pg-core").PgT
|
|
|
376
376
|
}, {}, {
|
|
377
377
|
baseBuilder: import("drizzle-orm/pg-core").PgColumnBuilder<{
|
|
378
378
|
name: "conversation_ids";
|
|
379
|
-
dataType:
|
|
380
|
-
columnType:
|
|
379
|
+
dataType: 'string';
|
|
380
|
+
columnType: 'PgText';
|
|
381
381
|
data: string;
|
|
382
382
|
enumValues: [string, ...string[]];
|
|
383
383
|
driverParam: string;
|
|
@@ -453,7 +453,7 @@ export declare const juniorGitHubPullRequests: import("drizzle-orm/pg-core").PgT
|
|
|
453
453
|
generated: undefined;
|
|
454
454
|
}, {}, {}>;
|
|
455
455
|
};
|
|
456
|
-
dialect:
|
|
456
|
+
dialect: 'pg';
|
|
457
457
|
}>;
|
|
458
458
|
/** Many-to-many links between tracked pull requests and tracked issues. */
|
|
459
459
|
export declare const juniorGitHubPullRequestIssues: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
@@ -512,7 +512,7 @@ export declare const juniorGitHubPullRequestIssues: import("drizzle-orm/pg-core"
|
|
|
512
512
|
generated: undefined;
|
|
513
513
|
}, {}, {}>;
|
|
514
514
|
};
|
|
515
|
-
dialect:
|
|
515
|
+
dialect: 'pg';
|
|
516
516
|
}>;
|
|
517
517
|
export declare const githubSqlSchema: {
|
|
518
518
|
juniorGitHubIssues: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
@@ -660,8 +660,8 @@ export declare const githubSqlSchema: {
|
|
|
660
660
|
}, {}, {
|
|
661
661
|
baseBuilder: import("drizzle-orm/pg-core").PgColumnBuilder<{
|
|
662
662
|
name: "conversation_ids";
|
|
663
|
-
dataType:
|
|
664
|
-
columnType:
|
|
663
|
+
dataType: 'string';
|
|
664
|
+
columnType: 'PgText';
|
|
665
665
|
data: string;
|
|
666
666
|
enumValues: [string, ...string[]];
|
|
667
667
|
driverParam: string;
|
|
@@ -720,7 +720,7 @@ export declare const githubSqlSchema: {
|
|
|
720
720
|
generated: undefined;
|
|
721
721
|
}, {}, {}>;
|
|
722
722
|
};
|
|
723
|
-
dialect:
|
|
723
|
+
dialect: 'pg';
|
|
724
724
|
}>;
|
|
725
725
|
juniorGitHubPullRequestIssues: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
726
726
|
name: "junior_github_pull_request_issues";
|
|
@@ -778,7 +778,7 @@ export declare const githubSqlSchema: {
|
|
|
778
778
|
generated: undefined;
|
|
779
779
|
}, {}, {}>;
|
|
780
780
|
};
|
|
781
|
-
dialect:
|
|
781
|
+
dialect: 'pg';
|
|
782
782
|
}>;
|
|
783
783
|
juniorGitHubPullRequests: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
784
784
|
name: "junior_github_pull_requests";
|
|
@@ -857,7 +857,7 @@ export declare const githubSqlSchema: {
|
|
|
857
857
|
tableName: "junior_github_pull_requests";
|
|
858
858
|
dataType: "string";
|
|
859
859
|
columnType: "PgText";
|
|
860
|
-
data: "
|
|
860
|
+
data: "closed_unmerged" | "merged" | "open";
|
|
861
861
|
driverParam: string;
|
|
862
862
|
notNull: true;
|
|
863
863
|
hasDefault: false;
|
|
@@ -869,7 +869,7 @@ export declare const githubSqlSchema: {
|
|
|
869
869
|
identity: undefined;
|
|
870
870
|
generated: undefined;
|
|
871
871
|
}, {}, {
|
|
872
|
-
$type: "
|
|
872
|
+
$type: "closed_unmerged" | "merged" | "open";
|
|
873
873
|
}>;
|
|
874
874
|
commitComposition: import("drizzle-orm/pg-core").PgColumn<{
|
|
875
875
|
name: "commit_composition";
|
|
@@ -925,8 +925,8 @@ export declare const githubSqlSchema: {
|
|
|
925
925
|
}, {}, {
|
|
926
926
|
baseBuilder: import("drizzle-orm/pg-core").PgColumnBuilder<{
|
|
927
927
|
name: "conversation_ids";
|
|
928
|
-
dataType:
|
|
929
|
-
columnType:
|
|
928
|
+
dataType: 'string';
|
|
929
|
+
columnType: 'PgText';
|
|
930
930
|
data: string;
|
|
931
931
|
enumValues: [string, ...string[]];
|
|
932
932
|
driverParam: string;
|
|
@@ -1002,6 +1002,6 @@ export declare const githubSqlSchema: {
|
|
|
1002
1002
|
generated: undefined;
|
|
1003
1003
|
}, {}, {}>;
|
|
1004
1004
|
};
|
|
1005
|
-
dialect:
|
|
1005
|
+
dialect: 'pg';
|
|
1006
1006
|
}>;
|
|
1007
1007
|
};
|
|
@@ -24,7 +24,7 @@ export declare function gitHubPullRequestCreateWatch(config: GitHubPullRequestSu
|
|
|
24
24
|
export declare const GITHUB_PULL_REQUEST_SUGGESTED_EVENTS: readonly ["pull_request.checks.failed", "pull_request.comment.created", "pull_request.ready_for_review", "pull_request.review.changes_requested", "pull_request.review.commented", "pull_request.review_comment.created", "pull_request.merged", "pull_request.closed_unmerged"];
|
|
25
25
|
/** Exact values GitHub may set on pull request event data. Missing keys do not match. */
|
|
26
26
|
export declare const GITHUB_PULL_REQUEST_MATCH_FIELDS: Record<string, {
|
|
27
|
-
kind: "
|
|
27
|
+
kind: "boolean" | "number" | "string";
|
|
28
28
|
description: string;
|
|
29
29
|
enum?: string[] | undefined;
|
|
30
30
|
}>;
|
package/dist/index.js
CHANGED
|
@@ -20,14 +20,11 @@ import {
|
|
|
20
20
|
GITHUB_RELEASE_SOURCE_IDENTIFIER,
|
|
21
21
|
GITHUB_RELEASE_SUGGESTED_EVENTS,
|
|
22
22
|
GITHUB_REPOSITORY_IDENTIFIER,
|
|
23
|
-
GitHubPluginSetupError,
|
|
24
23
|
HTTP_READ_METHODS,
|
|
25
|
-
USER_TOKEN_GRANTS,
|
|
26
24
|
USER_WRITE_REQUIREMENTS,
|
|
27
25
|
botLoginFromEmail,
|
|
28
26
|
botUserIdFromEmail,
|
|
29
27
|
createPermissionCache,
|
|
30
|
-
credentialUnavailable,
|
|
31
28
|
gitHubDeploymentSourceSubscribable,
|
|
32
29
|
gitHubIssueSubscribable,
|
|
33
30
|
gitHubPullRequestCreateWatch,
|
|
@@ -39,9 +36,8 @@ import {
|
|
|
39
36
|
githubRequest,
|
|
40
37
|
isBotLogin,
|
|
41
38
|
isRecord,
|
|
42
|
-
|
|
39
|
+
issueGitHubCredential,
|
|
43
40
|
issueInstallationToken,
|
|
44
|
-
issueUserCredential,
|
|
45
41
|
listVerifiedUserEmails,
|
|
46
42
|
loadCheckSuiteFacts,
|
|
47
43
|
needsCheckSuitePullRequestFacts,
|
|
@@ -53,7 +49,7 @@ import {
|
|
|
53
49
|
readGrantPermissions,
|
|
54
50
|
requireEnv,
|
|
55
51
|
resolveUserAccount
|
|
56
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-6F62DDRZ.js";
|
|
57
53
|
|
|
58
54
|
// src/plugin.ts
|
|
59
55
|
import {
|
|
@@ -539,13 +535,22 @@ function cleanDisplayValue(value, userId) {
|
|
|
539
535
|
}
|
|
540
536
|
return cleaned;
|
|
541
537
|
}
|
|
538
|
+
function automationLabel(source, automationUrl) {
|
|
539
|
+
if (source?.kind !== "event_automation" && source?.kind !== "scheduled_automation" || !source.automationId) {
|
|
540
|
+
return void 0;
|
|
541
|
+
}
|
|
542
|
+
const automation = `automation \`${source.automationId}\``;
|
|
543
|
+
const label = automationUrl ? `[${automation}](${automationUrl})` : automation;
|
|
544
|
+
return source.automationRunId ? `${label} \xB7 Run ID \`${source.automationRunId}\`` : label;
|
|
545
|
+
}
|
|
542
546
|
function requesterLabel(args) {
|
|
543
547
|
const { actor, identity, user } = args;
|
|
544
|
-
|
|
545
|
-
|
|
548
|
+
const automation = automationLabel(args.source, args.automationUrl);
|
|
549
|
+
if (automation) {
|
|
550
|
+
return automation;
|
|
546
551
|
}
|
|
547
|
-
if (actor.platform === "system") {
|
|
548
|
-
return
|
|
552
|
+
if (!actor || actor.platform === "system") {
|
|
553
|
+
return void 0;
|
|
549
554
|
}
|
|
550
555
|
const login = linkedGitHubLogin(user);
|
|
551
556
|
if (login) {
|
|
@@ -561,7 +566,7 @@ function parseExistingLabels(blockContents) {
|
|
|
561
566
|
return [];
|
|
562
567
|
}
|
|
563
568
|
const withoutLeadIn = trimmed.replace(/^(?:Requested by|via)\s+/i, "");
|
|
564
|
-
return withoutLeadIn.split(/,\s*(
|
|
569
|
+
return withoutLeadIn.split(/,\s*(?=\*\*|@|\[?automation `|Junior system actor `|via\s)/i).map((entry) => entry.trim().replace(/^via\s+/i, "")).filter(Boolean);
|
|
565
570
|
}
|
|
566
571
|
function formatAttributionBlock(labels) {
|
|
567
572
|
return `${GITHUB_REQUEST_ATTRIBUTION_START}
|
|
@@ -574,7 +579,7 @@ function applyAttribution(body, label) {
|
|
|
574
579
|
`${GITHUB_REQUEST_ATTRIBUTION_START}([\\s\\S]*?)${GITHUB_REQUEST_ATTRIBUTION_END}`
|
|
575
580
|
);
|
|
576
581
|
const existingMatch = normalizedBody.match(existing);
|
|
577
|
-
const existingLabels = existingMatch ? parseExistingLabels(existingMatch[1]) : [];
|
|
582
|
+
const existingLabels = existingMatch?.[1] !== void 0 ? parseExistingLabels(existingMatch[1]) : [];
|
|
578
583
|
const labels = label && !existingLabels.includes(label) ? [...existingLabels, label] : existingLabels;
|
|
579
584
|
const attribution = labels.length ? formatAttributionBlock(labels) : void 0;
|
|
580
585
|
if (existingMatch) {
|
|
@@ -602,7 +607,9 @@ async function appendGitHubRequesterAttribution(body, ctx) {
|
|
|
602
607
|
body,
|
|
603
608
|
requesterLabel({
|
|
604
609
|
actor: ctx.actor,
|
|
610
|
+
automationUrl: ctx.automationLink?.url,
|
|
605
611
|
identity: resolved?.identity,
|
|
612
|
+
source: ctx.source,
|
|
606
613
|
user: resolved?.user
|
|
607
614
|
})
|
|
608
615
|
);
|
|
@@ -3853,6 +3860,52 @@ function createGitHubWebhookRoute(args) {
|
|
|
3853
3860
|
};
|
|
3854
3861
|
}
|
|
3855
3862
|
|
|
3863
|
+
// src/webhooks/installation-requests.ts
|
|
3864
|
+
function splitRepository(fullName, label) {
|
|
3865
|
+
const [owner, name, ...extra] = fullName.split("/");
|
|
3866
|
+
if (!owner || !name || extra.length > 0) {
|
|
3867
|
+
throw new Error(`GitHub ${label} received an invalid repository name`);
|
|
3868
|
+
}
|
|
3869
|
+
return { owner, name };
|
|
3870
|
+
}
|
|
3871
|
+
async function loadPullRequestCommitPages(env, pullRequest) {
|
|
3872
|
+
const { owner, name } = splitRepository(
|
|
3873
|
+
pullRequest.repositoryFullName,
|
|
3874
|
+
"pull request commits"
|
|
3875
|
+
);
|
|
3876
|
+
const token = await issueInstallationToken({
|
|
3877
|
+
...env,
|
|
3878
|
+
permissions: { pull_requests: "read" },
|
|
3879
|
+
repositories: [name]
|
|
3880
|
+
});
|
|
3881
|
+
return async (page, perPage) => await githubRequest(
|
|
3882
|
+
"https://api.github.com",
|
|
3883
|
+
`/repos/${encodeURIComponent(owner)}/${encodeURIComponent(name)}/pulls/${pullRequest.number}/commits?per_page=${perPage}&page=${page}`,
|
|
3884
|
+
{ token: token.token }
|
|
3885
|
+
);
|
|
3886
|
+
}
|
|
3887
|
+
async function markPullRequestFeedbackReviewing(env, target) {
|
|
3888
|
+
const { owner, name } = splitRepository(target.repo, "pull request feedback");
|
|
3889
|
+
const token = await issueInstallationToken({
|
|
3890
|
+
...env,
|
|
3891
|
+
repositories: [name]
|
|
3892
|
+
});
|
|
3893
|
+
await githubRequest(
|
|
3894
|
+
"https://api.github.com",
|
|
3895
|
+
pullRequestCommentReactionsPath({
|
|
3896
|
+
owner,
|
|
3897
|
+
name,
|
|
3898
|
+
commentKind: target.commentKind,
|
|
3899
|
+
commentId: target.commentId
|
|
3900
|
+
}),
|
|
3901
|
+
{
|
|
3902
|
+
body: { content: pullRequestFeedbackReactionContent("reviewing") },
|
|
3903
|
+
method: "POST",
|
|
3904
|
+
token: token.token
|
|
3905
|
+
}
|
|
3906
|
+
);
|
|
3907
|
+
}
|
|
3908
|
+
|
|
3856
3909
|
// src/pull-request-outcomes/commit-composition.ts
|
|
3857
3910
|
import { z as z20 } from "zod";
|
|
3858
3911
|
var canonicalCommitSchema = z20.object({
|
|
@@ -5023,25 +5076,10 @@ function githubPlugin(options = {}) {
|
|
|
5023
5076
|
};
|
|
5024
5077
|
},
|
|
5025
5078
|
routes(ctx) {
|
|
5026
|
-
const
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
"GitHub pull request commits received an invalid repository name"
|
|
5031
|
-
);
|
|
5032
|
-
}
|
|
5033
|
-
const token = await issueInstallationToken({
|
|
5034
|
-
appIdEnv,
|
|
5035
|
-
privateKeyEnv,
|
|
5036
|
-
installationIdEnv,
|
|
5037
|
-
permissions: { pull_requests: "read" },
|
|
5038
|
-
repositories: [name]
|
|
5039
|
-
});
|
|
5040
|
-
return async (page, perPage) => await githubRequest(
|
|
5041
|
-
"https://api.github.com",
|
|
5042
|
-
`/repos/${encodeURIComponent(owner)}/${encodeURIComponent(name)}/pulls/${pullRequest.number}/commits?per_page=${perPage}&page=${page}`,
|
|
5043
|
-
{ token: token.token }
|
|
5044
|
-
);
|
|
5079
|
+
const installationEnv = {
|
|
5080
|
+
appIdEnv,
|
|
5081
|
+
installationIdEnv,
|
|
5082
|
+
privateKeyEnv
|
|
5045
5083
|
};
|
|
5046
5084
|
return [
|
|
5047
5085
|
createGitHubWebhookRoute({
|
|
@@ -5050,7 +5088,10 @@ function githubPlugin(options = {}) {
|
|
|
5050
5088
|
botEmail: () => readEnv(botEmailEnv),
|
|
5051
5089
|
classifyPullRequestCommits: async (pullRequest) => await classifyGitHubPullRequestCommitComposition({
|
|
5052
5090
|
botEmail: requireEnv(botEmailEnv),
|
|
5053
|
-
loadPage: await
|
|
5091
|
+
loadPage: await loadPullRequestCommitPages(
|
|
5092
|
+
installationEnv,
|
|
5093
|
+
pullRequest
|
|
5094
|
+
)
|
|
5054
5095
|
}),
|
|
5055
5096
|
codeChanges: ctx.codeChanges,
|
|
5056
5097
|
db: ctx.db,
|
|
@@ -5058,39 +5099,13 @@ function githubPlugin(options = {}) {
|
|
|
5058
5099
|
installationIdEnv,
|
|
5059
5100
|
loadPullRequestPeople: async (pullRequest) => await loadGitHubPullRequestPeople({
|
|
5060
5101
|
logins: pullRequest.logins,
|
|
5061
|
-
loadPage: await
|
|
5102
|
+
loadPage: await loadPullRequestCommitPages(
|
|
5103
|
+
installationEnv,
|
|
5104
|
+
pullRequest
|
|
5105
|
+
)
|
|
5062
5106
|
}),
|
|
5063
5107
|
log: ctx.log,
|
|
5064
|
-
markFeedbackReviewing: async (
|
|
5065
|
-
const [owner, name, ...extra] = repo.split("/");
|
|
5066
|
-
if (!owner || !name || extra.length > 0) {
|
|
5067
|
-
throw new Error(
|
|
5068
|
-
"GitHub pull request feedback received an invalid repository name"
|
|
5069
|
-
);
|
|
5070
|
-
}
|
|
5071
|
-
const token = await issueInstallationToken({
|
|
5072
|
-
appIdEnv,
|
|
5073
|
-
privateKeyEnv,
|
|
5074
|
-
installationIdEnv,
|
|
5075
|
-
repositories: [name]
|
|
5076
|
-
});
|
|
5077
|
-
await githubRequest(
|
|
5078
|
-
"https://api.github.com",
|
|
5079
|
-
pullRequestCommentReactionsPath({
|
|
5080
|
-
owner,
|
|
5081
|
-
name,
|
|
5082
|
-
commentKind,
|
|
5083
|
-
commentId
|
|
5084
|
-
}),
|
|
5085
|
-
{
|
|
5086
|
-
body: {
|
|
5087
|
-
content: pullRequestFeedbackReactionContent("reviewing")
|
|
5088
|
-
},
|
|
5089
|
-
method: "POST",
|
|
5090
|
-
token: token.token
|
|
5091
|
-
}
|
|
5092
|
-
);
|
|
5093
|
-
},
|
|
5108
|
+
markFeedbackReviewing: async (target) => await markPullRequestFeedbackReviewing(installationEnv, target),
|
|
5094
5109
|
privateKeyEnv,
|
|
5095
5110
|
events: ctx.events,
|
|
5096
5111
|
webhookSecret: () => readEnv("GITHUB_WEBHOOK_SECRET")
|
|
@@ -5180,38 +5195,15 @@ function githubPlugin(options = {}) {
|
|
|
5180
5195
|
return verifiedEmails.length > 0 ? { ...account, verifiedEmails } : account;
|
|
5181
5196
|
},
|
|
5182
5197
|
async issueCredential(ctx) {
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
if (ctx.grant.name === "installation-write") {
|
|
5193
|
-
return await issueInstallationCredential({
|
|
5194
|
-
appIdEnv,
|
|
5195
|
-
privateKeyEnv,
|
|
5196
|
-
installationIdEnv
|
|
5197
|
-
});
|
|
5198
|
-
}
|
|
5199
|
-
if (USER_TOKEN_GRANTS.has(ctx.grant.name)) {
|
|
5200
|
-
return await issueUserCredential(ctx, {
|
|
5201
|
-
clientIdEnv,
|
|
5202
|
-
clientSecretEnv,
|
|
5203
|
-
userScope
|
|
5204
|
-
});
|
|
5205
|
-
}
|
|
5206
|
-
} catch (error) {
|
|
5207
|
-
if (error instanceof GitHubPluginSetupError) {
|
|
5208
|
-
return credentialUnavailable(error.message);
|
|
5209
|
-
}
|
|
5210
|
-
throw error;
|
|
5211
|
-
}
|
|
5212
|
-
throw new Error(
|
|
5213
|
-
`GitHub plugin cannot issue unknown grant "${ctx.grant.name}".`
|
|
5214
|
-
);
|
|
5198
|
+
return await issueGitHubCredential(ctx, {
|
|
5199
|
+
appIdEnv,
|
|
5200
|
+
clientIdEnv,
|
|
5201
|
+
clientSecretEnv,
|
|
5202
|
+
installationIdEnv,
|
|
5203
|
+
privateKeyEnv,
|
|
5204
|
+
readPermissions: declaredReadPermissions ? { permissions: declaredReadPermissions } : { loadPermissions: loadReadPermissions },
|
|
5205
|
+
userScope
|
|
5206
|
+
});
|
|
5215
5207
|
}
|
|
5216
5208
|
}
|
|
5217
5209
|
});
|
|
@@ -15,9 +15,9 @@ declare const githubPullRequestOutcomeInputSchema: z.ZodObject<{
|
|
|
15
15
|
repositoryFullName: z.ZodString;
|
|
16
16
|
repositoryId: z.ZodString;
|
|
17
17
|
state: z.ZodEnum<{
|
|
18
|
+
closed_unmerged: "closed_unmerged";
|
|
18
19
|
merged: "merged";
|
|
19
20
|
open: "open";
|
|
20
|
-
closed_unmerged: "closed_unmerged";
|
|
21
21
|
}>;
|
|
22
22
|
title: z.ZodOptional<z.ZodString>;
|
|
23
23
|
updatedAt: z.ZodDate;
|
package/dist/testing.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Actor, Identity, PluginLogger, User } from "@sentry/junior-plugin-api";
|
|
1
|
+
import type { Actor, Identity, PluginLogger, Source, User } from "@sentry/junior-plugin-api";
|
|
2
2
|
export declare const GITHUB_REQUEST_ATTRIBUTION_START = "<!-- junior-request-attribution:start -->";
|
|
3
3
|
export declare const GITHUB_REQUEST_ATTRIBUTION_END = "<!-- junior-request-attribution:end -->";
|
|
4
4
|
/**
|
|
@@ -16,7 +16,11 @@ export declare function linkedGitHubLogin(user: User | undefined): string | unde
|
|
|
16
16
|
*/
|
|
17
17
|
export declare function appendGitHubRequesterAttribution(body: string, ctx: {
|
|
18
18
|
actor?: Actor;
|
|
19
|
+
automationLink?: {
|
|
20
|
+
url: string;
|
|
21
|
+
};
|
|
19
22
|
log: PluginLogger;
|
|
23
|
+
source?: Source;
|
|
20
24
|
users: {
|
|
21
25
|
resolveActor(): Promise<{
|
|
22
26
|
identity?: Identity;
|
|
@@ -9,14 +9,11 @@ export declare function createGitHubCloneRepositoryTool(ctx: {
|
|
|
9
9
|
directory?: string | undefined;
|
|
10
10
|
allowAdHoc?: boolean | undefined;
|
|
11
11
|
}, {
|
|
12
|
-
path: string;
|
|
13
|
-
repo: string;
|
|
14
|
-
target: "cloneRepository";
|
|
15
12
|
objectAnnotations?: {
|
|
16
13
|
kind: "object";
|
|
17
14
|
key: string;
|
|
18
15
|
label: string;
|
|
19
|
-
objectType: "
|
|
16
|
+
objectType: "automation" | "calendar_event" | "code_change" | "deployment" | "item" | "task";
|
|
20
17
|
title: string;
|
|
21
18
|
url: string | null;
|
|
22
19
|
description?: string | undefined;
|
|
@@ -31,7 +28,7 @@ export declare function createGitHubCloneRepositoryTool(ctx: {
|
|
|
31
28
|
sourceBranch?: string | undefined;
|
|
32
29
|
targetBranch?: string | undefined;
|
|
33
30
|
reviewers?: string[] | undefined;
|
|
34
|
-
review?: "
|
|
31
|
+
review?: "approved" | "changes_requested" | "required" | undefined;
|
|
35
32
|
checks?: {
|
|
36
33
|
passed: number;
|
|
37
34
|
failed: number;
|
|
@@ -66,15 +63,15 @@ export declare function createGitHubCloneRepositoryTool(ctx: {
|
|
|
66
63
|
arguments: Record<string, unknown>;
|
|
67
64
|
reason?: string | undefined;
|
|
68
65
|
} | undefined;
|
|
69
|
-
}, {
|
|
70
66
|
path: string;
|
|
71
67
|
repo: string;
|
|
72
68
|
target: "cloneRepository";
|
|
69
|
+
}, {
|
|
73
70
|
objectAnnotations?: {
|
|
74
71
|
kind: "object";
|
|
75
72
|
key: string;
|
|
76
73
|
label: string;
|
|
77
|
-
objectType: "
|
|
74
|
+
objectType: "automation" | "calendar_event" | "code_change" | "deployment" | "item" | "task";
|
|
78
75
|
title: string;
|
|
79
76
|
url: string | null;
|
|
80
77
|
description?: string | undefined;
|
|
@@ -89,7 +86,7 @@ export declare function createGitHubCloneRepositoryTool(ctx: {
|
|
|
89
86
|
sourceBranch?: string | undefined;
|
|
90
87
|
targetBranch?: string | undefined;
|
|
91
88
|
reviewers?: string[] | undefined;
|
|
92
|
-
review?: "
|
|
89
|
+
review?: "approved" | "changes_requested" | "required" | undefined;
|
|
93
90
|
checks?: {
|
|
94
91
|
passed: number;
|
|
95
92
|
failed: number;
|
|
@@ -124,4 +121,7 @@ export declare function createGitHubCloneRepositoryTool(ctx: {
|
|
|
124
121
|
arguments: Record<string, unknown>;
|
|
125
122
|
reason?: string | undefined;
|
|
126
123
|
} | undefined;
|
|
124
|
+
path: string;
|
|
125
|
+
repo: string;
|
|
126
|
+
target: "cloneRepository";
|
|
127
127
|
}>;
|