@gitkraken/core-gitlens 0.39.0 → 0.41.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.
Files changed (82) hide show
  1. package/CHANGELOG.md +29 -1
  2. package/dist/git/models/pullRequest.d.ts +55 -1
  3. package/dist/git/models/pullRequest.js +5 -1
  4. package/dist/git/models/pullRequest.js.map +1 -1
  5. package/dist/git/models/pullRequestActivity.d.ts +55 -0
  6. package/dist/git/models/pullRequestActivity.js +0 -0
  7. package/dist/git/utils/pullRequest.utils.js +3 -1
  8. package/dist/git/utils/pullRequest.utils.js.map +1 -1
  9. package/dist/git/watching/worktreeSummary.d.ts +1 -0
  10. package/dist/git/watching/worktreeSummary.js +34 -2
  11. package/dist/git/watching/worktreeSummary.js.map +1 -1
  12. package/dist/plus/git-github/api/aliasedQuery.d.ts +19 -0
  13. package/dist/plus/git-github/api/aliasedQuery.js +21 -0
  14. package/dist/plus/git-github/api/aliasedQuery.js.map +1 -0
  15. package/dist/plus/git-github/api/cancellation.d.ts +4 -0
  16. package/dist/plus/git-github/api/cancellation.js +9 -0
  17. package/dist/plus/git-github/api/cancellation.js.map +1 -0
  18. package/dist/plus/git-github/api/checkRunLogs.d.ts +31 -0
  19. package/dist/plus/git-github/api/checkRunLogs.js +252 -0
  20. package/dist/plus/git-github/api/checkRunLogs.js.map +1 -0
  21. package/dist/plus/git-github/api/checkRuns.d.ts +26 -0
  22. package/dist/plus/git-github/api/checkRuns.js +191 -0
  23. package/dist/plus/git-github/api/checkRuns.js.map +1 -0
  24. package/dist/plus/git-github/api/github.d.ts +25 -2
  25. package/dist/plus/git-github/api/github.js +169 -37
  26. package/dist/plus/git-github/api/github.js.map +1 -1
  27. package/dist/plus/git-github/api/issueWrites.d.ts +51 -0
  28. package/dist/plus/git-github/api/issueWrites.js +192 -0
  29. package/dist/plus/git-github/api/issueWrites.js.map +1 -0
  30. package/dist/plus/git-github/api/pullRequestActivity.d.ts +19 -0
  31. package/dist/plus/git-github/api/pullRequestActivity.js +355 -0
  32. package/dist/plus/git-github/api/pullRequestActivity.js.map +1 -0
  33. package/dist/plus/git-github/models.d.ts +100 -4
  34. package/dist/plus/git-github/models.js +135 -3
  35. package/dist/plus/git-github/models.js.map +1 -1
  36. package/dist/plus/integrations/authentication/rejectedTokenTracker.d.ts +7 -8
  37. package/dist/plus/integrations/authentication/rejectedTokenTracker.js +7 -8
  38. package/dist/plus/integrations/authentication/rejectedTokenTracker.js.map +1 -1
  39. package/dist/plus/integrations/fieldPresence.d.ts +10 -5
  40. package/dist/plus/integrations/fieldPresence.js +46 -25
  41. package/dist/plus/integrations/fieldPresence.js.map +1 -1
  42. package/dist/plus/integrations/index.d.ts +6 -2
  43. package/dist/plus/integrations/index.js.map +1 -1
  44. package/dist/plus/integrations/integrationService.d.ts +31 -1
  45. package/dist/plus/integrations/integrationService.js +45 -0
  46. package/dist/plus/integrations/integrationService.js.map +1 -1
  47. package/dist/plus/integrations/manager.d.ts +86 -0
  48. package/dist/plus/integrations/models/gitHostIntegration.d.ts +31 -1
  49. package/dist/plus/integrations/models/gitHostIntegration.js +68 -0
  50. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  51. package/dist/plus/integrations/models/integration.d.ts +26 -5
  52. package/dist/plus/integrations/models/integration.js +35 -10
  53. package/dist/plus/integrations/models/integration.js.map +1 -1
  54. package/dist/plus/integrations/providers/asana.d.ts +4 -5
  55. package/dist/plus/integrations/providers/asana.js +53 -12
  56. package/dist/plus/integrations/providers/asana.js.map +1 -1
  57. package/dist/plus/integrations/providers/github.d.ts +18 -3
  58. package/dist/plus/integrations/providers/github.js +90 -5
  59. package/dist/plus/integrations/providers/github.js.map +1 -1
  60. package/dist/plus/integrations/providers/linear.js +6 -6
  61. package/dist/plus/integrations/providers/linear.js.map +1 -1
  62. package/dist/plus/integrations/providers/models.d.ts +6 -15
  63. package/dist/plus/integrations/providers/models.js +1 -1
  64. package/dist/plus/integrations/providers/models.js.map +1 -1
  65. package/dist/plus/integrations/providers/providersApi.d.ts +1 -6
  66. package/dist/plus/integrations/providers/providersApi.js.map +1 -1
  67. package/dist/plus/integrations/reads/etag.js +20 -5
  68. package/dist/plus/integrations/reads/etag.js.map +1 -1
  69. package/dist/plus/integrations/reads/pullRequestActivity.d.ts +36 -0
  70. package/dist/plus/integrations/reads/pullRequestActivity.js +103 -0
  71. package/dist/plus/integrations/reads/pullRequestActivity.js.map +1 -0
  72. package/dist/plus/integrations/reads/pullRequestBatch.d.ts +4 -1
  73. package/dist/plus/integrations/reads/pullRequestBatch.js +5 -2
  74. package/dist/plus/integrations/reads/pullRequestBatch.js.map +1 -1
  75. package/dist/plus/integrations/reads/pullRequestBranches.d.ts +2 -0
  76. package/dist/plus/integrations/reads/pullRequestBranches.js +2 -1
  77. package/dist/plus/integrations/reads/pullRequestBranches.js.map +1 -1
  78. package/dist/plus/integrations/reads/pullRequestCheckLogs.d.ts +27 -0
  79. package/dist/plus/integrations/reads/pullRequestCheckLogs.js +92 -0
  80. package/dist/plus/integrations/reads/pullRequestCheckLogs.js.map +1 -0
  81. package/docs/integrations.md +115 -5
  82. package/package.json +2 -2
@@ -6,12 +6,15 @@ import { Provider } from "../../../git/models/remoteProvider.js";
6
6
  import { GitUser } from "../../../git/models/user.js";
7
7
  import { IssueOrPullRequest, IssueOrPullRequestState } from "../../../git/models/issueOrPullRequest.js";
8
8
  import { Issue, IssueSearchCriteria, IssueShape, IssueSorting } from "../../../git/models/issue.js";
9
- import { PullRequest, PullRequestMergeMethod, PullRequestMergeQueueActionFailureReason, PullRequestMergeQueueActionResult, PullRequestMergeQueueEntry, PullRequestSearchCriteria, PullRequestShape, PullRequestStateFilter } from "../../../git/models/pullRequest.js";
9
+ import { PullRequest, PullRequestCheckLog, PullRequestMergeMethod, PullRequestMergeQueueActionFailureReason, PullRequestMergeQueueActionResult, PullRequestMergeQueueEntry, PullRequestSearchCriteria, PullRequestShape, PullRequestStateFilter } from "../../../git/models/pullRequest.js";
10
10
  import { Account, UnidentifiedAuthor } from "../../../git/models/author.js";
11
11
  import { DefaultBranch } from "../../../git/models/defaultBranch.js";
12
+ import { PullRequestActivityPage } from "../../../git/models/pullRequestActivity.js";
12
13
  import { RepositoryMetadata } from "../../../git/models/repositoryMetadata.js";
14
+ import { GitHubBlame, GitHubBranch, GitHubCheckRunRef, GitHubCommit, GitHubCommitRef, GitHubContributor, GitHubIssueEtagInclude, GitHubIssueEtagNode, GitHubPagedResult, GitHubPullRequestEtagInclude, GitHubPullRequestEtagNode, GitHubPullRequestState, GitHubSshSigningKey, GitHubTag } from "../models.js";
13
15
  import { GitHubApiConfig } from "./config.js";
14
- import { GitHubBlame, GitHubBranch, GitHubCommit, GitHubCommitRef, GitHubContributor, GitHubIssueEtagInclude, GitHubIssueEtagNode, GitHubPagedResult, GitHubPullRequestEtagInclude, GitHubPullRequestEtagNode, GitHubPullRequestState, GitHubSshSigningKey, GitHubTag } from "../models.js";
16
+ import { GitHubIssueDelete, GitHubIssueWrite, IssueWriteResult } from "./issueWrites.js";
17
+ import { GitHubPullRequestActivityTarget } from "./pullRequestActivity.js";
15
18
  import { GitHubTokenInfo } from "./token.js";
16
19
  import { Endpoints } from "@octokit/types";
17
20
  //#region ../plus/git-github/src/api/github.d.ts
@@ -237,6 +240,9 @@ export declare class GitHubApi {
237
240
  private getEnterpriseVersion;
238
241
  private requestWithRetries;
239
242
  private delayWithAbort;
243
+ mutateIssue(provider: Provider, token: GitHubTokenInfo, input: GitHubIssueWrite | (GitHubIssueDelete & {
244
+ action: 'delete';
245
+ })): Promise<IssueWriteResult>;
240
246
  private readonly _pendingGraphQL;
241
247
  private graphql;
242
248
  private request;
@@ -474,7 +480,22 @@ export declare class GitHubApi {
474
480
  baseUrl?: string;
475
481
  avatarSize?: number;
476
482
  mergeQueue?: boolean;
483
+ checkRuns?: boolean;
484
+ checkRunsRequired?: boolean;
477
485
  }, cancellation?: AbortSignal): Promise<PromiseSettledResult<PullRequest | undefined>[]>;
486
+ private aliasedGraphql;
487
+ getCheckRunLogs(provider: Provider, token: GitHubTokenInfo, targets: readonly {
488
+ owner: string;
489
+ repo: string;
490
+ ref: GitHubCheckRunRef;
491
+ }[], options: {
492
+ baseUrl?: string;
493
+ tailLines: number;
494
+ }, cancellation?: AbortSignal): Promise<PromiseSettledResult<PullRequestCheckLog>[]>;
495
+ getPullRequestActivity(provider: Provider, token: GitHubTokenInfo, targets: readonly GitHubPullRequestActivityTarget[], options: {
496
+ baseUrl?: string;
497
+ limit: number;
498
+ }, cancellation?: AbortSignal): Promise<PromiseSettledResult<PullRequestActivityPage | undefined>[]>;
478
499
  /**
479
500
  * The cheap check behind the batch reads' etags: {@link getPullRequestsBatch}'s aliased document, slot rules and
480
501
  * failure handling, selecting only a pull request's change state ({@link gqlPullRequestEtagFragment}) — plus
@@ -492,6 +513,7 @@ export declare class GitHubApi {
492
513
  baseUrl?: string;
493
514
  etagIncludes?: readonly GitHubPullRequestEtagInclude[];
494
515
  mergeQueue?: boolean;
516
+ checkRuns?: boolean;
495
517
  }, cancellation?: AbortSignal): Promise<PromiseSettledResult<GitHubPullRequestEtagNode | undefined>[]>;
496
518
  /**
497
519
  * The issue twin of {@link getPullRequestsEtagFieldsBatch}: {@link getIssuesBatch}'s aliased document, slot
@@ -548,6 +570,7 @@ export declare class GitHubApi {
548
570
  avatarSize?: number;
549
571
  limit: number;
550
572
  mergeQueue?: boolean;
573
+ checkRuns?: boolean;
551
574
  }, cancellation?: AbortSignal): Promise<PromiseSettledResult<{
552
575
  pullRequests: PullRequest[][];
553
576
  truncated: boolean;
@@ -19,7 +19,13 @@ import { getPullRequestComparator } from "../../../git/utils/pullRequest.utils.j
19
19
  import { effectiveIssueSort, getIssueComparator } from "../../../git/utils/issue.utils.js";
20
20
  import { fromGitHubIssue, fromGitHubIssueOrPullRequestState, fromGitHubMergeQueueEntry, fromGitHubPullRequest, fromGitHubPullRequestLite } from "../models.js";
21
21
  import { githubSearchResultLimit } from "./config.js";
22
+ import { getAliasErrorVerdict } from "./aliasedQuery.js";
23
+ import { toCancellationError } from "./cancellation.js";
24
+ import { readGitHubCheckRunLogs } from "./checkRunLogs.js";
25
+ import { etagCheckContextsFragment, gqlPullRequestCheckRunsFragment, isCheckContextsError, readCheckContexts } from "./checkRuns.js";
22
26
  import { gitHubIssueSearchRelationships, toGitHubIssueSearchQualifiers, toGitHubIssueSearchScopeQualifiers, toGitHubIssueSearchSlideQualifier, toGitHubIssueSortQualifier } from "./issueSearchQuery.js";
27
+ import { mutateGitHubIssue } from "./issueWrites.js";
28
+ import { readGitHubPullRequestActivity } from "./pullRequestActivity.js";
23
29
  import { toGitHubPullRequestSearchFacets } from "./pullRequestSearchQuery.js";
24
30
  import * as l10n from "@vscode/l10n";
25
31
  import { GraphqlResponseError, graphql } from "@octokit/graphql";
@@ -455,20 +461,8 @@ reactions(content: THUMBS_UP) {
455
461
  totalCount
456
462
  }
457
463
  ` };
458
- /**
459
- * What an alias's own errors say about its slot in an {@link AliasedGraphqlResult}: `'absent'` only when its node
460
- * is null and every error on it is NOT_FOUND; a rejection when a node arrived with an error, or on any other error
461
- * (even a NOT_FOUND nested under the node), since neither is trustworthy; `undefined` when the alias has no errors.
462
- */
463
- function getAliasErrorVerdict(errors, alias, node) {
464
- const aliasErrors = errors.filter((e) => e.path?.[0] === alias);
465
- if (aliasErrors.length === 0) return void 0;
466
- if (node == null && aliasErrors.every((e) => e.type === "NOT_FOUND")) return "absent";
467
- const primary = aliasErrors.find((e) => e.type !== "NOT_FOUND") ?? aliasErrors[0];
468
- return {
469
- status: "rejected",
470
- reason: new Error(primary.message)
471
- };
464
+ function isByteStream(value) {
465
+ return typeof value === "object" && value != null && "getReader" in value && typeof value.getReader === "function";
472
466
  }
473
467
  var GitHubApi = class {
474
468
  config;
@@ -1938,6 +1932,12 @@ var GitHubApi = class {
1938
1932
  signal?.addEventListener("abort", onAbort, { once: true });
1939
1933
  });
1940
1934
  }
1935
+ async mutateIssue(provider, token, input) {
1936
+ return mutateGitHubIssue(input, (query, variables) => this.requestWithRetries(() => this.config.wrapForForcedInsecureSSL(provider.getIgnoreSSLErrors(), () => this.getDefaults(token.accessToken, graphql)(query, {
1937
+ ...variables,
1938
+ headers: { "x-github-next-global-id": "1" }
1939
+ })), graphqlReadQueryRegex.test(query), void 0, void 0));
1940
+ }
1941
1941
  _pendingGraphQL = /* @__PURE__ */ new Map();
1942
1942
  async graphql(provider, token, query, variables, scope, cancellation, allowPartialNotFound, gatewayFailures) {
1943
1943
  const { accessToken, ...tokenInfo } = token;
@@ -2083,7 +2083,7 @@ var GitHubApi = class {
2083
2083
  return defaults;
2084
2084
  }
2085
2085
  handleRequestError(provider, token, ex, scope, deferFailure) {
2086
- if (ex.name === "AbortError") throw new CancellationError(ex);
2086
+ if (ex.name === "AbortError") throw toCancellationError(ex);
2087
2087
  const { accessToken, ...tokenInfo } = token;
2088
2088
  switch (ex.status) {
2089
2089
  case 404:
@@ -2513,6 +2513,10 @@ var GitHubApi = class {
2513
2513
  if (coordinates.length === 0) return [];
2514
2514
  const stackFragment = gqlPullRequestStackFragmentFor(options);
2515
2515
  const mergeQueueFragment = gqlPullRequestMergeQueueFragmentFor(options, this.config);
2516
+ const checkRuns = options?.checkRuns === true ? {
2517
+ kind: "row",
2518
+ readsRequired: options.checkRunsRequired !== false && isGitHubDotCom(options)
2519
+ } : void 0;
2516
2520
  const query = `query getPullRequestsBatch(
2517
2521
  ${coordinates.map((_, i) => `$o${i}: String!\n\t\t\t\t$n${i}: String!\n\t\t\t\t$k${i}: Int!`).join("\n ")}
2518
2522
  $avatarSize: Int
@@ -2521,7 +2525,7 @@ var GitHubApi = class {
2521
2525
  pullRequest(number: $k${i}) {
2522
2526
  ${gqlPullRequestFragment}
2523
2527
  ${stackFragment}
2524
- ${mergeQueueFragment}
2528
+ ${mergeQueueFragment}${checkRuns != null ? gqlPullRequestCheckRunsFragment(checkRuns, i) : ""}
2525
2529
  }
2526
2530
  }`).join("\n ")}
2527
2531
  }`;
@@ -2537,10 +2541,20 @@ var GitHubApi = class {
2537
2541
  try {
2538
2542
  const rsp = await this.graphql(provider, token, query, variables, scope, cancellation, "aliased");
2539
2543
  if (rsp?.data == null) throw new Error("GitHub returned no data for the pull request batch");
2544
+ const errors = checkRuns != null ? rsp.errors.filter((e) => !isCheckContextsError(e)) : rsp.errors;
2545
+ const checkContexts = checkRuns != null ? await readCheckContexts(this.aliasedGraphql(provider, token, options?.baseUrl, scope, cancellation), checkRuns, coordinates.map((c, i) => {
2546
+ const alias = `p${i}`;
2547
+ const node = rsp.data[alias]?.pullRequest;
2548
+ return node != null && getAliasErrorVerdict(errors, alias, node) == null ? {
2549
+ number: c.number,
2550
+ commit: node.commits.nodes?.[0]?.commit,
2551
+ errorPath: [alias]
2552
+ } : void 0;
2553
+ }), rsp.errors, scope) : void 0;
2540
2554
  return coordinates.map((c, i) => {
2541
2555
  const alias = `p${i}`;
2542
2556
  const node = rsp.data[alias]?.pullRequest;
2543
- const verdict = getAliasErrorVerdict(rsp.errors, alias, node);
2557
+ const verdict = getAliasErrorVerdict(node != null ? errors : rsp.errors, alias, node);
2544
2558
  if (verdict === "absent") return {
2545
2559
  status: "fulfilled",
2546
2560
  value: void 0
@@ -2553,7 +2567,7 @@ var GitHubApi = class {
2553
2567
  try {
2554
2568
  return {
2555
2569
  status: "fulfilled",
2556
- value: fromGitHubPullRequest(node, provider)
2570
+ value: fromGitHubPullRequest(node, provider, void 0, checkContexts?.[i])
2557
2571
  };
2558
2572
  } catch (ex) {
2559
2573
  scope?.warn(`failed to map pull request; ${c.owner}/${c.repo}#${c.number}, ex=${ex}`);
@@ -2567,6 +2581,54 @@ var GitHubApi = class {
2567
2581
  throw this.handleException(ex, provider, scope);
2568
2582
  }
2569
2583
  }
2584
+ aliasedGraphql(provider, token, baseUrl, scope, cancellation) {
2585
+ return (query, variables) => this.graphql(provider, token, query, {
2586
+ ...variables,
2587
+ baseUrl
2588
+ }, scope, cancellation, "aliased");
2589
+ }
2590
+ async getCheckRunLogs(provider, token, targets, options, cancellation) {
2591
+ const scope = getScopedLogger();
2592
+ const route = (job) => ({
2593
+ owner: job.owner,
2594
+ repo: job.repo,
2595
+ job_id: job.jobId,
2596
+ baseUrl: options.baseUrl
2597
+ });
2598
+ const requestJobLog = (job, request) => this.request(provider, token, "GET /repos/{owner}/{repo}/actions/jobs/{job_id}/logs", {
2599
+ ...route(job),
2600
+ request
2601
+ }, scope, cancellation, true);
2602
+ const configFetch = this.config.fetch;
2603
+ return readGitHubCheckRunLogs({
2604
+ isWeb: this.config.isWeb,
2605
+ graphql: this.aliasedGraphql(provider, token, options.baseUrl, scope, cancellation),
2606
+ requestJobLogRedirect: async (job) => {
2607
+ const rsp = await requestJobLog(job, { redirect: "manual" });
2608
+ return {
2609
+ status: rsp.status,
2610
+ location: rsp.headers.location
2611
+ };
2612
+ },
2613
+ requestJobLogStream: async (job) => {
2614
+ const body = (await requestJobLog(job, { parseSuccessResponseBody: false })).data;
2615
+ if (body == null) return null;
2616
+ if (isByteStream(body)) return body;
2617
+ throw new Error("GitHub answered the job log without a body stream");
2618
+ },
2619
+ requestJobStatus: async (job) => {
2620
+ return (await this.request(provider, token, "GET /repos/{owner}/{repo}/actions/jobs/{job_id}", route(job), scope, cancellation, true)).data?.status;
2621
+ },
2622
+ fetchStorage: (url, init) => this.config.wrapForForcedInsecureSSL(provider.getIgnoreSSLErrors(), () => configFetch(url, {
2623
+ method: "GET",
2624
+ ...init
2625
+ }))
2626
+ }, targets, options.tailLines, scope, cancellation);
2627
+ }
2628
+ async getPullRequestActivity(provider, token, targets, options, cancellation) {
2629
+ const scope = getScopedLogger();
2630
+ return readGitHubPullRequestActivity(this.aliasedGraphql(provider, token, options.baseUrl, scope, cancellation), targets, options.limit, scope);
2631
+ }
2570
2632
  /**
2571
2633
  * The cheap check behind the batch reads' etags: {@link getPullRequestsBatch}'s aliased document, slot rules and
2572
2634
  * failure handling, selecting only a pull request's change state ({@link gqlPullRequestEtagFragment}) — plus
@@ -2581,6 +2643,7 @@ var GitHubApi = class {
2581
2643
  if (coordinates.length === 0) return [];
2582
2644
  const includeFragments = Array.from(new Set(options?.etagIncludes), (include) => gqlPullRequestEtagIncludeFragments[include]);
2583
2645
  const mergeQueueFragment = gqlPullRequestEtagMergeQueueFragmentFor(options, this.config);
2646
+ const checkRuns = options?.checkRuns === true;
2584
2647
  const query = `query getPullRequestsEtagFieldsBatch(
2585
2648
  ${coordinates.map((_, i) => `$o${i}: String!\n\t\t\t\t$n${i}: String!\n\t\t\t\t$k${i}: Int!`).join("\n ")}
2586
2649
  ) {
@@ -2588,7 +2651,7 @@ var GitHubApi = class {
2588
2651
  pullRequest(number: $k${i}) {
2589
2652
  ${gqlPullRequestEtagFragment}
2590
2653
  ${mergeQueueFragment}
2591
- ${includeFragments.join("")}
2654
+ ${includeFragments.join("")}${checkRuns ? gqlPullRequestCheckRunsFragment(etagCheckContextsFragment, i) : ""}
2592
2655
  }
2593
2656
  }`).join("\n ")}
2594
2657
  }`;
@@ -2601,18 +2664,36 @@ var GitHubApi = class {
2601
2664
  try {
2602
2665
  const rsp = await this.graphql(provider, token, query, variables, scope, cancellation, "aliased");
2603
2666
  if (rsp?.data == null) throw new Error("GitHub returned no data for the pull request etag batch");
2667
+ const errors = checkRuns ? rsp.errors.filter((e) => !isCheckContextsError(e)) : rsp.errors;
2668
+ const checkContexts = checkRuns ? await readCheckContexts(this.aliasedGraphql(provider, token, options?.baseUrl, scope, cancellation), etagCheckContextsFragment, coordinates.map((c, i) => {
2669
+ const alias = `p${i}`;
2670
+ const node = rsp.data[alias]?.pullRequest;
2671
+ return node != null && getAliasErrorVerdict(errors, alias, node) == null ? {
2672
+ number: c.number,
2673
+ commit: node.commits?.nodes?.[0]?.commit,
2674
+ errorPath: [alias]
2675
+ } : void 0;
2676
+ }), rsp.errors, scope) : void 0;
2604
2677
  return coordinates.map((_, i) => {
2605
2678
  const alias = `p${i}`;
2606
2679
  const node = rsp.data[alias]?.pullRequest;
2607
- const verdict = getAliasErrorVerdict(rsp.errors, alias, node);
2680
+ const verdict = getAliasErrorVerdict(node != null ? errors : rsp.errors, alias, node);
2608
2681
  if (verdict === "absent") return {
2609
2682
  status: "fulfilled",
2610
2683
  value: void 0
2611
2684
  };
2612
2685
  if (verdict != null) return verdict;
2686
+ if (node == null) return {
2687
+ status: "fulfilled",
2688
+ value: void 0
2689
+ };
2690
+ const read = checkContexts?.[i];
2613
2691
  return {
2614
2692
  status: "fulfilled",
2615
- value: node ?? void 0
2693
+ value: read != null ? {
2694
+ ...node,
2695
+ checkRuns: read
2696
+ } : node
2616
2697
  };
2617
2698
  });
2618
2699
  } catch (ex) {
@@ -2702,6 +2783,10 @@ var GitHubApi = class {
2702
2783
  if (queries.length === 0) return [];
2703
2784
  const stackFragment = gqlPullRequestStackFragmentFor(options);
2704
2785
  const mergeQueueFragment = gqlPullRequestMergeQueueFragmentFor(options, this.config);
2786
+ const checkRuns = options.checkRuns === true ? {
2787
+ kind: "row",
2788
+ readsRequired: false
2789
+ } : void 0;
2705
2790
  const query = `query getPullRequestsForBranches(
2706
2791
  ${queries.map((_, i) => `$o${i}: String!\n\t\t\t\t$n${i}: String!\n\t\t\t\t$h${i}: String!`).join("\n ")}
2707
2792
  $limit: Int!
@@ -2713,7 +2798,7 @@ var GitHubApi = class {
2713
2798
  nodes {
2714
2799
  ${gqlPullRequestFragment}
2715
2800
  ${stackFragment}
2716
- ${mergeQueueFragment}
2801
+ ${mergeQueueFragment}${checkRuns != null ? gqlPullRequestCheckRunsFragment(checkRuns, i) : ""}
2717
2802
  headRepositoryOwner {
2718
2803
  login
2719
2804
  }
@@ -2734,10 +2819,11 @@ var GitHubApi = class {
2734
2819
  try {
2735
2820
  const rsp = await this.graphql(provider, token, query, variables, scope, cancellation, "aliased");
2736
2821
  if (rsp?.data == null) throw new Error("GitHub returned no data for the pull requests by branch");
2737
- return queries.map((t, i) => {
2822
+ const errors = checkRuns != null ? rsp.errors.filter((e) => !isCheckContextsError(e)) : rsp.errors;
2823
+ const answers = queries.map((t, i) => {
2738
2824
  const alias = `b${i}`;
2739
2825
  const repository = rsp.data[alias];
2740
- const verdict = getAliasErrorVerdict(rsp.errors, alias, repository);
2826
+ const verdict = getAliasErrorVerdict(repository != null ? errors : rsp.errors, alias, repository);
2741
2827
  if (verdict != null && verdict !== "absent") return verdict;
2742
2828
  if (repository == null) return {
2743
2829
  status: "fulfilled",
@@ -2751,25 +2837,63 @@ var GitHubApi = class {
2751
2837
  status: "rejected",
2752
2838
  reason: /* @__PURE__ */ new Error(`GitHub returned no pull requests for ${t.owner}/${t.repo}:${t.branch}`)
2753
2839
  };
2754
- const returned = connection.nodes.filter((pr) => pr != null);
2840
+ const returned = [];
2841
+ const errorPaths = /* @__PURE__ */ new Map();
2842
+ connection.nodes.forEach((pr, index) => {
2843
+ if (pr == null) return;
2844
+ returned.push(pr);
2845
+ if (checkRuns != null) errorPaths.set(pr, [
2846
+ alias,
2847
+ "pullRequests",
2848
+ "nodes",
2849
+ index
2850
+ ]);
2851
+ });
2755
2852
  const nodes = returned.filter((pr) => pr.headRefName === t.branch);
2853
+ return {
2854
+ matches: t.headOwners.map((owner) => {
2855
+ const headOwner = owner?.toLowerCase();
2856
+ return nodes.filter((pr) => headOwner == null ? !pr.isCrossRepository : pr.isCrossRepository && pr.headRepositoryOwner?.login.toLowerCase() === headOwner);
2857
+ }),
2858
+ truncated: connection.totalCount > returned.length,
2859
+ errorPaths
2860
+ };
2861
+ });
2862
+ let checkContexts;
2863
+ if (checkRuns != null) {
2864
+ const matched = /* @__PURE__ */ new Map();
2865
+ for (const answer of answers) {
2866
+ if ("status" in answer) continue;
2867
+ for (const pr of answer.matches.flat()) {
2868
+ const errorPath = answer.errorPaths.get(pr);
2869
+ if (errorPath != null) matched.set(pr, errorPath);
2870
+ }
2871
+ }
2872
+ const rows = [...matched];
2873
+ const read = await readCheckContexts(this.aliasedGraphql(provider, token, options.baseUrl, scope, cancellation), checkRuns, rows.map(([pr, errorPath]) => ({
2874
+ number: pr.number,
2875
+ commit: pr.commits.nodes?.[0]?.commit,
2876
+ errorPath
2877
+ })), rsp.errors, scope);
2878
+ checkContexts = new Map(rows.map(([pr], i) => [pr, read[i]]));
2879
+ }
2880
+ return queries.map((t, i) => {
2881
+ const answer = answers[i];
2882
+ if ("status" in answer) return answer;
2756
2883
  try {
2757
2884
  const mapped = /* @__PURE__ */ new Map();
2758
2885
  return {
2759
2886
  status: "fulfilled",
2760
2887
  value: {
2761
- pullRequests: t.headOwners.map((owner) => {
2762
- const headOwner = owner?.toLowerCase();
2763
- return nodes.filter((pr) => headOwner == null ? !pr.isCrossRepository : pr.isCrossRepository && pr.headRepositoryOwner?.login.toLowerCase() === headOwner).map((pr) => {
2764
- let converted = mapped.get(pr);
2765
- if (converted == null) {
2766
- converted = fromGitHubPullRequest(pr, provider);
2767
- mapped.set(pr, converted);
2768
- }
2769
- return converted;
2770
- }).sort((a, b) => b.updatedDate.getTime() - a.updatedDate.getTime());
2771
- }),
2772
- truncated: connection.totalCount > returned.length
2888
+ pullRequests: answer.matches.map((matches) => matches.map((pr) => {
2889
+ let converted = mapped.get(pr);
2890
+ if (converted == null) {
2891
+ converted = fromGitHubPullRequest(pr, provider, void 0, checkContexts?.get(pr));
2892
+ mapped.set(pr, converted);
2893
+ }
2894
+ return converted;
2895
+ }).sort((a, b) => b.updatedDate.getTime() - a.updatedDate.getTime())),
2896
+ truncated: answer.truncated
2773
2897
  }
2774
2898
  };
2775
2899
  } catch (ex) {
@@ -3789,6 +3913,14 @@ __decorate([trace({ args: (provider, token) => ({
3789
3913
  provider: provider.name,
3790
3914
  token: `<token:${token.microHash}>`
3791
3915
  }) })], GitHubApi.prototype, "getPullRequestsBatch", null);
3916
+ __decorate([trace({ args: (provider, token) => ({
3917
+ provider: provider.name,
3918
+ token: `<token:${token.microHash}>`
3919
+ }) })], GitHubApi.prototype, "getCheckRunLogs", null);
3920
+ __decorate([trace({ args: (provider, token) => ({
3921
+ provider: provider.name,
3922
+ token: `<token:${token.microHash}>`
3923
+ }) })], GitHubApi.prototype, "getPullRequestActivity", null);
3792
3924
  __decorate([trace({ args: (provider, token) => ({
3793
3925
  provider: provider.name,
3794
3926
  token: `<token:${token.microHash}>`