@gitkraken/core-gitlens 0.36.0 → 0.37.1
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/utils/branch.utils.d.ts +14 -0
- package/dist/git/utils/branch.utils.js +37 -1
- package/dist/git/utils/branch.utils.js.map +1 -1
- package/dist/git/utils/branchLanded.utils.d.ts +43 -0
- package/dist/git/utils/branchLanded.utils.js +56 -0
- package/dist/git/utils/branchLanded.utils.js.map +1 -0
- package/dist/plus/ai/models/model.js +58 -4
- package/dist/plus/ai/models/model.js.map +1 -1
- package/dist/plus/ai/providers/anthropicProvider.js +58 -223
- package/dist/plus/ai/providers/anthropicProvider.js.map +1 -1
- package/dist/plus/ai/providers/deepSeekProvider.js +32 -18
- package/dist/plus/ai/providers/deepSeekProvider.js.map +1 -1
- package/dist/plus/ai/providers/geminiProvider.js +25 -189
- package/dist/plus/ai/providers/geminiProvider.js.map +1 -1
- package/dist/plus/ai/providers/mistralProvider.js +31 -73
- package/dist/plus/ai/providers/mistralProvider.js.map +1 -1
- package/dist/plus/ai/providers/xaiProvider.js +9 -11
- package/dist/plus/ai/providers/xaiProvider.js.map +1 -1
- package/dist/plus/git-github/api/github.d.ts +18 -3
- package/dist/plus/git-github/api/github.js +58 -15
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +2 -0
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +24 -5
- package/dist/plus/integrations/models/issuesIntegration.d.ts +2 -1
- package/dist/plus/integrations/models/issuesIntegration.js +6 -3
- package/dist/plus/integrations/models/issuesIntegration.js.map +1 -1
- package/dist/plus/integrations/providers/azureDevOps.d.ts +21 -6
- package/dist/plus/integrations/providers/azureDevOps.js +24 -12
- package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
- package/dist/plus/integrations/providers/azureDevOpsServer.d.ts +49 -3
- package/dist/plus/integrations/providers/azureDevOpsServer.js +151 -23
- package/dist/plus/integrations/providers/azureDevOpsServer.js.map +1 -1
- package/dist/plus/integrations/providers/issueSorts.d.ts +0 -1
- package/dist/plus/integrations/providers/linear.d.ts +3 -2
- package/dist/plus/integrations/providers/linear.js +7 -5
- package/dist/plus/integrations/providers/linear.js.map +1 -1
- package/dist/plus/integrations/reads/drains.d.ts +0 -1
- package/dist/plus/integrations/reads/searchPullRequests.d.ts +2 -0
- package/dist/plus/integrations/reads/searchPullRequests.js +18 -9
- package/dist/plus/integrations/reads/searchPullRequests.js.map +1 -1
- package/docs/integrations.md +27 -6
- package/package.json +1 -1
|
@@ -15,8 +15,8 @@ import { base64 } from "../../../utils/base64.js";
|
|
|
15
15
|
import { getGitHubNoReplyAddressParts } from "../../../git/remotes/github.js";
|
|
16
16
|
import { defaultIssueSort } from "../../../git/models/issue.js";
|
|
17
17
|
import "../../../git/models/pullRequest.js";
|
|
18
|
-
import { effectiveIssueSort, getIssueComparator } from "../../../git/utils/issue.utils.js";
|
|
19
18
|
import { getPullRequestComparator } from "../../../git/utils/pullRequest.utils.js";
|
|
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
22
|
import { gitHubIssueSearchRelationships, toGitHubIssueSearchQualifiers, toGitHubIssueSearchScopeQualifiers, toGitHubIssueSearchSlideQualifier, toGitHubIssueSortQualifier } from "./issueSearchQuery.js";
|
|
@@ -44,6 +44,8 @@ const requestRetryMaxDelay = 2e3;
|
|
|
44
44
|
const accountResolveBatchSize = 25;
|
|
45
45
|
const defaultPullRequestSearchPageSize = 30;
|
|
46
46
|
const maxPullRequestSearchPageSize = 100;
|
|
47
|
+
const fullPullRequestSearchPageBudget = 20;
|
|
48
|
+
const summaryPullRequestSearchPageBudget = maxPullRequestSearchPageSize;
|
|
47
49
|
const maxMyPullRequestSearchPages = 4;
|
|
48
50
|
function isRetryableTransientError(ex) {
|
|
49
51
|
if (!(ex instanceof RequestError)) return false;
|
|
@@ -55,6 +57,10 @@ function isRetryableTransientError(ex) {
|
|
|
55
57
|
default: return false;
|
|
56
58
|
}
|
|
57
59
|
}
|
|
60
|
+
/** A gateway that gave up waiting for GitHub to build the response, which an identical request mostly repeats. */
|
|
61
|
+
function isGatewayTimeoutError(ex) {
|
|
62
|
+
return ex instanceof RequestError && (ex.status === 502 || ex.status === 504);
|
|
63
|
+
}
|
|
58
64
|
/**
|
|
59
65
|
* When a rate-limited request may be retried, as a UTC epoch in seconds, or `undefined` when the response says
|
|
60
66
|
* nothing useful. Header precedence follows GitHub's own guidance
|
|
@@ -1899,12 +1905,14 @@ var GitHubApi = class {
|
|
|
1899
1905
|
this._enterpriseVersions.set(accessToken, version);
|
|
1900
1906
|
return version ?? void 0;
|
|
1901
1907
|
}
|
|
1902
|
-
async requestWithRetries(execute, retryable, signal, scope) {
|
|
1908
|
+
async requestWithRetries(execute, retryable, signal, scope, noGatewayRetry) {
|
|
1903
1909
|
let attempt = 0;
|
|
1904
1910
|
while (true) try {
|
|
1905
1911
|
return await execute();
|
|
1906
1912
|
} catch (ex) {
|
|
1907
|
-
if (
|
|
1913
|
+
if (signal?.aborted && isRetryableTransientError(ex)) throw new CancellationError(ex);
|
|
1914
|
+
if (!retryable || attempt >= maxRequestRetries || !isRetryableTransientError(ex)) throw ex;
|
|
1915
|
+
if (noGatewayRetry && isGatewayTimeoutError(ex)) throw ex;
|
|
1908
1916
|
attempt++;
|
|
1909
1917
|
const delay = getRequestRetryDelay(attempt);
|
|
1910
1918
|
scope?.warn(`Transient request failure (status ${ex.status}); retrying ${attempt}/${maxRequestRetries} in ${delay}ms`);
|
|
@@ -1931,13 +1939,13 @@ var GitHubApi = class {
|
|
|
1931
1939
|
});
|
|
1932
1940
|
}
|
|
1933
1941
|
_pendingGraphQL = /* @__PURE__ */ new Map();
|
|
1934
|
-
async graphql(provider, token, query, variables, scope, cancellation, allowPartialNotFound) {
|
|
1942
|
+
async graphql(provider, token, query, variables, scope, cancellation, allowPartialNotFound, gatewayFailures) {
|
|
1935
1943
|
const { accessToken, ...tokenInfo } = token;
|
|
1936
1944
|
const dedupable = cancellation == null && variables?.request == null;
|
|
1937
1945
|
let dedupeKey;
|
|
1938
1946
|
if (dedupable) {
|
|
1939
1947
|
try {
|
|
1940
|
-
dedupeKey = `${token.microHash}|${provider?.id ?? ""}|${allowPartialNotFound ?? ""}|${query}|${JSON.stringify(variables ?? null)}`;
|
|
1948
|
+
dedupeKey = `${token.microHash}|${provider?.id ?? ""}|${allowPartialNotFound ?? ""}|${gatewayFailures ?? ""}|${query}|${JSON.stringify(variables ?? null)}`;
|
|
1941
1949
|
} catch {
|
|
1942
1950
|
dedupeKey = void 0;
|
|
1943
1951
|
}
|
|
@@ -1959,7 +1967,7 @@ var GitHubApi = class {
|
|
|
1959
1967
|
};
|
|
1960
1968
|
}
|
|
1961
1969
|
const retryable = graphqlReadQueryRegex.test(query);
|
|
1962
|
-
const data = await this.requestWithRetries(() => this.config.wrapForForcedInsecureSSL(provider?.getIgnoreSSLErrors() ?? false, () => this.getDefaults(accessToken, graphql)(query, variables)), retryable, cancellation, scope);
|
|
1970
|
+
const data = await this.requestWithRetries(() => this.config.wrapForForcedInsecureSSL(provider?.getIgnoreSSLErrors() ?? false, () => this.getDefaults(accessToken, graphql)(query, variables)), retryable, cancellation, scope, gatewayFailures != null);
|
|
1963
1971
|
return allowPartialNotFound === "aliased" ? {
|
|
1964
1972
|
data,
|
|
1965
1973
|
errors: []
|
|
@@ -1986,7 +1994,7 @@ var GitHubApi = class {
|
|
|
1986
1994
|
case "FORBIDDEN": throw new AuthenticationError(tokenInfo, 3, ex);
|
|
1987
1995
|
}
|
|
1988
1996
|
if (_logger.isDebugging) this.config.onDebugError?.(`GitHub request failed: ${ex.errors?.[0]?.message ?? ex.message}`);
|
|
1989
|
-
} else if (ex instanceof RequestError || ex.name === "AbortError") this.handleRequestError(provider, token, ex, scope, allowPartialNotFound === "aliased");
|
|
1997
|
+
} else if (gatewayFailures === "caller" && isGatewayTimeoutError(ex)) {} else if (ex instanceof RequestError || ex.name === "AbortError") this.handleRequestError(provider, token, ex, scope, allowPartialNotFound === "aliased");
|
|
1990
1998
|
else if (_logger.isDebugging) this.config.onDebugError?.(`GitHub request failed: ${ex.message}`);
|
|
1991
1999
|
throw ex;
|
|
1992
2000
|
}
|
|
@@ -3043,6 +3051,15 @@ var GitHubApi = class {
|
|
|
3043
3051
|
* union of facets and no per-facet server order describes it. The sort is part of the cursor fingerprint, so
|
|
3044
3052
|
* changing it invalidates a threaded cursor exactly as changing the text or the scope does. User text is
|
|
3045
3053
|
* sanitized before it reaches the provider query. See {@link toGitHubPullRequestSearchFacets}.
|
|
3054
|
+
*
|
|
3055
|
+
* A page selects at most {@link fullPullRequestSearchPageBudget} pull requests across its facets with the full
|
|
3056
|
+
* fragment, and {@link summaryPullRequestSearchPageBudget} with the lite one, whatever `pageSize` asks for: past
|
|
3057
|
+
* that GitHub's gateway times out building the page (502/504 after ~11s). When it times out anyway, the page is
|
|
3058
|
+
* requested once more at half its size (unchanged when it is already one row per facet) rather than twice more
|
|
3059
|
+
* unchanged, and a second gateway failure fails the read. A page that recovers is smaller but no facet skips or
|
|
3060
|
+
* repeats a row, since each resumes from the cursor of the last row it served; the halved size is kept in the
|
|
3061
|
+
* cursor for the rest of the walk, so later pages don't time out again first. Other transient failures (503, a
|
|
3062
|
+
* network failure) are retried unchanged on each of those two requests, as on any read.
|
|
3046
3063
|
*/
|
|
3047
3064
|
async searchPullRequestsPage(provider, token, options, cancellation) {
|
|
3048
3065
|
const scope = getScopedLogger();
|
|
@@ -3063,6 +3080,7 @@ var GitHubApi = class {
|
|
|
3063
3080
|
let cursor;
|
|
3064
3081
|
if (options?.cursor != null) try {
|
|
3065
3082
|
const parsed = JSON.parse(options.cursor);
|
|
3083
|
+
const parsedBudget = cursorNumber(parsed, "budget");
|
|
3066
3084
|
const parsedFacets = parsed.facets;
|
|
3067
3085
|
if (parsedFacets != null && typeof parsedFacets === "object" && !Array.isArray(parsedFacets)) {
|
|
3068
3086
|
const parsedAliases = Object.keys(parsedFacets).sort();
|
|
@@ -3073,7 +3091,8 @@ var GitHubApi = class {
|
|
|
3073
3091
|
page: typeof parsed.page === "number" && Number.isFinite(parsed.page) ? Math.max(1, Math.trunc(parsed.page)) : 1,
|
|
3074
3092
|
facets: parsedFacets,
|
|
3075
3093
|
truncated: parsed.truncated === true,
|
|
3076
|
-
totalCount: typeof parsed.totalCount === "number" && Number.isFinite(parsed.totalCount) ? Math.max(0, Math.trunc(parsed.totalCount)) : void 0
|
|
3094
|
+
totalCount: typeof parsed.totalCount === "number" && Number.isFinite(parsed.totalCount) ? Math.max(0, Math.trunc(parsed.totalCount)) : void 0,
|
|
3095
|
+
budget: parsedBudget != null && parsedBudget >= 1 ? Math.trunc(parsedBudget) : void 0
|
|
3077
3096
|
};
|
|
3078
3097
|
}
|
|
3079
3098
|
} catch {}
|
|
@@ -3087,8 +3106,9 @@ var GitHubApi = class {
|
|
|
3087
3106
|
truncated: cursor?.truncated === true,
|
|
3088
3107
|
totalCount: cursor?.totalCount
|
|
3089
3108
|
};
|
|
3090
|
-
const
|
|
3091
|
-
const
|
|
3109
|
+
const budget = Math.min(options?.summary === true ? summaryPullRequestSearchPageBudget : fullPullRequestSearchPageBudget, cursor?.budget ?? Number.POSITIVE_INFINITY);
|
|
3110
|
+
const facetBudget = Math.max(1, Math.floor(budget / activeFacets.length));
|
|
3111
|
+
const requestedPageSize = Math.min(facetBudget, Math.max(1, Math.trunc(options?.pageSize ?? facetBudget)));
|
|
3092
3112
|
const includeVar = (alias) => `include${alias.charAt(0).toUpperCase()}${alias.slice(1)}`;
|
|
3093
3113
|
const stackFragment = gqlPullRequestStackFragmentFor(options);
|
|
3094
3114
|
const mergeQueueFragment = gqlPullRequestMergeQueueFragmentFor(options, this.config);
|
|
@@ -3097,7 +3117,8 @@ var GitHubApi = class {
|
|
|
3097
3117
|
`$${f.alias}Cursor: String`,
|
|
3098
3118
|
`$${includeVar(f.alias)}: Boolean!`
|
|
3099
3119
|
]);
|
|
3100
|
-
const
|
|
3120
|
+
const toQuery = (size) => {
|
|
3121
|
+
const fields = facets.map((f) => `${f.alias}: search(first: ${size}, after: $${f.alias}Cursor, query: $${f.alias}Search, type: ISSUE)
|
|
3101
3122
|
@include(if: $${includeVar(f.alias)}) {
|
|
3102
3123
|
issueCount
|
|
3103
3124
|
pageInfo {
|
|
@@ -3112,12 +3133,13 @@ var GitHubApi = class {
|
|
|
3112
3133
|
}
|
|
3113
3134
|
}
|
|
3114
3135
|
}`);
|
|
3115
|
-
|
|
3136
|
+
return `query searchPullRequestsPage(
|
|
3116
3137
|
${params.join("\n ")}
|
|
3117
3138
|
$avatarSize: Int
|
|
3118
3139
|
) {
|
|
3119
3140
|
${fields.join("\n ")}
|
|
3120
3141
|
}`;
|
|
3142
|
+
};
|
|
3121
3143
|
const variables = {
|
|
3122
3144
|
baseUrl: options?.baseUrl,
|
|
3123
3145
|
avatarSize: options?.avatarSize
|
|
@@ -3127,8 +3149,18 @@ var GitHubApi = class {
|
|
|
3127
3149
|
variables[`${facet.alias}Cursor`] = cursor?.facets[facet.alias] ?? void 0;
|
|
3128
3150
|
variables[includeVar(facet.alias)] = isActive(facet.alias);
|
|
3129
3151
|
}
|
|
3152
|
+
const read = (size, gatewayFailures) => this.graphql(provider, token, toQuery(size), variables, scope, cancellation, void 0, gatewayFailures);
|
|
3130
3153
|
try {
|
|
3131
|
-
|
|
3154
|
+
let pageSize = requestedPageSize;
|
|
3155
|
+
let rsp;
|
|
3156
|
+
try {
|
|
3157
|
+
rsp = await read(pageSize, "caller");
|
|
3158
|
+
} catch (ex) {
|
|
3159
|
+
if (!isGatewayTimeoutError(ex)) throw ex;
|
|
3160
|
+
pageSize = Math.max(1, Math.floor(pageSize / 2));
|
|
3161
|
+
scope?.warn(`Gateway failure (status ${ex.status}) building the page; retrying at ${pageSize} per facet`);
|
|
3162
|
+
rsp = await read(pageSize, "final");
|
|
3163
|
+
}
|
|
3132
3164
|
if (rsp == null) return {
|
|
3133
3165
|
values: [],
|
|
3134
3166
|
hasMore: false,
|
|
@@ -3171,7 +3203,8 @@ var GitHubApi = class {
|
|
|
3171
3203
|
page: page + 1,
|
|
3172
3204
|
facets: nextFacets,
|
|
3173
3205
|
truncated: truncated || void 0,
|
|
3174
|
-
totalCount
|
|
3206
|
+
totalCount,
|
|
3207
|
+
budget: pageSize < requestedPageSize ? pageSize * activeFacets.length : cursor?.budget
|
|
3175
3208
|
};
|
|
3176
3209
|
return {
|
|
3177
3210
|
values,
|
|
@@ -3185,11 +3218,16 @@ var GitHubApi = class {
|
|
|
3185
3218
|
throw this.handleException(ex, provider, scope);
|
|
3186
3219
|
}
|
|
3187
3220
|
}
|
|
3221
|
+
/**
|
|
3222
|
+
* The exact opened + merged state set is ordered newest-created first, overriding unquoted `sort:` qualifiers
|
|
3223
|
+
* in the search text. Other state sets keep GitHub's order, including any caller-supplied sort.
|
|
3224
|
+
*/
|
|
3188
3225
|
async searchPullRequests(provider, token, options, cancellation) {
|
|
3189
3226
|
const scope = getScopedLogger();
|
|
3190
3227
|
const pageSize = 10;
|
|
3191
3228
|
const include = options?.include?.length ? options.include : void 0;
|
|
3192
|
-
const
|
|
3229
|
+
const splitStates = requiresGitHubPullRequestStateFacets(include);
|
|
3230
|
+
const stateSearches = splitStates ? [{
|
|
3193
3231
|
alias: "opened",
|
|
3194
3232
|
qualifier: "is:open"
|
|
3195
3233
|
}, {
|
|
@@ -3223,6 +3261,10 @@ var GitHubApi = class {
|
|
|
3223
3261
|
${fields.join("\n ")}
|
|
3224
3262
|
}`;
|
|
3225
3263
|
let search = options?.search?.trim() ?? "";
|
|
3264
|
+
if (splitStates) {
|
|
3265
|
+
search = search.replace(/"(?:\\.|[^"\\])*"|(?:^|\s)sort:(?:"(?:\\.|[^"\\])*"|[^\s"]*)/gi, (match) => match.startsWith("\"") ? match : "");
|
|
3266
|
+
search = `${search.trim()} sort:created-desc`.trim();
|
|
3267
|
+
}
|
|
3226
3268
|
if (options?.user) search += ` user:${options.user}`;
|
|
3227
3269
|
if (options?.repos != null && options.repos.length > 0) {
|
|
3228
3270
|
const repo = " repo:";
|
|
@@ -3245,6 +3287,7 @@ var GitHubApi = class {
|
|
|
3245
3287
|
if (rsp == null) return [];
|
|
3246
3288
|
const results = [];
|
|
3247
3289
|
for (const { alias } of stateSearches) for (const node of rsp[alias]?.nodes ?? []) results.push(fromGitHubPullRequest(node, provider, "text-search"));
|
|
3290
|
+
if (splitStates) results.sort(getPullRequestComparator("created:desc"));
|
|
3248
3291
|
return [...uniqueBy(filterPullRequestsBySearchState(results, include), (pr) => pr.url, (original, _current) => original)].slice(0, pageSize);
|
|
3249
3292
|
} catch (ex) {
|
|
3250
3293
|
throw this.handleException(ex, provider, scope);
|