@gitkraken/core-gitlens 0.40.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.
- package/CHANGELOG.md +14 -1
- package/dist/git/models/pullRequest.d.ts +55 -1
- package/dist/git/models/pullRequest.js +5 -1
- package/dist/git/models/pullRequest.js.map +1 -1
- package/dist/git/models/pullRequestActivity.d.ts +55 -0
- package/dist/git/models/pullRequestActivity.js +0 -0
- package/dist/git/utils/pullRequest.utils.js +3 -1
- package/dist/git/utils/pullRequest.utils.js.map +1 -1
- package/dist/git/watching/worktreeSummary.d.ts +1 -0
- package/dist/git/watching/worktreeSummary.js +34 -2
- package/dist/git/watching/worktreeSummary.js.map +1 -1
- package/dist/plus/git-github/api/aliasedQuery.d.ts +19 -0
- package/dist/plus/git-github/api/aliasedQuery.js +21 -0
- package/dist/plus/git-github/api/aliasedQuery.js.map +1 -0
- package/dist/plus/git-github/api/cancellation.d.ts +4 -0
- package/dist/plus/git-github/api/cancellation.js +9 -0
- package/dist/plus/git-github/api/cancellation.js.map +1 -0
- package/dist/plus/git-github/api/checkRunLogs.d.ts +31 -0
- package/dist/plus/git-github/api/checkRunLogs.js +252 -0
- package/dist/plus/git-github/api/checkRunLogs.js.map +1 -0
- package/dist/plus/git-github/api/checkRuns.d.ts +26 -0
- package/dist/plus/git-github/api/checkRuns.js +191 -0
- package/dist/plus/git-github/api/checkRuns.js.map +1 -0
- package/dist/plus/git-github/api/github.d.ts +21 -2
- package/dist/plus/git-github/api/github.js +162 -37
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/api/pullRequestActivity.d.ts +19 -0
- package/dist/plus/git-github/api/pullRequestActivity.js +355 -0
- package/dist/plus/git-github/api/pullRequestActivity.js.map +1 -0
- package/dist/plus/git-github/models.d.ts +100 -4
- package/dist/plus/git-github/models.js +135 -3
- package/dist/plus/git-github/models.js.map +1 -1
- package/dist/plus/integrations/fieldPresence.d.ts +10 -5
- package/dist/plus/integrations/fieldPresence.js +46 -25
- package/dist/plus/integrations/fieldPresence.js.map +1 -1
- package/dist/plus/integrations/index.d.ts +4 -1
- package/dist/plus/integrations/index.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +24 -0
- package/dist/plus/integrations/integrationService.js +8 -0
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +77 -0
- package/dist/plus/integrations/models/gitHostIntegration.d.ts +31 -1
- package/dist/plus/integrations/models/gitHostIntegration.js +68 -0
- package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
- package/dist/plus/integrations/models/integration.d.ts +21 -2
- package/dist/plus/integrations/models/integration.js +20 -1
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/providers/github.d.ts +13 -2
- package/dist/plus/integrations/providers/github.js +65 -5
- package/dist/plus/integrations/providers/github.js.map +1 -1
- package/dist/plus/integrations/providers/issueSorts.d.ts +1 -0
- package/dist/plus/integrations/reads/drains.d.ts +1 -0
- package/dist/plus/integrations/reads/etag.js +20 -5
- package/dist/plus/integrations/reads/etag.js.map +1 -1
- package/dist/plus/integrations/reads/pullRequestActivity.d.ts +36 -0
- package/dist/plus/integrations/reads/pullRequestActivity.js +103 -0
- package/dist/plus/integrations/reads/pullRequestActivity.js.map +1 -0
- package/dist/plus/integrations/reads/pullRequestBatch.d.ts +4 -1
- package/dist/plus/integrations/reads/pullRequestBatch.js +5 -2
- package/dist/plus/integrations/reads/pullRequestBatch.js.map +1 -1
- package/dist/plus/integrations/reads/pullRequestBranches.d.ts +2 -0
- package/dist/plus/integrations/reads/pullRequestBranches.js +2 -1
- package/dist/plus/integrations/reads/pullRequestBranches.js.map +1 -1
- package/dist/plus/integrations/reads/pullRequestCheckLogs.d.ts +27 -0
- package/dist/plus/integrations/reads/pullRequestCheckLogs.js +92 -0
- package/dist/plus/integrations/reads/pullRequestCheckLogs.js.map +1 -0
- package/docs/integrations.md +96 -5
- package/package.json +1 -1
|
@@ -6,13 +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";
|
|
15
16
|
import { GitHubIssueDelete, GitHubIssueWrite, IssueWriteResult } from "./issueWrites.js";
|
|
17
|
+
import { GitHubPullRequestActivityTarget } from "./pullRequestActivity.js";
|
|
16
18
|
import { GitHubTokenInfo } from "./token.js";
|
|
17
19
|
import { Endpoints } from "@octokit/types";
|
|
18
20
|
//#region ../plus/git-github/src/api/github.d.ts
|
|
@@ -478,7 +480,22 @@ export declare class GitHubApi {
|
|
|
478
480
|
baseUrl?: string;
|
|
479
481
|
avatarSize?: number;
|
|
480
482
|
mergeQueue?: boolean;
|
|
483
|
+
checkRuns?: boolean;
|
|
484
|
+
checkRunsRequired?: boolean;
|
|
481
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>[]>;
|
|
482
499
|
/**
|
|
483
500
|
* The cheap check behind the batch reads' etags: {@link getPullRequestsBatch}'s aliased document, slot rules and
|
|
484
501
|
* failure handling, selecting only a pull request's change state ({@link gqlPullRequestEtagFragment}) — plus
|
|
@@ -496,6 +513,7 @@ export declare class GitHubApi {
|
|
|
496
513
|
baseUrl?: string;
|
|
497
514
|
etagIncludes?: readonly GitHubPullRequestEtagInclude[];
|
|
498
515
|
mergeQueue?: boolean;
|
|
516
|
+
checkRuns?: boolean;
|
|
499
517
|
}, cancellation?: AbortSignal): Promise<PromiseSettledResult<GitHubPullRequestEtagNode | undefined>[]>;
|
|
500
518
|
/**
|
|
501
519
|
* The issue twin of {@link getPullRequestsEtagFieldsBatch}: {@link getIssuesBatch}'s aliased document, slot
|
|
@@ -552,6 +570,7 @@ export declare class GitHubApi {
|
|
|
552
570
|
avatarSize?: number;
|
|
553
571
|
limit: number;
|
|
554
572
|
mergeQueue?: boolean;
|
|
573
|
+
checkRuns?: boolean;
|
|
555
574
|
}, cancellation?: AbortSignal): Promise<PromiseSettledResult<{
|
|
556
575
|
pullRequests: PullRequest[][];
|
|
557
576
|
truncated: boolean;
|
|
@@ -19,8 +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";
|
|
23
27
|
import { mutateGitHubIssue } from "./issueWrites.js";
|
|
28
|
+
import { readGitHubPullRequestActivity } from "./pullRequestActivity.js";
|
|
24
29
|
import { toGitHubPullRequestSearchFacets } from "./pullRequestSearchQuery.js";
|
|
25
30
|
import * as l10n from "@vscode/l10n";
|
|
26
31
|
import { GraphqlResponseError, graphql } from "@octokit/graphql";
|
|
@@ -456,20 +461,8 @@ reactions(content: THUMBS_UP) {
|
|
|
456
461
|
totalCount
|
|
457
462
|
}
|
|
458
463
|
` };
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
* is null and every error on it is NOT_FOUND; a rejection when a node arrived with an error, or on any other error
|
|
462
|
-
* (even a NOT_FOUND nested under the node), since neither is trustworthy; `undefined` when the alias has no errors.
|
|
463
|
-
*/
|
|
464
|
-
function getAliasErrorVerdict(errors, alias, node) {
|
|
465
|
-
const aliasErrors = errors.filter((e) => e.path?.[0] === alias);
|
|
466
|
-
if (aliasErrors.length === 0) return void 0;
|
|
467
|
-
if (node == null && aliasErrors.every((e) => e.type === "NOT_FOUND")) return "absent";
|
|
468
|
-
const primary = aliasErrors.find((e) => e.type !== "NOT_FOUND") ?? aliasErrors[0];
|
|
469
|
-
return {
|
|
470
|
-
status: "rejected",
|
|
471
|
-
reason: new Error(primary.message)
|
|
472
|
-
};
|
|
464
|
+
function isByteStream(value) {
|
|
465
|
+
return typeof value === "object" && value != null && "getReader" in value && typeof value.getReader === "function";
|
|
473
466
|
}
|
|
474
467
|
var GitHubApi = class {
|
|
475
468
|
config;
|
|
@@ -2090,7 +2083,7 @@ var GitHubApi = class {
|
|
|
2090
2083
|
return defaults;
|
|
2091
2084
|
}
|
|
2092
2085
|
handleRequestError(provider, token, ex, scope, deferFailure) {
|
|
2093
|
-
if (ex.name === "AbortError") throw
|
|
2086
|
+
if (ex.name === "AbortError") throw toCancellationError(ex);
|
|
2094
2087
|
const { accessToken, ...tokenInfo } = token;
|
|
2095
2088
|
switch (ex.status) {
|
|
2096
2089
|
case 404:
|
|
@@ -2520,6 +2513,10 @@ var GitHubApi = class {
|
|
|
2520
2513
|
if (coordinates.length === 0) return [];
|
|
2521
2514
|
const stackFragment = gqlPullRequestStackFragmentFor(options);
|
|
2522
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;
|
|
2523
2520
|
const query = `query getPullRequestsBatch(
|
|
2524
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 ")}
|
|
2525
2522
|
$avatarSize: Int
|
|
@@ -2528,7 +2525,7 @@ var GitHubApi = class {
|
|
|
2528
2525
|
pullRequest(number: $k${i}) {
|
|
2529
2526
|
${gqlPullRequestFragment}
|
|
2530
2527
|
${stackFragment}
|
|
2531
|
-
${mergeQueueFragment}
|
|
2528
|
+
${mergeQueueFragment}${checkRuns != null ? gqlPullRequestCheckRunsFragment(checkRuns, i) : ""}
|
|
2532
2529
|
}
|
|
2533
2530
|
}`).join("\n ")}
|
|
2534
2531
|
}`;
|
|
@@ -2544,10 +2541,20 @@ var GitHubApi = class {
|
|
|
2544
2541
|
try {
|
|
2545
2542
|
const rsp = await this.graphql(provider, token, query, variables, scope, cancellation, "aliased");
|
|
2546
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;
|
|
2547
2554
|
return coordinates.map((c, i) => {
|
|
2548
2555
|
const alias = `p${i}`;
|
|
2549
2556
|
const node = rsp.data[alias]?.pullRequest;
|
|
2550
|
-
const verdict = getAliasErrorVerdict(rsp.errors, alias, node);
|
|
2557
|
+
const verdict = getAliasErrorVerdict(node != null ? errors : rsp.errors, alias, node);
|
|
2551
2558
|
if (verdict === "absent") return {
|
|
2552
2559
|
status: "fulfilled",
|
|
2553
2560
|
value: void 0
|
|
@@ -2560,7 +2567,7 @@ var GitHubApi = class {
|
|
|
2560
2567
|
try {
|
|
2561
2568
|
return {
|
|
2562
2569
|
status: "fulfilled",
|
|
2563
|
-
value: fromGitHubPullRequest(node, provider)
|
|
2570
|
+
value: fromGitHubPullRequest(node, provider, void 0, checkContexts?.[i])
|
|
2564
2571
|
};
|
|
2565
2572
|
} catch (ex) {
|
|
2566
2573
|
scope?.warn(`failed to map pull request; ${c.owner}/${c.repo}#${c.number}, ex=${ex}`);
|
|
@@ -2574,6 +2581,54 @@ var GitHubApi = class {
|
|
|
2574
2581
|
throw this.handleException(ex, provider, scope);
|
|
2575
2582
|
}
|
|
2576
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
|
+
}
|
|
2577
2632
|
/**
|
|
2578
2633
|
* The cheap check behind the batch reads' etags: {@link getPullRequestsBatch}'s aliased document, slot rules and
|
|
2579
2634
|
* failure handling, selecting only a pull request's change state ({@link gqlPullRequestEtagFragment}) — plus
|
|
@@ -2588,6 +2643,7 @@ var GitHubApi = class {
|
|
|
2588
2643
|
if (coordinates.length === 0) return [];
|
|
2589
2644
|
const includeFragments = Array.from(new Set(options?.etagIncludes), (include) => gqlPullRequestEtagIncludeFragments[include]);
|
|
2590
2645
|
const mergeQueueFragment = gqlPullRequestEtagMergeQueueFragmentFor(options, this.config);
|
|
2646
|
+
const checkRuns = options?.checkRuns === true;
|
|
2591
2647
|
const query = `query getPullRequestsEtagFieldsBatch(
|
|
2592
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 ")}
|
|
2593
2649
|
) {
|
|
@@ -2595,7 +2651,7 @@ var GitHubApi = class {
|
|
|
2595
2651
|
pullRequest(number: $k${i}) {
|
|
2596
2652
|
${gqlPullRequestEtagFragment}
|
|
2597
2653
|
${mergeQueueFragment}
|
|
2598
|
-
${includeFragments.join("")}
|
|
2654
|
+
${includeFragments.join("")}${checkRuns ? gqlPullRequestCheckRunsFragment(etagCheckContextsFragment, i) : ""}
|
|
2599
2655
|
}
|
|
2600
2656
|
}`).join("\n ")}
|
|
2601
2657
|
}`;
|
|
@@ -2608,18 +2664,36 @@ var GitHubApi = class {
|
|
|
2608
2664
|
try {
|
|
2609
2665
|
const rsp = await this.graphql(provider, token, query, variables, scope, cancellation, "aliased");
|
|
2610
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;
|
|
2611
2677
|
return coordinates.map((_, i) => {
|
|
2612
2678
|
const alias = `p${i}`;
|
|
2613
2679
|
const node = rsp.data[alias]?.pullRequest;
|
|
2614
|
-
const verdict = getAliasErrorVerdict(rsp.errors, alias, node);
|
|
2680
|
+
const verdict = getAliasErrorVerdict(node != null ? errors : rsp.errors, alias, node);
|
|
2615
2681
|
if (verdict === "absent") return {
|
|
2616
2682
|
status: "fulfilled",
|
|
2617
2683
|
value: void 0
|
|
2618
2684
|
};
|
|
2619
2685
|
if (verdict != null) return verdict;
|
|
2686
|
+
if (node == null) return {
|
|
2687
|
+
status: "fulfilled",
|
|
2688
|
+
value: void 0
|
|
2689
|
+
};
|
|
2690
|
+
const read = checkContexts?.[i];
|
|
2620
2691
|
return {
|
|
2621
2692
|
status: "fulfilled",
|
|
2622
|
-
value:
|
|
2693
|
+
value: read != null ? {
|
|
2694
|
+
...node,
|
|
2695
|
+
checkRuns: read
|
|
2696
|
+
} : node
|
|
2623
2697
|
};
|
|
2624
2698
|
});
|
|
2625
2699
|
} catch (ex) {
|
|
@@ -2709,6 +2783,10 @@ var GitHubApi = class {
|
|
|
2709
2783
|
if (queries.length === 0) return [];
|
|
2710
2784
|
const stackFragment = gqlPullRequestStackFragmentFor(options);
|
|
2711
2785
|
const mergeQueueFragment = gqlPullRequestMergeQueueFragmentFor(options, this.config);
|
|
2786
|
+
const checkRuns = options.checkRuns === true ? {
|
|
2787
|
+
kind: "row",
|
|
2788
|
+
readsRequired: false
|
|
2789
|
+
} : void 0;
|
|
2712
2790
|
const query = `query getPullRequestsForBranches(
|
|
2713
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 ")}
|
|
2714
2792
|
$limit: Int!
|
|
@@ -2720,7 +2798,7 @@ var GitHubApi = class {
|
|
|
2720
2798
|
nodes {
|
|
2721
2799
|
${gqlPullRequestFragment}
|
|
2722
2800
|
${stackFragment}
|
|
2723
|
-
${mergeQueueFragment}
|
|
2801
|
+
${mergeQueueFragment}${checkRuns != null ? gqlPullRequestCheckRunsFragment(checkRuns, i) : ""}
|
|
2724
2802
|
headRepositoryOwner {
|
|
2725
2803
|
login
|
|
2726
2804
|
}
|
|
@@ -2741,10 +2819,11 @@ var GitHubApi = class {
|
|
|
2741
2819
|
try {
|
|
2742
2820
|
const rsp = await this.graphql(provider, token, query, variables, scope, cancellation, "aliased");
|
|
2743
2821
|
if (rsp?.data == null) throw new Error("GitHub returned no data for the pull requests by branch");
|
|
2744
|
-
|
|
2822
|
+
const errors = checkRuns != null ? rsp.errors.filter((e) => !isCheckContextsError(e)) : rsp.errors;
|
|
2823
|
+
const answers = queries.map((t, i) => {
|
|
2745
2824
|
const alias = `b${i}`;
|
|
2746
2825
|
const repository = rsp.data[alias];
|
|
2747
|
-
const verdict = getAliasErrorVerdict(rsp.errors, alias, repository);
|
|
2826
|
+
const verdict = getAliasErrorVerdict(repository != null ? errors : rsp.errors, alias, repository);
|
|
2748
2827
|
if (verdict != null && verdict !== "absent") return verdict;
|
|
2749
2828
|
if (repository == null) return {
|
|
2750
2829
|
status: "fulfilled",
|
|
@@ -2758,25 +2837,63 @@ var GitHubApi = class {
|
|
|
2758
2837
|
status: "rejected",
|
|
2759
2838
|
reason: /* @__PURE__ */ new Error(`GitHub returned no pull requests for ${t.owner}/${t.repo}:${t.branch}`)
|
|
2760
2839
|
};
|
|
2761
|
-
const returned =
|
|
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
|
+
});
|
|
2762
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;
|
|
2763
2883
|
try {
|
|
2764
2884
|
const mapped = /* @__PURE__ */ new Map();
|
|
2765
2885
|
return {
|
|
2766
2886
|
status: "fulfilled",
|
|
2767
2887
|
value: {
|
|
2768
|
-
pullRequests:
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
}).sort((a, b) => b.updatedDate.getTime() - a.updatedDate.getTime());
|
|
2778
|
-
}),
|
|
2779
|
-
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
|
|
2780
2897
|
}
|
|
2781
2898
|
};
|
|
2782
2899
|
} catch (ex) {
|
|
@@ -3796,6 +3913,14 @@ __decorate([trace({ args: (provider, token) => ({
|
|
|
3796
3913
|
provider: provider.name,
|
|
3797
3914
|
token: `<token:${token.microHash}>`
|
|
3798
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);
|
|
3799
3924
|
__decorate([trace({ args: (provider, token) => ({
|
|
3800
3925
|
provider: provider.name,
|
|
3801
3926
|
token: `<token:${token.microHash}>`
|