@gitkraken/core-gitlens 0.40.0 → 0.43.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 +25 -1
- package/dist/git/models/issue.d.ts +2 -0
- package/dist/git/models/issue.js.map +1 -1
- package/dist/git/models/issueOrPullRequest.d.ts +4 -0
- package/dist/git/models/pullRequest.d.ts +57 -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 +23 -6
- package/dist/plus/git-github/api/github.js +174 -39
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/api/issueWrites.d.ts +3 -2
- package/dist/plus/git-github/api/issueWrites.js +10 -5
- package/dist/plus/git-github/api/issueWrites.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 +142 -6
- 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 +5 -2
- package/dist/plus/integrations/index.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +26 -1
- package/dist/plus/integrations/integrationService.js +22 -0
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +86 -1
- 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/azure/azure.js +20 -14
- package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
- package/dist/plus/integrations/providers/azure/models.js +7 -3
- package/dist/plus/integrations/providers/azure/models.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket/bitbucket.js +18 -13
- package/dist/plus/integrations/providers/bitbucket/bitbucket.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket/models.js +5 -2
- package/dist/plus/integrations/providers/bitbucket/models.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket-server/models.js +3 -1
- package/dist/plus/integrations/providers/bitbucket-server/models.js.map +1 -1
- package/dist/plus/integrations/providers/github.d.ts +15 -6
- package/dist/plus/integrations/providers/github.js +65 -5
- package/dist/plus/integrations/providers/github.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/gitlab.js +12 -6
- package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/models.js +5 -2
- package/dist/plus/integrations/providers/gitlab/models.js.map +1 -1
- package/dist/plus/integrations/providers/jiraIssueByKey.js +3 -1
- package/dist/plus/integrations/providers/jiraIssueByKey.js.map +1 -1
- package/dist/plus/integrations/providers/models.js +9 -4
- package/dist/plus/integrations/providers/models.js.map +1 -1
- package/dist/plus/integrations/providers/providerApiClient.js +10 -7
- package/dist/plus/integrations/providers/providerApiClient.js.map +1 -1
- package/dist/plus/integrations/providers/providersApi.js +3 -1
- package/dist/plus/integrations/providers/providersApi.js.map +1 -1
- 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 +111 -14
- package/package.json +2 -2
|
@@ -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 {
|
|
15
|
-
import {
|
|
16
|
+
import { GitHubIssueMutation, 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
|
|
@@ -238,9 +240,7 @@ export declare class GitHubApi {
|
|
|
238
240
|
private getEnterpriseVersion;
|
|
239
241
|
private requestWithRetries;
|
|
240
242
|
private delayWithAbort;
|
|
241
|
-
mutateIssue(provider: Provider, token: GitHubTokenInfo, input:
|
|
242
|
-
action: 'delete';
|
|
243
|
-
})): Promise<IssueWriteResult>;
|
|
243
|
+
mutateIssue(provider: Provider, token: GitHubTokenInfo, input: GitHubIssueMutation): Promise<IssueWriteResult>;
|
|
244
244
|
private readonly _pendingGraphQL;
|
|
245
245
|
private graphql;
|
|
246
246
|
private request;
|
|
@@ -478,7 +478,22 @@ export declare class GitHubApi {
|
|
|
478
478
|
baseUrl?: string;
|
|
479
479
|
avatarSize?: number;
|
|
480
480
|
mergeQueue?: boolean;
|
|
481
|
+
checkRuns?: boolean;
|
|
482
|
+
checkRunsRequired?: boolean;
|
|
481
483
|
}, cancellation?: AbortSignal): Promise<PromiseSettledResult<PullRequest | undefined>[]>;
|
|
484
|
+
private aliasedGraphql;
|
|
485
|
+
getCheckRunLogs(provider: Provider, token: GitHubTokenInfo, targets: readonly {
|
|
486
|
+
owner: string;
|
|
487
|
+
repo: string;
|
|
488
|
+
ref: GitHubCheckRunRef;
|
|
489
|
+
}[], options: {
|
|
490
|
+
baseUrl?: string;
|
|
491
|
+
tailLines: number;
|
|
492
|
+
}, cancellation?: AbortSignal): Promise<PromiseSettledResult<PullRequestCheckLog>[]>;
|
|
493
|
+
getPullRequestActivity(provider: Provider, token: GitHubTokenInfo, targets: readonly GitHubPullRequestActivityTarget[], options: {
|
|
494
|
+
baseUrl?: string;
|
|
495
|
+
limit: number;
|
|
496
|
+
}, cancellation?: AbortSignal): Promise<PromiseSettledResult<PullRequestActivityPage | undefined>[]>;
|
|
482
497
|
/**
|
|
483
498
|
* The cheap check behind the batch reads' etags: {@link getPullRequestsBatch}'s aliased document, slot rules and
|
|
484
499
|
* failure handling, selecting only a pull request's change state ({@link gqlPullRequestEtagFragment}) — plus
|
|
@@ -496,6 +511,7 @@ export declare class GitHubApi {
|
|
|
496
511
|
baseUrl?: string;
|
|
497
512
|
etagIncludes?: readonly GitHubPullRequestEtagInclude[];
|
|
498
513
|
mergeQueue?: boolean;
|
|
514
|
+
checkRuns?: boolean;
|
|
499
515
|
}, cancellation?: AbortSignal): Promise<PromiseSettledResult<GitHubPullRequestEtagNode | undefined>[]>;
|
|
500
516
|
/**
|
|
501
517
|
* The issue twin of {@link getPullRequestsEtagFieldsBatch}: {@link getIssuesBatch}'s aliased document, slot
|
|
@@ -552,6 +568,7 @@ export declare class GitHubApi {
|
|
|
552
568
|
avatarSize?: number;
|
|
553
569
|
limit: number;
|
|
554
570
|
mergeQueue?: boolean;
|
|
571
|
+
checkRuns?: boolean;
|
|
555
572
|
}, cancellation?: AbortSignal): Promise<PromiseSettledResult<{
|
|
556
573
|
pullRequests: PullRequest[][];
|
|
557
574
|
truncated: boolean;
|
|
@@ -19,10 +19,16 @@ 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";
|
|
31
|
+
import { captureReadNodes, copyReadProvenance, createReadCapture } from "@gitkraken/provider-apis/read-provenance";
|
|
26
32
|
import { GraphqlResponseError, graphql } from "@octokit/graphql";
|
|
27
33
|
import { request } from "@octokit/request";
|
|
28
34
|
import { RequestError } from "@octokit/request-error";
|
|
@@ -456,20 +462,8 @@ reactions(content: THUMBS_UP) {
|
|
|
456
462
|
totalCount
|
|
457
463
|
}
|
|
458
464
|
` };
|
|
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
|
-
};
|
|
465
|
+
function isByteStream(value) {
|
|
466
|
+
return typeof value === "object" && value != null && "getReader" in value && typeof value.getReader === "function";
|
|
473
467
|
}
|
|
474
468
|
var GitHubApi = class {
|
|
475
469
|
config;
|
|
@@ -683,7 +677,7 @@ var GitHubApi = class {
|
|
|
683
677
|
number
|
|
684
678
|
}, scope))?.repository?.issueOrPullRequest;
|
|
685
679
|
if (issue == null) return void 0;
|
|
686
|
-
|
|
680
|
+
const result = {
|
|
687
681
|
provider,
|
|
688
682
|
type: issue.__typename === "PullRequest" ? "pullrequest" : "issue",
|
|
689
683
|
id: String(issue.number),
|
|
@@ -696,6 +690,7 @@ var GitHubApi = class {
|
|
|
696
690
|
url: issue.url,
|
|
697
691
|
state: fromGitHubIssueOrPullRequestState(issue.state)
|
|
698
692
|
};
|
|
693
|
+
return copyReadProvenance(result, issue);
|
|
699
694
|
} catch (ex) {
|
|
700
695
|
if (ex instanceof RequestNotFoundError) return void 0;
|
|
701
696
|
throw this.handleException(ex, provider, scope);
|
|
@@ -1974,7 +1969,15 @@ var GitHubApi = class {
|
|
|
1974
1969
|
};
|
|
1975
1970
|
}
|
|
1976
1971
|
const retryable = graphqlReadQueryRegex.test(query);
|
|
1977
|
-
const data = await this.requestWithRetries(() => this.config.wrapForForcedInsecureSSL(provider?.getIgnoreSSLErrors() ?? false, () =>
|
|
1972
|
+
const data = await this.requestWithRetries(() => this.config.wrapForForcedInsecureSSL(provider?.getIgnoreSSLErrors() ?? false, async () => {
|
|
1973
|
+
const capture = createReadCapture();
|
|
1974
|
+
try {
|
|
1975
|
+
return captureReadNodes(await this.getDefaults(accessToken, graphql)(query, variables), capture);
|
|
1976
|
+
} catch (ex) {
|
|
1977
|
+
if (ex instanceof GraphqlResponseError) captureReadNodes(ex.data, capture);
|
|
1978
|
+
throw ex;
|
|
1979
|
+
}
|
|
1980
|
+
}), retryable, cancellation, scope, gatewayFailures != null);
|
|
1978
1981
|
return allowPartialNotFound === "aliased" ? {
|
|
1979
1982
|
data,
|
|
1980
1983
|
errors: []
|
|
@@ -2090,7 +2093,7 @@ var GitHubApi = class {
|
|
|
2090
2093
|
return defaults;
|
|
2091
2094
|
}
|
|
2092
2095
|
handleRequestError(provider, token, ex, scope, deferFailure) {
|
|
2093
|
-
if (ex.name === "AbortError") throw
|
|
2096
|
+
if (ex.name === "AbortError") throw toCancellationError(ex);
|
|
2094
2097
|
const { accessToken, ...tokenInfo } = token;
|
|
2095
2098
|
switch (ex.status) {
|
|
2096
2099
|
case 404:
|
|
@@ -2520,6 +2523,10 @@ var GitHubApi = class {
|
|
|
2520
2523
|
if (coordinates.length === 0) return [];
|
|
2521
2524
|
const stackFragment = gqlPullRequestStackFragmentFor(options);
|
|
2522
2525
|
const mergeQueueFragment = gqlPullRequestMergeQueueFragmentFor(options, this.config);
|
|
2526
|
+
const checkRuns = options?.checkRuns === true ? {
|
|
2527
|
+
kind: "row",
|
|
2528
|
+
readsRequired: options.checkRunsRequired !== false && isGitHubDotCom(options)
|
|
2529
|
+
} : void 0;
|
|
2523
2530
|
const query = `query getPullRequestsBatch(
|
|
2524
2531
|
${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
2532
|
$avatarSize: Int
|
|
@@ -2528,7 +2535,7 @@ var GitHubApi = class {
|
|
|
2528
2535
|
pullRequest(number: $k${i}) {
|
|
2529
2536
|
${gqlPullRequestFragment}
|
|
2530
2537
|
${stackFragment}
|
|
2531
|
-
${mergeQueueFragment}
|
|
2538
|
+
${mergeQueueFragment}${checkRuns != null ? gqlPullRequestCheckRunsFragment(checkRuns, i) : ""}
|
|
2532
2539
|
}
|
|
2533
2540
|
}`).join("\n ")}
|
|
2534
2541
|
}`;
|
|
@@ -2544,10 +2551,20 @@ var GitHubApi = class {
|
|
|
2544
2551
|
try {
|
|
2545
2552
|
const rsp = await this.graphql(provider, token, query, variables, scope, cancellation, "aliased");
|
|
2546
2553
|
if (rsp?.data == null) throw new Error("GitHub returned no data for the pull request batch");
|
|
2554
|
+
const errors = checkRuns != null ? rsp.errors.filter((e) => !isCheckContextsError(e)) : rsp.errors;
|
|
2555
|
+
const checkContexts = checkRuns != null ? await readCheckContexts(this.aliasedGraphql(provider, token, options?.baseUrl, scope, cancellation), checkRuns, coordinates.map((c, i) => {
|
|
2556
|
+
const alias = `p${i}`;
|
|
2557
|
+
const node = rsp.data[alias]?.pullRequest;
|
|
2558
|
+
return node != null && getAliasErrorVerdict(errors, alias, node) == null ? {
|
|
2559
|
+
number: c.number,
|
|
2560
|
+
commit: node.commits.nodes?.[0]?.commit,
|
|
2561
|
+
errorPath: [alias]
|
|
2562
|
+
} : void 0;
|
|
2563
|
+
}), rsp.errors, scope) : void 0;
|
|
2547
2564
|
return coordinates.map((c, i) => {
|
|
2548
2565
|
const alias = `p${i}`;
|
|
2549
2566
|
const node = rsp.data[alias]?.pullRequest;
|
|
2550
|
-
const verdict = getAliasErrorVerdict(rsp.errors, alias, node);
|
|
2567
|
+
const verdict = getAliasErrorVerdict(node != null ? errors : rsp.errors, alias, node);
|
|
2551
2568
|
if (verdict === "absent") return {
|
|
2552
2569
|
status: "fulfilled",
|
|
2553
2570
|
value: void 0
|
|
@@ -2560,7 +2577,7 @@ var GitHubApi = class {
|
|
|
2560
2577
|
try {
|
|
2561
2578
|
return {
|
|
2562
2579
|
status: "fulfilled",
|
|
2563
|
-
value: fromGitHubPullRequest(node, provider)
|
|
2580
|
+
value: fromGitHubPullRequest(node, provider, void 0, checkContexts?.[i])
|
|
2564
2581
|
};
|
|
2565
2582
|
} catch (ex) {
|
|
2566
2583
|
scope?.warn(`failed to map pull request; ${c.owner}/${c.repo}#${c.number}, ex=${ex}`);
|
|
@@ -2574,6 +2591,54 @@ var GitHubApi = class {
|
|
|
2574
2591
|
throw this.handleException(ex, provider, scope);
|
|
2575
2592
|
}
|
|
2576
2593
|
}
|
|
2594
|
+
aliasedGraphql(provider, token, baseUrl, scope, cancellation) {
|
|
2595
|
+
return (query, variables) => this.graphql(provider, token, query, {
|
|
2596
|
+
...variables,
|
|
2597
|
+
baseUrl
|
|
2598
|
+
}, scope, cancellation, "aliased");
|
|
2599
|
+
}
|
|
2600
|
+
async getCheckRunLogs(provider, token, targets, options, cancellation) {
|
|
2601
|
+
const scope = getScopedLogger();
|
|
2602
|
+
const route = (job) => ({
|
|
2603
|
+
owner: job.owner,
|
|
2604
|
+
repo: job.repo,
|
|
2605
|
+
job_id: job.jobId,
|
|
2606
|
+
baseUrl: options.baseUrl
|
|
2607
|
+
});
|
|
2608
|
+
const requestJobLog = (job, request) => this.request(provider, token, "GET /repos/{owner}/{repo}/actions/jobs/{job_id}/logs", {
|
|
2609
|
+
...route(job),
|
|
2610
|
+
request
|
|
2611
|
+
}, scope, cancellation, true);
|
|
2612
|
+
const configFetch = this.config.fetch;
|
|
2613
|
+
return readGitHubCheckRunLogs({
|
|
2614
|
+
isWeb: this.config.isWeb,
|
|
2615
|
+
graphql: this.aliasedGraphql(provider, token, options.baseUrl, scope, cancellation),
|
|
2616
|
+
requestJobLogRedirect: async (job) => {
|
|
2617
|
+
const rsp = await requestJobLog(job, { redirect: "manual" });
|
|
2618
|
+
return {
|
|
2619
|
+
status: rsp.status,
|
|
2620
|
+
location: rsp.headers.location
|
|
2621
|
+
};
|
|
2622
|
+
},
|
|
2623
|
+
requestJobLogStream: async (job) => {
|
|
2624
|
+
const body = (await requestJobLog(job, { parseSuccessResponseBody: false })).data;
|
|
2625
|
+
if (body == null) return null;
|
|
2626
|
+
if (isByteStream(body)) return body;
|
|
2627
|
+
throw new Error("GitHub answered the job log without a body stream");
|
|
2628
|
+
},
|
|
2629
|
+
requestJobStatus: async (job) => {
|
|
2630
|
+
return (await this.request(provider, token, "GET /repos/{owner}/{repo}/actions/jobs/{job_id}", route(job), scope, cancellation, true)).data?.status;
|
|
2631
|
+
},
|
|
2632
|
+
fetchStorage: (url, init) => this.config.wrapForForcedInsecureSSL(provider.getIgnoreSSLErrors(), () => configFetch(url, {
|
|
2633
|
+
method: "GET",
|
|
2634
|
+
...init
|
|
2635
|
+
}))
|
|
2636
|
+
}, targets, options.tailLines, scope, cancellation);
|
|
2637
|
+
}
|
|
2638
|
+
async getPullRequestActivity(provider, token, targets, options, cancellation) {
|
|
2639
|
+
const scope = getScopedLogger();
|
|
2640
|
+
return readGitHubPullRequestActivity(this.aliasedGraphql(provider, token, options.baseUrl, scope, cancellation), targets, options.limit, scope);
|
|
2641
|
+
}
|
|
2577
2642
|
/**
|
|
2578
2643
|
* The cheap check behind the batch reads' etags: {@link getPullRequestsBatch}'s aliased document, slot rules and
|
|
2579
2644
|
* failure handling, selecting only a pull request's change state ({@link gqlPullRequestEtagFragment}) — plus
|
|
@@ -2588,6 +2653,7 @@ var GitHubApi = class {
|
|
|
2588
2653
|
if (coordinates.length === 0) return [];
|
|
2589
2654
|
const includeFragments = Array.from(new Set(options?.etagIncludes), (include) => gqlPullRequestEtagIncludeFragments[include]);
|
|
2590
2655
|
const mergeQueueFragment = gqlPullRequestEtagMergeQueueFragmentFor(options, this.config);
|
|
2656
|
+
const checkRuns = options?.checkRuns === true;
|
|
2591
2657
|
const query = `query getPullRequestsEtagFieldsBatch(
|
|
2592
2658
|
${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
2659
|
) {
|
|
@@ -2595,7 +2661,7 @@ var GitHubApi = class {
|
|
|
2595
2661
|
pullRequest(number: $k${i}) {
|
|
2596
2662
|
${gqlPullRequestEtagFragment}
|
|
2597
2663
|
${mergeQueueFragment}
|
|
2598
|
-
${includeFragments.join("")}
|
|
2664
|
+
${includeFragments.join("")}${checkRuns ? gqlPullRequestCheckRunsFragment(etagCheckContextsFragment, i) : ""}
|
|
2599
2665
|
}
|
|
2600
2666
|
}`).join("\n ")}
|
|
2601
2667
|
}`;
|
|
@@ -2608,18 +2674,36 @@ var GitHubApi = class {
|
|
|
2608
2674
|
try {
|
|
2609
2675
|
const rsp = await this.graphql(provider, token, query, variables, scope, cancellation, "aliased");
|
|
2610
2676
|
if (rsp?.data == null) throw new Error("GitHub returned no data for the pull request etag batch");
|
|
2677
|
+
const errors = checkRuns ? rsp.errors.filter((e) => !isCheckContextsError(e)) : rsp.errors;
|
|
2678
|
+
const checkContexts = checkRuns ? await readCheckContexts(this.aliasedGraphql(provider, token, options?.baseUrl, scope, cancellation), etagCheckContextsFragment, coordinates.map((c, i) => {
|
|
2679
|
+
const alias = `p${i}`;
|
|
2680
|
+
const node = rsp.data[alias]?.pullRequest;
|
|
2681
|
+
return node != null && getAliasErrorVerdict(errors, alias, node) == null ? {
|
|
2682
|
+
number: c.number,
|
|
2683
|
+
commit: node.commits?.nodes?.[0]?.commit,
|
|
2684
|
+
errorPath: [alias]
|
|
2685
|
+
} : void 0;
|
|
2686
|
+
}), rsp.errors, scope) : void 0;
|
|
2611
2687
|
return coordinates.map((_, i) => {
|
|
2612
2688
|
const alias = `p${i}`;
|
|
2613
2689
|
const node = rsp.data[alias]?.pullRequest;
|
|
2614
|
-
const verdict = getAliasErrorVerdict(rsp.errors, alias, node);
|
|
2690
|
+
const verdict = getAliasErrorVerdict(node != null ? errors : rsp.errors, alias, node);
|
|
2615
2691
|
if (verdict === "absent") return {
|
|
2616
2692
|
status: "fulfilled",
|
|
2617
2693
|
value: void 0
|
|
2618
2694
|
};
|
|
2619
2695
|
if (verdict != null) return verdict;
|
|
2696
|
+
if (node == null) return {
|
|
2697
|
+
status: "fulfilled",
|
|
2698
|
+
value: void 0
|
|
2699
|
+
};
|
|
2700
|
+
const read = checkContexts?.[i];
|
|
2620
2701
|
return {
|
|
2621
2702
|
status: "fulfilled",
|
|
2622
|
-
value:
|
|
2703
|
+
value: read != null ? {
|
|
2704
|
+
...node,
|
|
2705
|
+
checkRuns: read
|
|
2706
|
+
} : node
|
|
2623
2707
|
};
|
|
2624
2708
|
});
|
|
2625
2709
|
} catch (ex) {
|
|
@@ -2709,6 +2793,10 @@ var GitHubApi = class {
|
|
|
2709
2793
|
if (queries.length === 0) return [];
|
|
2710
2794
|
const stackFragment = gqlPullRequestStackFragmentFor(options);
|
|
2711
2795
|
const mergeQueueFragment = gqlPullRequestMergeQueueFragmentFor(options, this.config);
|
|
2796
|
+
const checkRuns = options.checkRuns === true ? {
|
|
2797
|
+
kind: "row",
|
|
2798
|
+
readsRequired: false
|
|
2799
|
+
} : void 0;
|
|
2712
2800
|
const query = `query getPullRequestsForBranches(
|
|
2713
2801
|
${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
2802
|
$limit: Int!
|
|
@@ -2720,7 +2808,7 @@ var GitHubApi = class {
|
|
|
2720
2808
|
nodes {
|
|
2721
2809
|
${gqlPullRequestFragment}
|
|
2722
2810
|
${stackFragment}
|
|
2723
|
-
${mergeQueueFragment}
|
|
2811
|
+
${mergeQueueFragment}${checkRuns != null ? gqlPullRequestCheckRunsFragment(checkRuns, i) : ""}
|
|
2724
2812
|
headRepositoryOwner {
|
|
2725
2813
|
login
|
|
2726
2814
|
}
|
|
@@ -2741,10 +2829,11 @@ var GitHubApi = class {
|
|
|
2741
2829
|
try {
|
|
2742
2830
|
const rsp = await this.graphql(provider, token, query, variables, scope, cancellation, "aliased");
|
|
2743
2831
|
if (rsp?.data == null) throw new Error("GitHub returned no data for the pull requests by branch");
|
|
2744
|
-
|
|
2832
|
+
const errors = checkRuns != null ? rsp.errors.filter((e) => !isCheckContextsError(e)) : rsp.errors;
|
|
2833
|
+
const answers = queries.map((t, i) => {
|
|
2745
2834
|
const alias = `b${i}`;
|
|
2746
2835
|
const repository = rsp.data[alias];
|
|
2747
|
-
const verdict = getAliasErrorVerdict(rsp.errors, alias, repository);
|
|
2836
|
+
const verdict = getAliasErrorVerdict(repository != null ? errors : rsp.errors, alias, repository);
|
|
2748
2837
|
if (verdict != null && verdict !== "absent") return verdict;
|
|
2749
2838
|
if (repository == null) return {
|
|
2750
2839
|
status: "fulfilled",
|
|
@@ -2758,25 +2847,63 @@ var GitHubApi = class {
|
|
|
2758
2847
|
status: "rejected",
|
|
2759
2848
|
reason: /* @__PURE__ */ new Error(`GitHub returned no pull requests for ${t.owner}/${t.repo}:${t.branch}`)
|
|
2760
2849
|
};
|
|
2761
|
-
const returned =
|
|
2850
|
+
const returned = [];
|
|
2851
|
+
const errorPaths = /* @__PURE__ */ new Map();
|
|
2852
|
+
connection.nodes.forEach((pr, index) => {
|
|
2853
|
+
if (pr == null) return;
|
|
2854
|
+
returned.push(pr);
|
|
2855
|
+
if (checkRuns != null) errorPaths.set(pr, [
|
|
2856
|
+
alias,
|
|
2857
|
+
"pullRequests",
|
|
2858
|
+
"nodes",
|
|
2859
|
+
index
|
|
2860
|
+
]);
|
|
2861
|
+
});
|
|
2762
2862
|
const nodes = returned.filter((pr) => pr.headRefName === t.branch);
|
|
2863
|
+
return {
|
|
2864
|
+
matches: t.headOwners.map((owner) => {
|
|
2865
|
+
const headOwner = owner?.toLowerCase();
|
|
2866
|
+
return nodes.filter((pr) => headOwner == null ? !pr.isCrossRepository : pr.isCrossRepository && pr.headRepositoryOwner?.login.toLowerCase() === headOwner);
|
|
2867
|
+
}),
|
|
2868
|
+
truncated: connection.totalCount > returned.length,
|
|
2869
|
+
errorPaths
|
|
2870
|
+
};
|
|
2871
|
+
});
|
|
2872
|
+
let checkContexts;
|
|
2873
|
+
if (checkRuns != null) {
|
|
2874
|
+
const matched = /* @__PURE__ */ new Map();
|
|
2875
|
+
for (const answer of answers) {
|
|
2876
|
+
if ("status" in answer) continue;
|
|
2877
|
+
for (const pr of answer.matches.flat()) {
|
|
2878
|
+
const errorPath = answer.errorPaths.get(pr);
|
|
2879
|
+
if (errorPath != null) matched.set(pr, errorPath);
|
|
2880
|
+
}
|
|
2881
|
+
}
|
|
2882
|
+
const rows = [...matched];
|
|
2883
|
+
const read = await readCheckContexts(this.aliasedGraphql(provider, token, options.baseUrl, scope, cancellation), checkRuns, rows.map(([pr, errorPath]) => ({
|
|
2884
|
+
number: pr.number,
|
|
2885
|
+
commit: pr.commits.nodes?.[0]?.commit,
|
|
2886
|
+
errorPath
|
|
2887
|
+
})), rsp.errors, scope);
|
|
2888
|
+
checkContexts = new Map(rows.map(([pr], i) => [pr, read[i]]));
|
|
2889
|
+
}
|
|
2890
|
+
return queries.map((t, i) => {
|
|
2891
|
+
const answer = answers[i];
|
|
2892
|
+
if ("status" in answer) return answer;
|
|
2763
2893
|
try {
|
|
2764
2894
|
const mapped = /* @__PURE__ */ new Map();
|
|
2765
2895
|
return {
|
|
2766
2896
|
status: "fulfilled",
|
|
2767
2897
|
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
|
|
2898
|
+
pullRequests: answer.matches.map((matches) => matches.map((pr) => {
|
|
2899
|
+
let converted = mapped.get(pr);
|
|
2900
|
+
if (converted == null) {
|
|
2901
|
+
converted = fromGitHubPullRequest(pr, provider, void 0, checkContexts?.get(pr));
|
|
2902
|
+
mapped.set(pr, converted);
|
|
2903
|
+
}
|
|
2904
|
+
return converted;
|
|
2905
|
+
}).sort((a, b) => b.updatedDate.getTime() - a.updatedDate.getTime())),
|
|
2906
|
+
truncated: answer.truncated
|
|
2780
2907
|
}
|
|
2781
2908
|
};
|
|
2782
2909
|
} catch (ex) {
|
|
@@ -3796,6 +3923,14 @@ __decorate([trace({ args: (provider, token) => ({
|
|
|
3796
3923
|
provider: provider.name,
|
|
3797
3924
|
token: `<token:${token.microHash}>`
|
|
3798
3925
|
}) })], GitHubApi.prototype, "getPullRequestsBatch", null);
|
|
3926
|
+
__decorate([trace({ args: (provider, token) => ({
|
|
3927
|
+
provider: provider.name,
|
|
3928
|
+
token: `<token:${token.microHash}>`
|
|
3929
|
+
}) })], GitHubApi.prototype, "getCheckRunLogs", null);
|
|
3930
|
+
__decorate([trace({ args: (provider, token) => ({
|
|
3931
|
+
provider: provider.name,
|
|
3932
|
+
token: `<token:${token.microHash}>`
|
|
3933
|
+
}) })], GitHubApi.prototype, "getPullRequestActivity", null);
|
|
3799
3934
|
__decorate([trace({ args: (provider, token) => ({
|
|
3800
3935
|
provider: provider.name,
|
|
3801
3936
|
token: `<token:${token.microHash}>`
|