@sentry/junior-github 0.265.0 → 0.267.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.
@@ -0,0 +1,7 @@
1
+ import { type EventMatchFields } from "@sentry/junior-plugin-api";
2
+ /**
3
+ * Filters on who wrote a GitHub comment or review. Issue comments, pull
4
+ * request comments, reviews, and inline review comments set them, so the
5
+ * issue, pull request, and repository resource types share one definition.
6
+ */
7
+ export declare function gitHubCommentMatchFields(events: readonly string[]): EventMatchFields;
@@ -0,0 +1,18 @@
1
+ import type { PluginEventDeclaration } from "@sentry/junior-plugin-api";
2
+ import { type GitHubPullRequestEvent } from "./pull-request.js";
3
+ /**
4
+ * Declare the reach and guidance of every GitHub event.
5
+ *
6
+ * - Deployment events reach every repository. They carry status facts,
7
+ * Junior adds no reaction, and they load nothing from GitHub.
8
+ * - Release, issue, and pull request events need a `repo` filter. They carry
9
+ * release notes, titles, bodies, comments, or reviews from repositories
10
+ * that can be private, and comments and reviews make Junior add a
11
+ * reaction. The filter limits how many repositories a trigger covers. It
12
+ * does not check that the person can see the repository.
13
+ *
14
+ * Pull request filters such as `authors` and `openerRole` load data from
15
+ * GitHub. Core skips a trigger with no identifier when its `repo` filter does
16
+ * not match the event, so it loads nothing for other repositories.
17
+ */
18
+ export declare function gitHubEventDeclarations(pullRequestGuidance: Partial<Record<GitHubPullRequestEvent, string>>): Record<string, PluginEventDeclaration>;
@@ -11,6 +11,7 @@ export declare const GITHUB_DEPLOYMENT_MATCH_FIELDS: Record<string, {
11
11
  description: string;
12
12
  enum?: string[] | undefined;
13
13
  list?: true | undefined;
14
+ case?: "lower" | "upper" | undefined;
14
15
  events?: string[] | undefined;
15
16
  }>;
16
17
  /** The identifier shape that `gitHubDeploymentSourceResource` builds. */
@@ -2,15 +2,16 @@ 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
4
  /**
5
- * Exact values GitHub sets on issue comment event data. Only
6
- * `issue.comment.created` sets them, so a trigger with these filters cannot
7
- * select other events.
5
+ * Exact values GitHub sets on issue event data. Every issue event sets the
6
+ * repository and issue number. Only `issue.comment.created` sets the comment
7
+ * filters, so a trigger with them cannot select other events.
8
8
  */
9
- export declare const GITHUB_ISSUE_COMMENT_MATCH_FIELDS: Record<string, {
9
+ export declare const GITHUB_ISSUE_MATCH_FIELDS: Record<string, {
10
10
  kind: "boolean" | "number" | "string";
11
11
  description: string;
12
12
  enum?: string[] | undefined;
13
13
  list?: true | undefined;
14
+ case?: "lower" | "upper" | undefined;
14
15
  events?: string[] | undefined;
15
16
  }>;
16
17
  /** The identifier shape that `gitHubIssueResource` builds. */
@@ -26,13 +26,15 @@ export declare const GITHUB_PULL_REQUEST_SUGGESTED_EVENTS: readonly ["pull_reque
26
26
  * Exact values GitHub may set on pull request event data. Missing keys do not
27
27
  * match. The opener and author values load in
28
28
  * `webhooks/pull-request-match-data.ts` for every pull request event. The
29
- * pull request comment webhook has no head branch.
29
+ * pull request comment webhook has no head branch. A check suite result that
30
+ * GitHub links to no pull request has no `pullRequest`.
30
31
  */
31
32
  export declare const GITHUB_PULL_REQUEST_MATCH_FIELDS: Record<string, {
32
33
  kind: "boolean" | "number" | "string";
33
34
  description: string;
34
35
  enum?: string[] | undefined;
35
36
  list?: true | undefined;
37
+ case?: "lower" | "upper" | undefined;
36
38
  events?: string[] | undefined;
37
39
  }>;
38
40
  /** The identifier shape that `gitHubPullRequestResource` builds. */
@@ -1,5 +1,24 @@
1
- import type { SubscribableResource } from "@sentry/junior-plugin-api";
1
+ import { type SubscribableResource } from "@sentry/junior-plugin-api";
2
+ import { z } from "zod";
2
3
  export declare const GITHUB_RELEASE_EVENTS: readonly ["release.published"];
4
+ /**
5
+ * `tag` in event data: the trimmed tag with ASCII letters in lowercase. The
6
+ * release-source identifier has the URI-encoded tag, and the plugin
7
+ * lowercases identifiers. Encoding turns other characters into `%XX`
8
+ * escapes, so only ASCII letters change case there. This form is the same
9
+ * text, so `release/1.0` is not `release%2f1.0`, and `Ü` stays `Ü`. To turn
10
+ * an identifier into a `tag` filter, decode its tag part.
11
+ */
12
+ export declare const gitHubReleaseTagDataSchema: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
13
+ /** Exact values that every release event sets. */
14
+ export declare const GITHUB_RELEASE_MATCH_FIELDS: Record<string, {
15
+ kind: "boolean" | "number" | "string";
16
+ description: string;
17
+ enum?: string[] | undefined;
18
+ list?: true | undefined;
19
+ case?: "lower" | "upper" | undefined;
20
+ events?: string[] | undefined;
21
+ }>;
3
22
  export declare const GITHUB_RELEASE_SUGGESTED_EVENTS: string[];
4
23
  /** The identifier shape that `gitHubReleaseSourceResource` builds. */
5
24
  export declare const GITHUB_RELEASE_SOURCE_IDENTIFIER: {
@@ -0,0 +1,13 @@
1
+ import { type EventMatchFields } from "@sentry/junior-plugin-api";
2
+ import { z } from "zod";
3
+ /**
4
+ * `repo` in event data: lowercase `owner/repo`. GitHub ignores case in
5
+ * repository names, so tools accept this form.
6
+ */
7
+ export declare const gitHubRepoDataSchema: z.ZodString;
8
+ /** `commitSha` in event data: the full lowercase commit SHA. */
9
+ export declare const gitHubCommitShaDataSchema: z.ZodString;
10
+ /** Filter on the repository of an event. */
11
+ export declare function gitHubRepoMatchFields(events: readonly string[]): EventMatchFields;
12
+ /** Filter on the commit of an event. */
13
+ export declare function gitHubCommitMatchFields(events: readonly string[]): EventMatchFields;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Git identity and commit-hook setup for GitHub sandboxes.
3
3
  */
4
- import type { Actor, SandboxPrepareHookContext, User } from "@sentry/junior-plugin-api";
4
+ import type { Actor, PluginEnv, SandboxPrepareHookContext, User } from "@sentry/junior-plugin-api";
5
5
  /**
6
6
  * Build `Co-Authored-By` trailers crediting human run actors.
7
7
  *
@@ -20,6 +20,27 @@ export declare function additionalActorCoauthorTrailers(args: {
20
20
  /** Linked user for the current run actor, when already resolved. */
21
21
  currentUser?: User;
22
22
  }): string[];
23
+ /**
24
+ * Client hooks that Junior's hooks directory passes to the repository.
25
+ *
26
+ * Junior's `core.hooksPath` replaces the repository hooks directory: the
27
+ * repository's own `core.hooksPath` (husky) or `.git/hooks` (simple-git-hooks,
28
+ * Git LFS). Git would skip those hooks without these pass-through hooks.
29
+ * `prepare-commit-msg` is not in the list because Junior's own hook runs the
30
+ * repository hook first.
31
+ */
32
+ export declare const REPOSITORY_HOOK_NAMES: readonly ["applypatch-msg", "pre-applypatch", "post-applypatch", "pre-commit", "pre-merge-commit", "commit-msg", "post-commit", "pre-rebase", "post-checkout", "post-merge", "pre-push", "post-rewrite", "pre-auto-gc"];
33
+ /** Directory for Junior's Git hooks under the sandbox Junior root. */
34
+ export declare function gitHooksPath(juniorRoot: string): string;
35
+ /**
36
+ * Point Git at Junior's hooks for one command.
37
+ *
38
+ * Command env config has a higher priority than every config file, so it
39
+ * also wins over a repository `core.hooksPath` such as husky's.
40
+ */
41
+ export declare function setGitHooksPathEnv(env: PluginEnv, hooksPath: string): void;
42
+ /** Build a hook that runs the repository's own hook with the same name. */
43
+ export declare function repositoryHook(name: string): string;
23
44
  /** Build the hook that replaces model-supplied commit attribution. */
24
45
  export declare function prepareCommitMsgHook(): string;
25
46
  /** Set one global Git option inside the prepared sandbox. */
package/dist/index.js CHANGED
@@ -10,15 +10,16 @@ import {
10
10
  GITHUB_DEPLOYMENT_SUGGESTED_EVENTS,
11
11
  GITHUB_GRAPHQL_RESPONSE_BODY_LIMIT_BYTES,
12
12
  GITHUB_INSTALLATION_ID_ENV,
13
- GITHUB_ISSUE_COMMENT_MATCH_FIELDS,
14
13
  GITHUB_ISSUE_EVENTS,
15
14
  GITHUB_ISSUE_IDENTIFIER,
15
+ GITHUB_ISSUE_MATCH_FIELDS,
16
16
  GITHUB_ISSUE_SUGGESTED_EVENTS,
17
17
  GITHUB_PULL_REQUEST_EVENTS,
18
18
  GITHUB_PULL_REQUEST_IDENTIFIER,
19
19
  GITHUB_PULL_REQUEST_MATCH_FIELDS,
20
20
  GITHUB_PULL_REQUEST_SUGGESTED_EVENTS,
21
21
  GITHUB_RELEASE_EVENTS,
22
+ GITHUB_RELEASE_MATCH_FIELDS,
22
23
  GITHUB_RELEASE_SOURCE_IDENTIFIER,
23
24
  GITHUB_RELEASE_SUGGESTED_EVENTS,
24
25
  GITHUB_REPOSITORY_EVENTS,
@@ -29,12 +30,14 @@ import {
29
30
  botLoginFromEmail,
30
31
  botUserIdFromEmail,
31
32
  createPermissionCache,
33
+ definedValues,
32
34
  gitHubDeploymentSourceSubscribable,
33
35
  gitHubIssueSubscribable,
34
36
  gitHubPullRequestCreateWatch,
35
37
  gitHubPullRequestEventGuidance,
36
38
  gitHubPullRequestSubscribable,
37
39
  gitHubReleaseSourceSubscribable,
40
+ gitHubRepoDataSchema,
38
41
  gitHubRepositorySubscribable,
39
42
  githubRepositoryFromUrl,
40
43
  githubRequest,
@@ -53,7 +56,7 @@ import {
53
56
  readGrantPermissions,
54
57
  requireEnv,
55
58
  resolveUserAccount
56
- } from "./chunk-4RYMEHIK.js";
59
+ } from "./chunk-PQFFT2UO.js";
57
60
 
58
61
  // src/tool-support/attribution.ts
59
62
  var GITHUB_REQUEST_ATTRIBUTION_START = "<!-- junior-request-attribution:start -->";
@@ -3094,6 +3097,7 @@ function createGitHubTools(ctx, botEmail, pullRequestSubscription) {
3094
3097
 
3095
3098
  // src/webhooks/handler.ts
3096
3099
  import { createHmac, timingSafeEqual } from "crypto";
3100
+ import { z as z21 } from "zod";
3097
3101
 
3098
3102
  // src/issue-outcomes/store.ts
3099
3103
  import { and as and2, eq as eq2, lte, sql as sql2 } from "drizzle-orm";
@@ -3676,15 +3680,22 @@ var LOOKUPS_BY_MATCH_KEY = {
3676
3680
  openerUsername: ["opener"]
3677
3681
  };
3678
3682
  var ALL_LOOKUPS = ["authors", "opener", "openerRole"];
3683
+ var lookupDataSchema = z19.object({
3684
+ authors: z19.array(z19.string().min(1)).min(1).optional(),
3685
+ openerRole: z19.string().min(1).optional(),
3686
+ openerUsername: z19.string().min(1).optional()
3687
+ }).strict();
3688
+ function lookupData(input) {
3689
+ return lookupDataSchema.parse(definedValues(input));
3690
+ }
3679
3691
  var webhookSchema = z19.object({
3680
3692
  repository: z19.object({ full_name: z19.string().min(1) })
3681
3693
  });
3682
3694
  function pullRequestNumbers(events) {
3683
3695
  const numbers = /* @__PURE__ */ new Map();
3684
3696
  for (const event of events) {
3685
- if (!event.eventType.startsWith("pull_request.")) continue;
3686
- const match = /#(\d+)$/.exec(event.identifier);
3687
- if (match) numbers.set(event.eventKey, Number(match[1]));
3697
+ const number = event.data?.pullRequest;
3698
+ if (typeof number === "number") numbers.set(event.eventKey, number);
3688
3699
  }
3689
3700
  return numbers;
3690
3701
  }
@@ -3727,7 +3738,7 @@ async function withJuniorOpeners(context, events) {
3727
3738
  } = event.data ?? {};
3728
3739
  return {
3729
3740
  ...event,
3730
- data: { ...data, ...login ? { openerUsername: login } : void 0 }
3741
+ data: { ...data, ...lookupData({ openerUsername: login || void 0 }) }
3731
3742
  };
3732
3743
  });
3733
3744
  }
@@ -3766,8 +3777,10 @@ async function withRolesAndAuthors(context, events, lookups) {
3766
3777
  ...event,
3767
3778
  data: {
3768
3779
  ...event.data,
3769
- ...role ? { openerRole: role } : void 0,
3770
- ...logins?.length ? { authors: logins } : void 0
3780
+ ...lookupData({
3781
+ authors: logins?.length ? logins : void 0,
3782
+ openerRole: role || void 0
3783
+ })
3771
3784
  }
3772
3785
  };
3773
3786
  })
@@ -3796,6 +3809,9 @@ async function withGitHubPullRequestMatchData(args) {
3796
3809
  repositoryFullName: parsed.data.repository.full_name
3797
3810
  };
3798
3811
  const keys = await args.neededMatchKeys?.({
3812
+ // Every copy sets this repo, so a broad trigger for another repo adds
3813
+ // no lazy keys.
3814
+ data: { repo: gitHubRepoDataSchema.parse(context.repositoryFullName) },
3799
3815
  eventTypes: [...new Set(pullRequestEvents.map((e) => e.eventType))],
3800
3816
  identifiers: [...new Set(pullRequestEvents.map((e) => e.identifier))]
3801
3817
  }) ?? [];
@@ -3980,19 +3996,17 @@ function webhookInstallationId(body) {
3980
3996
  }
3981
3997
  return parseInstallationId(installation.id);
3982
3998
  }
3999
+ var feedbackTargetSchema = z21.object({
4000
+ commentId: z21.number(),
4001
+ commentKind: z21.enum(["conversation", "review"]),
4002
+ repo: z21.string().min(1)
4003
+ });
3983
4004
  function pullRequestFeedbackTarget(events) {
3984
4005
  const event = events.find(
3985
4006
  (candidate) => candidate.eventType === "pull_request.comment.created" || candidate.eventType === "pull_request.review_comment.created"
3986
4007
  );
3987
- const data = event?.data;
3988
- if (!data || typeof data.repo !== "string" || typeof data.commentId !== "number" || data.commentKind !== "conversation" && data.commentKind !== "review") {
3989
- return void 0;
3990
- }
3991
- return {
3992
- commentId: data.commentId,
3993
- commentKind: data.commentKind,
3994
- repo: data.repo
3995
- };
4008
+ const parsed = feedbackTargetSchema.safeParse(event?.data);
4009
+ return parsed.success ? parsed.data : void 0;
3996
4010
  }
3997
4011
  function githubCodeChange(outcome, conversationIds) {
3998
4012
  return {
@@ -4209,8 +4223,27 @@ function createGitHubWebhookRoute(args) {
4209
4223
  };
4210
4224
  }
4211
4225
 
4226
+ // src/events/declarations.ts
4227
+ var NEEDS_REPO = { anyOf: ["repo"] };
4228
+ function gitHubEventDeclarations(pullRequestGuidance) {
4229
+ const declarations = {};
4230
+ for (const eventType of GITHUB_DEPLOYMENT_EVENTS) {
4231
+ declarations[eventType] = { reach: "all" };
4232
+ }
4233
+ for (const eventType of [...GITHUB_RELEASE_EVENTS, ...GITHUB_ISSUE_EVENTS]) {
4234
+ declarations[eventType] = { reach: NEEDS_REPO };
4235
+ }
4236
+ for (const eventType of GITHUB_PULL_REQUEST_EVENTS) {
4237
+ const declaration = { reach: NEEDS_REPO };
4238
+ const guidance = pullRequestGuidance[eventType];
4239
+ if (guidance) declaration.guidance = guidance;
4240
+ declarations[eventType] = declaration;
4241
+ }
4242
+ return declarations;
4243
+ }
4244
+
4212
4245
  // src/webhooks/installation-requests.ts
4213
- import { z as z21 } from "zod";
4246
+ import { z as z22 } from "zod";
4214
4247
  function splitRepository(fullName, label) {
4215
4248
  const [owner, name, ...extra] = fullName.split("/");
4216
4249
  if (!owner || !name || extra.length > 0) {
@@ -4255,9 +4288,9 @@ async function markPullRequestFeedbackReviewing(env, target) {
4255
4288
  }
4256
4289
  );
4257
4290
  }
4258
- var repositoryPermissionSchema = z21.object({
4259
- permission: z21.string().min(1),
4260
- role_name: z21.string().optional()
4291
+ var repositoryPermissionSchema = z22.object({
4292
+ permission: z22.string().min(1),
4293
+ role_name: z22.string().optional()
4261
4294
  });
4262
4295
  var REPOSITORY_ROLE_TTL_MS = 10 * 60 * 1e3;
4263
4296
  async function loadRepositoryRole(env, cache, target) {
@@ -4289,18 +4322,18 @@ async function loadRepositoryRole(env, cache, target) {
4289
4322
  }
4290
4323
 
4291
4324
  // src/pull-request-outcomes/commit-composition.ts
4292
- import { z as z22 } from "zod";
4293
- var canonicalCommitSchema = z22.object({
4294
- authorEmail: z22.string().nullable(),
4295
- authorLogin: z22.string().nullable()
4325
+ import { z as z23 } from "zod";
4326
+ var canonicalCommitSchema = z23.object({
4327
+ authorEmail: z23.string().nullable(),
4328
+ authorLogin: z23.string().nullable()
4296
4329
  }).strict();
4297
- var providerCommitSchema = z22.object({
4298
- author: z22.object({ login: z22.string() }).passthrough().nullable(),
4299
- commit: z22.object({
4300
- author: z22.object({ email: z22.string() }).passthrough().nullable()
4330
+ var providerCommitSchema = z23.object({
4331
+ author: z23.object({ login: z23.string() }).passthrough().nullable(),
4332
+ commit: z23.object({
4333
+ author: z23.object({ email: z23.string() }).passthrough().nullable()
4301
4334
  }).passthrough()
4302
4335
  }).passthrough();
4303
- var commitPageSchema2 = z22.array(providerCommitSchema).transform(
4336
+ var commitPageSchema2 = z23.array(providerCommitSchema).transform(
4304
4337
  (commits) => commits.map(
4305
4338
  (commit) => canonicalCommitSchema.parse({
4306
4339
  authorEmail: commit.commit.author?.email ?? null,
@@ -4421,6 +4454,53 @@ function additionalActorCoauthorTrailers(args) {
4421
4454
  }
4422
4455
  return trailers;
4423
4456
  }
4457
+ var REPOSITORY_HOOK_NAMES = [
4458
+ "applypatch-msg",
4459
+ "pre-applypatch",
4460
+ "post-applypatch",
4461
+ "pre-commit",
4462
+ "pre-merge-commit",
4463
+ "commit-msg",
4464
+ "post-commit",
4465
+ "pre-rebase",
4466
+ "post-checkout",
4467
+ "post-merge",
4468
+ "pre-push",
4469
+ "post-rewrite",
4470
+ "pre-auto-gc"
4471
+ ];
4472
+ function gitHooksPath(juniorRoot) {
4473
+ return `${juniorRoot}/git-hooks`;
4474
+ }
4475
+ function setGitHooksPathEnv(env, hooksPath) {
4476
+ const index2 = Number.parseInt(env.get("GIT_CONFIG_COUNT") ?? "0", 10) || 0;
4477
+ env.set(`GIT_CONFIG_KEY_${index2}`, "core.hooksPath");
4478
+ env.set(`GIT_CONFIG_VALUE_${index2}`, hooksPath);
4479
+ env.set("GIT_CONFIG_COUNT", String(index2 + 1));
4480
+ }
4481
+ function findRepositoryHook(name) {
4482
+ return `repository_hook=""
4483
+ repository_hooks_dir=$(git config --local --type=path core.hooksPath 2>/dev/null) || repository_hooks_dir=""
4484
+ if [ -z "$repository_hooks_dir" ]; then
4485
+ git_common_dir=$(git rev-parse --git-common-dir 2>/dev/null) || git_common_dir=""
4486
+ if [ -n "$git_common_dir" ]; then
4487
+ repository_hooks_dir="$git_common_dir/hooks"
4488
+ fi
4489
+ fi
4490
+ if [ -n "$repository_hooks_dir" ] && [ -x "$repository_hooks_dir/${name}" ] && ! [ "$repository_hooks_dir/${name}" -ef "$0" ]; then
4491
+ repository_hook="$repository_hooks_dir/${name}"
4492
+ fi`;
4493
+ }
4494
+ function repositoryHook(name) {
4495
+ return `#!/usr/bin/env bash
4496
+ set -eu
4497
+
4498
+ ${findRepositoryHook(name)}
4499
+ if [ -n "$repository_hook" ]; then
4500
+ exec "$repository_hook" "$@"
4501
+ fi
4502
+ `;
4503
+ }
4424
4504
  function prepareCommitMsgHook() {
4425
4505
  return `#!/usr/bin/env bash
4426
4506
  set -eu
@@ -4430,6 +4510,12 @@ if [ -z "$message_file" ]; then
4430
4510
  exit 1
4431
4511
  fi
4432
4512
 
4513
+ # Run the repository hook first so Junior's trailers stay final.
4514
+ ${findRepositoryHook("prepare-commit-msg")}
4515
+ if [ -n "$repository_hook" ]; then
4516
+ "$repository_hook" "$@"
4517
+ fi
4518
+
4433
4519
  if [ -z "\${JUNIOR_GIT_AUTHOR_NAME:-}" ] || [ -z "\${JUNIOR_GIT_AUTHOR_EMAIL:-}" ]; then
4434
4520
  echo "GitHub plugin internal error: the host runtime did not inject the Git author identity. Do not set Git author env vars manually; report this configuration error." >&2
4435
4521
  exit 1
@@ -5560,23 +5646,21 @@ function githubPlugin(options = {}) {
5560
5646
  identifier: GITHUB_ISSUE_IDENTIFIER,
5561
5647
  supportedEvents: [...GITHUB_ISSUE_EVENTS],
5562
5648
  suggestedEvents: [...GITHUB_ISSUE_SUGGESTED_EVENTS],
5563
- matchFields: GITHUB_ISSUE_COMMENT_MATCH_FIELDS
5649
+ matchFields: GITHUB_ISSUE_MATCH_FIELDS
5564
5650
  },
5565
5651
  {
5566
5652
  type: "pull_request",
5567
5653
  identifier: GITHUB_PULL_REQUEST_IDENTIFIER,
5568
5654
  supportedEvents: [...GITHUB_PULL_REQUEST_EVENTS],
5569
5655
  suggestedEvents: [...GITHUB_PULL_REQUEST_SUGGESTED_EVENTS],
5570
- matchFields: GITHUB_PULL_REQUEST_MATCH_FIELDS,
5571
- guidance: gitHubPullRequestEventGuidance(
5572
- options.pullRequestEvents?.guidance
5573
- )
5656
+ matchFields: GITHUB_PULL_REQUEST_MATCH_FIELDS
5574
5657
  },
5575
5658
  {
5576
5659
  type: "release_source",
5577
5660
  identifier: GITHUB_RELEASE_SOURCE_IDENTIFIER,
5578
5661
  supportedEvents: [...GITHUB_RELEASE_EVENTS],
5579
- suggestedEvents: [...GITHUB_RELEASE_SUGGESTED_EVENTS]
5662
+ suggestedEvents: [...GITHUB_RELEASE_SUGGESTED_EVENTS],
5663
+ matchFields: GITHUB_RELEASE_MATCH_FIELDS
5580
5664
  },
5581
5665
  {
5582
5666
  type: "repository",
@@ -5585,14 +5669,14 @@ function githubPlugin(options = {}) {
5585
5669
  suggestedEvents: [...GITHUB_REPOSITORY_SUGGESTED_EVENTS],
5586
5670
  matchFields: mergeEventMatchFields(
5587
5671
  GITHUB_DEPLOYMENT_MATCH_FIELDS,
5588
- GITHUB_ISSUE_COMMENT_MATCH_FIELDS,
5672
+ GITHUB_ISSUE_MATCH_FIELDS,
5589
5673
  GITHUB_PULL_REQUEST_MATCH_FIELDS
5590
- ),
5591
- guidance: gitHubPullRequestEventGuidance(
5592
- options.pullRequestEvents?.guidance
5593
5674
  )
5594
5675
  }
5595
5676
  ],
5677
+ events: gitHubEventDeclarations(
5678
+ gitHubPullRequestEventGuidance(options.pullRequestEvents?.guidance)
5679
+ ),
5596
5680
  isEnabled: () => Boolean(readEnv("GITHUB_WEBHOOK_SECRET")),
5597
5681
  normalizeIdentifier: (identifier) => identifier.toLowerCase()
5598
5682
  },
@@ -5759,12 +5843,19 @@ function githubPlugin(options = {}) {
5759
5843
  },
5760
5844
  workspacePrepare: prepareWorkspace,
5761
5845
  async sandboxPrepare(ctx) {
5762
- const hooksPath = `${ctx.sandbox.juniorRoot}/git-hooks`;
5846
+ const hooksPath = gitHooksPath(ctx.sandbox.juniorRoot);
5763
5847
  await ctx.sandbox.writeFile({
5764
5848
  path: `${hooksPath}/prepare-commit-msg`,
5765
5849
  mode: 493,
5766
5850
  content: prepareCommitMsgHook()
5767
5851
  });
5852
+ for (const name of REPOSITORY_HOOK_NAMES) {
5853
+ await ctx.sandbox.writeFile({
5854
+ path: `${hooksPath}/${name}`,
5855
+ mode: 493,
5856
+ content: repositoryHook(name)
5857
+ });
5858
+ }
5768
5859
  await configureGit(ctx, "core.hooksPath", hooksPath);
5769
5860
  await configureGit(ctx, "commit.gpgsign", "false");
5770
5861
  await configureGit(ctx, "credential.helper", "");
@@ -5787,6 +5878,7 @@ function githubPlugin(options = {}) {
5787
5878
  ctx.env.set("JUNIOR_GIT_AUTHOR_EMAIL", botEmail);
5788
5879
  ctx.env.set("GIT_COMMITTER_NAME", botName);
5789
5880
  ctx.env.set("GIT_COMMITTER_EMAIL", botEmail);
5881
+ setGitHooksPathEnv(ctx.env, gitHooksPath(ctx.juniorRoot));
5790
5882
  let currentUser;
5791
5883
  if (ctx.actor) {
5792
5884
  try {
package/dist/testing.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  normalizeGitHubEvents
3
- } from "./chunk-4RYMEHIK.js";
3
+ } from "./chunk-PQFFT2UO.js";
4
4
  export {
5
5
  normalizeGitHubEvents
6
6
  };
@@ -52,6 +52,9 @@ export declare function selectFailingChecks(checkRuns: unknown, options?: {
52
52
  export declare function normalizeCheckSuiteEvents(deliveryId: string, body: unknown, options?: GitHubCheckSuiteFacts): EventInput[];
53
53
  /** Identifiers and event types one completed check suite may publish. */
54
54
  export declare function parseCheckSuitePublishTargets(body: unknown): {
55
+ data: {
56
+ repo: string;
57
+ };
55
58
  eventTypes: string[];
56
59
  identifiers: string[];
57
60
  } | undefined;
@@ -1,7 +1,13 @@
1
1
  /**
2
- * Event key and target helpers shared by the GitHub webhook normalizers.
2
+ * Event data, event key, and target helpers shared by the GitHub webhook
3
+ * normalizers.
3
4
  */
4
5
  import type { EventInput } from "@sentry/junior-plugin-api";
6
+ /**
7
+ * Drop missing values from event data. A filter on a value that GitHub did not
8
+ * send then does not match.
9
+ */
10
+ export declare function definedValues(data: Record<string, unknown>): Record<string, unknown>;
5
11
  /** Build the event key for one event type from one webhook delivery. */
6
12
  export declare function gitHubEventKey(deliveryId: string, eventType: string): string;
7
13
  /**
@@ -1,13 +1,19 @@
1
1
  import type { CodeChangePublisher, PluginConversationAnnotations, PluginLogger, PluginRoute, EventPublisher } from "@sentry/junior-plugin-api";
2
+ import { z } from "zod";
2
3
  import type { GitHubDb } from "../db/database.js";
3
4
  import type { GitHubPullRequestCommitComposition } from "../db/schema.js";
4
5
  import { type GitHubRoleTarget } from "./pull-request-match-data.js";
5
6
  import { type GitHubCommitPageLoader, type GitHubPullRequestTarget } from "./pull-request-people.js";
6
- interface FeedbackTarget {
7
- commentId: number;
8
- commentKind: "conversation" | "review";
9
- repo: string;
10
- }
7
+ /** The pull request comment data that the feedback reaction needs. */
8
+ declare const feedbackTargetSchema: z.ZodObject<{
9
+ commentId: z.ZodNumber;
10
+ commentKind: z.ZodEnum<{
11
+ conversation: "conversation";
12
+ review: "review";
13
+ }>;
14
+ repo: z.ZodString;
15
+ }, z.core.$strip>;
16
+ type FeedbackTarget = z.output<typeof feedbackTargetSchema>;
11
17
  /** Create the public, signed GitHub webhook route owned by the plugin. */
12
18
  export declare function createGitHubWebhookRoute(args: {
13
19
  annotations: PluginConversationAnnotations;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior-github",
3
- "version": "0.265.0",
3
+ "version": "0.267.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -32,7 +32,7 @@
32
32
  "drizzle-orm": "^0.45.2",
33
33
  "marked": "^18.1.2",
34
34
  "zod": "^4.5.4",
35
- "@sentry/junior-plugin-api": "0.265.0"
35
+ "@sentry/junior-plugin-api": "0.267.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@oxlint/plugins": "1.79.0",