@gitkraken/core-gitlens 0.41.0 → 0.44.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 +34 -1
- package/dist/git/errors.d.ts +1 -0
- package/dist/git/errors.js +7 -1
- package/dist/git/errors.js.map +1 -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 +2 -0
- package/dist/git/models/pullRequest.js.map +1 -1
- package/dist/git-cli/providers/config.js +2 -2
- package/dist/git-cli/providers/pausedOperations.js +2 -2
- package/dist/git-cli/providers/pausedOperations.js.map +1 -1
- package/dist/git-cli/providers/staging.js +1 -1
- package/dist/ipc/discovery.js +1 -1
- package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
- package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
- package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
- package/dist/plus/git-github/api/aliasedQuery.d.ts +3 -2
- package/dist/plus/git-github/api/aliasedQuery.js +7 -3
- package/dist/plus/git-github/api/aliasedQuery.js.map +1 -1
- package/dist/plus/git-github/api/github.d.ts +7 -4
- package/dist/plus/git-github/api/github.js +112 -14
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/api/issueWrites.d.ts +5 -1
- package/dist/plus/git-github/api/issueWrites.js +15 -5
- package/dist/plus/git-github/api/issueWrites.js.map +1 -1
- package/dist/plus/git-github/models.js +7 -3
- package/dist/plus/git-github/models.js.map +1 -1
- package/dist/plus/integrations/collectionMetadata.js +2 -1
- package/dist/plus/integrations/collectionMetadata.js.map +1 -1
- package/dist/plus/integrations/context.d.ts +3 -3
- package/dist/plus/integrations/errors.d.ts +4 -0
- package/dist/plus/integrations/errors.js +8 -1
- package/dist/plus/integrations/errors.js.map +1 -1
- package/dist/plus/integrations/index.d.ts +3 -2
- package/dist/plus/integrations/index.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +18 -1
- package/dist/plus/integrations/integrationService.js +19 -0
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/lite.js +11 -1
- package/dist/plus/integrations/lite.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +93 -0
- package/dist/plus/integrations/models/gitHostIntegration.d.ts +21 -2
- package/dist/plus/integrations/models/gitHostIntegration.js +182 -14
- package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
- package/dist/plus/integrations/models/integration.d.ts +9 -1
- package/dist/plus/integrations/models/integration.js +43 -3
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/providers/apiClients.d.ts +1 -0
- package/dist/plus/integrations/providers/apiClients.js +3 -0
- package/dist/plus/integrations/providers/apiClients.js.map +1 -1
- package/dist/plus/integrations/providers/azure/azure.d.ts +3 -0
- package/dist/plus/integrations/providers/azure/azure.js +130 -33
- 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/azureDevOps.d.ts +12 -0
- package/dist/plus/integrations/providers/azureDevOps.js +22 -0
- package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket/bitbucket.d.ts +21 -2
- package/dist/plus/integrations/providers/bitbucket/bitbucket.js +77 -32
- 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/bitbucket-server.d.ts +2 -0
- package/dist/plus/integrations/providers/bitbucket-server.js +11 -3
- package/dist/plus/integrations/providers/bitbucket-server.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket.d.ts +14 -0
- package/dist/plus/integrations/providers/bitbucket.js +30 -2
- package/dist/plus/integrations/providers/bitbucket.js.map +1 -1
- package/dist/plus/integrations/providers/github.d.ts +9 -4
- package/dist/plus/integrations/providers/github.js +12 -1
- package/dist/plus/integrations/providers/github.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +19 -1
- package/dist/plus/integrations/providers/gitlab/gitlab.js +128 -23
- 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/gitlab.d.ts +15 -2
- package/dist/plus/integrations/providers/gitlab.js +34 -4
- package/dist/plus/integrations/providers/gitlab.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/providerErrors.d.ts +8 -0
- package/dist/plus/integrations/providers/providerErrors.js +15 -2
- package/dist/plus/integrations/providers/providerErrors.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/pullRequestsForCommits.d.ts +45 -0
- package/dist/plus/integrations/reads/pullRequestsForCommits.js +97 -0
- package/dist/plus/integrations/reads/pullRequestsForCommits.js.map +1 -0
- package/dist/plus/integrations/utils/domain.utils.d.ts +1 -0
- package/dist/plus/integrations/utils/domain.utils.js +5 -1
- package/dist/plus/integrations/utils/domain.utils.js.map +1 -1
- package/dist/plus/integrations/utils/failureBackoff.d.ts +13 -0
- package/dist/plus/integrations/utils/failureBackoff.js +47 -0
- package/dist/plus/integrations/utils/failureBackoff.js.map +1 -0
- package/dist/utils/env/node/exec.js +2 -2
- package/docs/integrations.md +105 -15
- package/package.json +2 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { chunk } from "../../../../utils/array.js";
|
|
1
2
|
import { CancellationError, isCancellationError, raceWithSignal } from "../../../../utils/cancellation.js";
|
|
2
3
|
import { Logger as _logger } from "../../../../utils/logger.js";
|
|
3
4
|
import { getScopedLogger } from "../../../../utils/logger.scoped.js";
|
|
@@ -5,13 +6,13 @@ import { mapBounded } from "../../../../utils/promise.js";
|
|
|
5
6
|
import { trace } from "../../../../utils/decorators/log.js";
|
|
6
7
|
import { PromiseCache } from "../../../../utils/promiseCache.js";
|
|
7
8
|
import __decorate from "../../../../_virtual/@oxc-project+runtime/helpers/esm/decorate.js";
|
|
8
|
-
import { AuthenticationError, RequestClientError, RequestNotFoundError } from "../../../../git/errors.js";
|
|
9
|
+
import { AuthenticationError, RequestClientError, RequestNotFoundError, RequestRateLimitError, getDeferredRequestFailure, reportRequestFailure } from "../../../../git/errors.js";
|
|
10
|
+
import { sha256, uuid } from "../../../../utils/crypto.js";
|
|
9
11
|
import { maybeStopWatch } from "../../../../utils/stopwatch.js";
|
|
10
12
|
import { base64 } from "../../../../utils/base64.js";
|
|
11
|
-
import { sha256, uuid } from "../../../../utils/crypto.js";
|
|
12
13
|
import { effectiveIssueSort } from "../../../../git/utils/issue.utils.js";
|
|
13
14
|
import { ProviderFetchError, isRateLimitResponse, toRateLimitError } from "../../errors.js";
|
|
14
|
-
import { throwProviderError } from "../providerErrors.js";
|
|
15
|
+
import { CommitReadRefusedError, isCommitReadRefusal, isNotFoundResponse, throwProviderError } from "../providerErrors.js";
|
|
15
16
|
import { azureWorkItemSearchResultLimit, parseAzureWorkItemSearchCursor, toAzureSearchPageSize, toAzureWorkItemSearchCursorKey, toAzureWorkItemSearchQueries, toAzureWorkItemSearchWiql } from "./search.js";
|
|
16
17
|
import { decodePathSegment } from "../../utils/domain.utils.js";
|
|
17
18
|
import { azurePullRequestStatusToState, azureWorkItemsStateCategoryToState, encodeAzurePathSegment, fromAzurePullRequest, fromAzureWorkItem, getAzurePullRequestWebUrl, isClosedAzurePullRequestStatus, normalizeAzureBranchName, parseAzureWorkItemDate, sanitizeAzureRepositoryUrl } from "./models.js";
|
|
@@ -21,10 +22,14 @@ import { baseProviderApiConfig } from "../apiConfig.js";
|
|
|
21
22
|
import { createProviderApiRequest } from "../providerApiClient.js";
|
|
22
23
|
import { queryAzureWorkItemSearch } from "./workItemSearch.js";
|
|
23
24
|
import * as l10n from "@vscode/l10n";
|
|
25
|
+
import { captureReadNodes, copyReadProvenance, createReadCapture } from "@gitkraken/provider-apis/read-provenance";
|
|
24
26
|
import { AzureDevOps } from "@gitkraken/provider-apis";
|
|
25
27
|
//#region ../plus/integrations/src/providers/azure/azure.ts
|
|
26
28
|
const forkRepositoryUrlCacheTtl = 3e5;
|
|
27
29
|
const workItemMetadataConcurrency = 6;
|
|
30
|
+
/** KEEP: Azure DevOps documents no limit on a query's commits; 100 keeps a window to a few modest requests. */
|
|
31
|
+
const commitQueryChunkSize = 100;
|
|
32
|
+
const commitReadConcurrency = 6;
|
|
28
33
|
/** How long a work-item search's id snapshot outlives the last page read from it, and the most it lives at all. */
|
|
29
34
|
const workItemSearchSnapshotTtl = 3e5;
|
|
30
35
|
const workItemSearchSnapshotMaxTtl = 18e5;
|
|
@@ -107,23 +112,96 @@ var AzureDevOpsApi = class {
|
|
|
107
112
|
try {
|
|
108
113
|
const encodedProject = encodeAzurePathSegment(projectName);
|
|
109
114
|
const encodedRepo = encodeAzurePathSegment(repoName);
|
|
110
|
-
const
|
|
115
|
+
const answers = (await this.request(provider, token, baseUrl, `${encodeAzurePathSegment(owner)}/${encodedProject}/_apis/git/repositories/${encodedRepo}/pullrequestquery?api-version=${resource.apiVersion}`, {
|
|
111
116
|
method: "POST",
|
|
112
117
|
body: JSON.stringify({ queries: [{
|
|
113
118
|
items: [rev],
|
|
114
119
|
type: "commit"
|
|
115
120
|
}] })
|
|
116
|
-
}, scope, cancellation))?.results
|
|
121
|
+
}, scope, cancellation))?.results?.[0];
|
|
122
|
+
if (answers == null) throw new Error(`Azure DevOps returned no pull request query results for ${repo}`);
|
|
123
|
+
const pr = answers[rev]?.[0];
|
|
117
124
|
if (pr == null) return void 0;
|
|
118
125
|
const pullRequest = await this.request(provider, token, baseUrl, `${encodeAzurePathSegment(owner)}/${encodeAzurePathSegment(pr.repository.project.id)}/_apis/git/repositories/${encodeAzurePathSegment(pr.repository.id)}/pullRequests/${encodeAzurePathSegment(pr.pullRequestId.toString())}`, { method: "GET" }, scope, cancellation);
|
|
119
|
-
if (pullRequest == null)
|
|
126
|
+
if (pullRequest == null) throw new Error(`Azure DevOps returned no pull request ${pr.pullRequestId} for ${repo}`);
|
|
120
127
|
return await this.toPullRequest(pullRequest, provider, token, owner, baseUrl, scope, cancellation);
|
|
121
128
|
} catch (ex) {
|
|
122
|
-
if (ex
|
|
123
|
-
|
|
124
|
-
|
|
129
|
+
if (isNotFoundResponse(ex)) return void 0;
|
|
130
|
+
if (isCommitReadRefusal(ex)) throw new CommitReadRefusedError(ex.message, ex);
|
|
131
|
+
throw ex;
|
|
125
132
|
}
|
|
126
133
|
}
|
|
134
|
+
async getPullRequestsForCommits(provider, token, owner, repo, revs, baseUrl, options, cancellation) {
|
|
135
|
+
const scope = getScopedLogger();
|
|
136
|
+
const gate = options?.gate ?? ((send) => send());
|
|
137
|
+
const slots = revs.map(() => ({
|
|
138
|
+
status: "fulfilled",
|
|
139
|
+
value: void 0
|
|
140
|
+
}));
|
|
141
|
+
if (revs.length === 0) return slots;
|
|
142
|
+
const reject = (indexes, reason) => {
|
|
143
|
+
for (const index of indexes) slots[index] = {
|
|
144
|
+
status: "rejected",
|
|
145
|
+
reason
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
const { projectName, repoName } = parseAzureRepositoryDescriptor(repo);
|
|
149
|
+
const resource = await this.requireRestResource(provider, token, owner, baseUrl, "pullRequestQuery", "4.1", cancellation);
|
|
150
|
+
const route = `${encodeAzurePathSegment(owner)}/${encodeAzurePathSegment(projectName)}/_apis/git/repositories/${encodeAzurePathSegment(repoName)}/pullrequestquery?api-version=${resource.apiVersion}`;
|
|
151
|
+
const found = /* @__PURE__ */ new Map();
|
|
152
|
+
const forkFailures = [];
|
|
153
|
+
await mapBounded(chunk(revs.map((_, index) => index), commitQueryChunkSize), commitReadConcurrency, async (indexes) => {
|
|
154
|
+
let answers;
|
|
155
|
+
try {
|
|
156
|
+
answers = (await gate(() => this.request(provider, token, baseUrl, route, {
|
|
157
|
+
method: "POST",
|
|
158
|
+
body: JSON.stringify({ queries: [{
|
|
159
|
+
items: indexes.map((index) => revs[index]),
|
|
160
|
+
type: "commit"
|
|
161
|
+
}] })
|
|
162
|
+
}, scope, cancellation, true)))?.results?.[0];
|
|
163
|
+
} catch (ex) {
|
|
164
|
+
if (isNotFoundResponse(ex)) return;
|
|
165
|
+
reject(indexes, ex);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (answers == null) {
|
|
169
|
+
reject(indexes, /* @__PURE__ */ new Error(`Azure DevOps returned no pull request query results for ${repo}`));
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
for (const index of indexes) {
|
|
173
|
+
const pr = answers[revs[index]]?.[0];
|
|
174
|
+
if (pr == null) continue;
|
|
175
|
+
let match = found.get(pr.pullRequestId);
|
|
176
|
+
if (match == null) {
|
|
177
|
+
match = {
|
|
178
|
+
pr,
|
|
179
|
+
indexes: []
|
|
180
|
+
};
|
|
181
|
+
found.set(pr.pullRequestId, match);
|
|
182
|
+
}
|
|
183
|
+
match.indexes.push(index);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
await mapBounded([...found.values()], commitReadConcurrency, async ({ pr, indexes }) => {
|
|
187
|
+
try {
|
|
188
|
+
const pullRequest = await gate(() => this.request(provider, token, baseUrl, `${encodeAzurePathSegment(owner)}/${encodeAzurePathSegment(pr.repository.project.id)}/_apis/git/repositories/${encodeAzurePathSegment(pr.repository.id)}/pullRequests/${encodeAzurePathSegment(pr.pullRequestId.toString())}`, { method: "GET" }, scope, cancellation, true));
|
|
189
|
+
if (pullRequest == null) throw new Error(`Azure DevOps returned no pull request ${pr.pullRequestId} for ${repo}`);
|
|
190
|
+
const value = await this.toPullRequest(pullRequest, provider, token, owner, baseUrl, scope, cancellation, {
|
|
191
|
+
gate,
|
|
192
|
+
failures: forkFailures
|
|
193
|
+
});
|
|
194
|
+
for (const index of indexes) slots[index] = {
|
|
195
|
+
status: "fulfilled",
|
|
196
|
+
value
|
|
197
|
+
};
|
|
198
|
+
} catch (ex) {
|
|
199
|
+
reject(indexes, ex);
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
if (!slots.some((slot) => slot.status === "rejected" && getDeferredRequestFailure(slot.reason) != null)) forkFailures.map(getDeferredRequestFailure).find((notify) => notify != null)?.();
|
|
203
|
+
return slots;
|
|
204
|
+
}
|
|
127
205
|
async getPullRequest(provider, token, owner, projectOrName, id, options) {
|
|
128
206
|
const scope = getScopedLogger();
|
|
129
207
|
const projectName = projectOrName.split("/")[0];
|
|
@@ -156,7 +234,7 @@ var AzureDevOpsApi = class {
|
|
|
156
234
|
const state = issueResult.fields["System.State"];
|
|
157
235
|
const stateCategory = await this.getWorkItemStateCategory(issueType, state, provider, token, owner, projectName, options);
|
|
158
236
|
const normalizedState = azureWorkItemsStateCategoryToState(stateCategory, parseAzureWorkItemDate(issueResult.fields["Microsoft.VSTS.Common.ClosedDate"]) ?? void 0);
|
|
159
|
-
|
|
237
|
+
const result = {
|
|
160
238
|
id: issueResult.id.toString(),
|
|
161
239
|
type: "issue",
|
|
162
240
|
nodeId: issueResult.id.toString(),
|
|
@@ -168,22 +246,26 @@ var AzureDevOpsApi = class {
|
|
|
168
246
|
title: issueResult.fields["System.Title"],
|
|
169
247
|
url: issueResult._links.html.href
|
|
170
248
|
};
|
|
249
|
+
return copyReadProvenance(result, issueResult);
|
|
171
250
|
}
|
|
172
251
|
}
|
|
173
252
|
if (options?.type === void 0 || options?.type === "pullrequest") try {
|
|
174
253
|
const prResult = await this.request(provider, token, options?.baseUrl, `${encodeAzurePathSegment(owner)}/${encodeAzurePathSegment(projectName)}/_apis/git/repositories/${encodeAzurePathSegment(repoName)}/pullRequests/${encodeAzurePathSegment(id)}`, { method: "GET" }, scope);
|
|
175
|
-
if (prResult != null)
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
254
|
+
if (prResult != null) {
|
|
255
|
+
const result = {
|
|
256
|
+
id: prResult.pullRequestId.toString(),
|
|
257
|
+
type: "pullrequest",
|
|
258
|
+
nodeId: prResult.pullRequestId.toString(),
|
|
259
|
+
provider,
|
|
260
|
+
createdDate: new Date(prResult.creationDate),
|
|
261
|
+
updatedDate: new Date(prResult.creationDate),
|
|
262
|
+
state: azurePullRequestStatusToState(prResult.status),
|
|
263
|
+
closed: isClosedAzurePullRequestStatus(prResult.status),
|
|
264
|
+
title: prResult.title,
|
|
265
|
+
url: getAzurePullRequestWebUrl(prResult, options.baseUrl, owner)
|
|
266
|
+
};
|
|
267
|
+
return copyReadProvenance(result, prResult);
|
|
268
|
+
}
|
|
187
269
|
return;
|
|
188
270
|
} catch (ex) {
|
|
189
271
|
if (ex instanceof AuthenticationError) throw ex;
|
|
@@ -515,8 +597,8 @@ var AzureDevOpsApi = class {
|
|
|
515
597
|
const encodedRepo = encodeAzurePathSegment(repoName);
|
|
516
598
|
return this.request(provider, token, baseUrl, `${encodeAzurePathSegment(owner)}/${encodedProject}/_apis/git/repositories/${encodedRepo}?api-version=${apiVersion}`, { method: "GET" }, scope, cancellation);
|
|
517
599
|
}
|
|
518
|
-
async toPullRequest(pr, provider, token, owner, baseUrl, scope, cancellation) {
|
|
519
|
-
const forkRepositoryUrls = await this.getForkRepositoryUrls(provider, token, owner, baseUrl, pr.forkSource?.repository, scope, cancellation);
|
|
600
|
+
async toPullRequest(pr, provider, token, owner, baseUrl, scope, cancellation, batch) {
|
|
601
|
+
const forkRepositoryUrls = await this.getForkRepositoryUrls(provider, token, owner, baseUrl, pr.forkSource?.repository, scope, cancellation, batch);
|
|
520
602
|
return fromAzurePullRequest(pr, provider, owner, baseUrl, forkRepositoryUrls, "point");
|
|
521
603
|
}
|
|
522
604
|
/**
|
|
@@ -528,7 +610,7 @@ var AzureDevOpsApi = class {
|
|
|
528
610
|
* leaves the head ref without a URL. It must never cost the pull request itself, which is what makes swallowing
|
|
529
611
|
* the failure here the right call rather than a shortcut.
|
|
530
612
|
*/
|
|
531
|
-
async getForkRepositoryUrls(provider, token, owner, baseUrl, repository, scope, cancellation) {
|
|
613
|
+
async getForkRepositoryUrls(provider, token, owner, baseUrl, repository, scope, cancellation, batch) {
|
|
532
614
|
if (repository == null) return void 0;
|
|
533
615
|
let tokenHash;
|
|
534
616
|
try {
|
|
@@ -542,13 +624,14 @@ var AzureDevOpsApi = class {
|
|
|
542
624
|
owner,
|
|
543
625
|
repository.id
|
|
544
626
|
]);
|
|
545
|
-
return this._forkRepositoryUrls.getOrCreate(cacheKey, (cacheable, aggregate) => this.fetchForkRepositoryUrls(provider, token, owner, baseUrl, repository.id, cacheable, scope, aggregate), { cancellation });
|
|
627
|
+
return this._forkRepositoryUrls.getOrCreate(cacheKey, (cacheable, aggregate) => this.fetchForkRepositoryUrls(provider, token, owner, baseUrl, repository.id, cacheable, scope, aggregate, batch), { cancellation });
|
|
546
628
|
}
|
|
547
|
-
async fetchForkRepositoryUrls(provider, token, owner, baseUrl, repositoryId, cacheable, scope, cancellation) {
|
|
629
|
+
async fetchForkRepositoryUrls(provider, token, owner, baseUrl, repositoryId, cacheable, scope, cancellation, batch) {
|
|
630
|
+
const send = batch?.gate ?? ((request) => request());
|
|
548
631
|
try {
|
|
549
632
|
encodeAzurePathSegment(repositoryId);
|
|
550
633
|
const resource = await this.requireRestResource(provider, token, owner, baseUrl, "repositories", "4.1", cancellation);
|
|
551
|
-
const response = await this.request(provider, token, baseUrl, `${encodeAzurePathSegment(owner)}/_apis/git/repositories/${encodeAzurePathSegment(repositoryId)}?api-version=${resource.apiVersion}`, { method: "GET" }, scope, cancellation);
|
|
634
|
+
const response = await send(() => this.request(provider, token, baseUrl, `${encodeAzurePathSegment(owner)}/_apis/git/repositories/${encodeAzurePathSegment(repositoryId)}?api-version=${resource.apiVersion}`, { method: "GET" }, scope, cancellation, batch != null), (reason) => reason instanceof RequestRateLimitError);
|
|
552
635
|
const webUrl = sanitizeAzureRepositoryUrl(response?.webUrl, baseUrl, owner);
|
|
553
636
|
const cloneHttps = sanitizeAzureRepositoryUrl(response?.remoteUrl, baseUrl, owner);
|
|
554
637
|
const url = webUrl ?? cloneHttps;
|
|
@@ -562,6 +645,7 @@ var AzureDevOpsApi = class {
|
|
|
562
645
|
};
|
|
563
646
|
} catch (ex) {
|
|
564
647
|
if (!(ex instanceof RequestNotFoundError) && !(ex instanceof AuthenticationError)) cacheable.invalidate();
|
|
648
|
+
batch?.failures.push(ex);
|
|
565
649
|
const status = ex instanceof ProviderFetchError ? ` (${ex.status})` : "";
|
|
566
650
|
scope?.warn(`Unable to resolve the fork repository URLs${status}`);
|
|
567
651
|
return;
|
|
@@ -627,7 +711,7 @@ var AzureDevOpsApi = class {
|
|
|
627
711
|
if (result == null) throw new Error(`Azure DevOps REST resource ${resource} is unavailable`);
|
|
628
712
|
return result;
|
|
629
713
|
}
|
|
630
|
-
async request(provider, token, baseUrl, route, options, scope, cancellation) {
|
|
714
|
+
async request(provider, token, baseUrl, route, options, scope, cancellation, deferFailure) {
|
|
631
715
|
const { accessToken } = token;
|
|
632
716
|
const url = baseUrl ? `${baseUrl}/${route}` : route;
|
|
633
717
|
let rsp;
|
|
@@ -635,6 +719,7 @@ var AzureDevOpsApi = class {
|
|
|
635
719
|
const sw = maybeStopWatch(`[AZURE] ${options?.method ?? "GET"} request`, { log: { onlyExit: true } });
|
|
636
720
|
try {
|
|
637
721
|
if (cancellation?.aborted) throw new CancellationError();
|
|
722
|
+
const capture = createReadCapture();
|
|
638
723
|
rsp = await this.config.wrapForForcedInsecureSSL(provider.getIgnoreSSLErrors(), () => this.config.fetch(url, {
|
|
639
724
|
headers: {
|
|
640
725
|
Authorization: `Basic ${base64(`PAT:${accessToken}`)}`,
|
|
@@ -648,19 +733,19 @@ var AzureDevOpsApi = class {
|
|
|
648
733
|
const { accessToken: _accessToken, ...tokenInfo } = token;
|
|
649
734
|
throw new AuthenticationError(tokenInfo, 2, /* @__PURE__ */ new Error(`(${rsp.status}) Azure DevOps returned a sign-in page instead of data`));
|
|
650
735
|
}
|
|
651
|
-
return await rsp.json();
|
|
736
|
+
return captureReadNodes(await rsp.json(), capture);
|
|
652
737
|
}
|
|
653
738
|
throw await ProviderFetchError.fromResponse("AzureDevOps", rsp);
|
|
654
739
|
} finally {
|
|
655
740
|
sw?.stop();
|
|
656
741
|
}
|
|
657
742
|
} catch (ex) {
|
|
658
|
-
if (ex instanceof ProviderFetchError || ex.name === "AbortError") this.handleRequestError(provider, token, ex, scope);
|
|
743
|
+
if (ex instanceof ProviderFetchError || ex.name === "AbortError") this.handleRequestError(provider, token, ex, scope, deferFailure);
|
|
659
744
|
else if (_logger.isDebugging) this.config.onError?.(`AzureDevOps request failed: ${ex.message}`);
|
|
660
745
|
throw ex;
|
|
661
746
|
}
|
|
662
747
|
}
|
|
663
|
-
handleRequestError(provider, token, ex, scope) {
|
|
748
|
+
handleRequestError(provider, token, ex, scope, deferFailure) {
|
|
664
749
|
if (ex.name === "AbortError" || !(ex instanceof ProviderFetchError)) throw new CancellationError(ex);
|
|
665
750
|
const { accessToken, ...tokenInfo } = token;
|
|
666
751
|
switch (ex.status) {
|
|
@@ -674,7 +759,11 @@ var AzureDevOpsApi = class {
|
|
|
674
759
|
throw new AuthenticationError(tokenInfo, 3, ex);
|
|
675
760
|
case 500:
|
|
676
761
|
scope?.error(ex);
|
|
677
|
-
if (ex.response != null)
|
|
762
|
+
if (ex.response != null) {
|
|
763
|
+
const notify = () => this.config.onRequestFailed?.(provider == null || provider.id === "azure" ? l10n.t("{0} failed to respond and might be experiencing issues. Please visit the [AzureDevOps status page](https://status.dev.azure.com) for more information.", provider?.name ?? "AzureDevOps") : l10n.t("{0} failed to respond and might be experiencing issues.", provider.name));
|
|
764
|
+
if (deferFailure) reportRequestFailure(provider, ex, notify, true, token.connectionId);
|
|
765
|
+
else notify();
|
|
766
|
+
}
|
|
678
767
|
return;
|
|
679
768
|
case 502:
|
|
680
769
|
scope?.error(ex);
|
|
@@ -700,6 +789,14 @@ __decorate([trace({ args: (provider, token, owner, repo, rev, baseUrl) => ({
|
|
|
700
789
|
rev,
|
|
701
790
|
baseUrl
|
|
702
791
|
}) })], AzureDevOpsApi.prototype, "getPullRequestForCommit", null);
|
|
792
|
+
__decorate([trace({ args: (provider, token, owner, repo, revs, baseUrl) => ({
|
|
793
|
+
provider: provider.name,
|
|
794
|
+
token: `<token:${token.microHash}>`,
|
|
795
|
+
owner,
|
|
796
|
+
repo,
|
|
797
|
+
revs: revs.length,
|
|
798
|
+
baseUrl
|
|
799
|
+
}) })], AzureDevOpsApi.prototype, "getPullRequestsForCommits", null);
|
|
703
800
|
__decorate([trace({ args: (provider, token, owner, projectOrName, id) => ({
|
|
704
801
|
provider: provider.name,
|
|
705
802
|
token: `<token:${token.microHash}>`,
|