@gitkraken/core-gitlens 0.4.100 → 0.4.101
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 +4 -1
- package/dist/plus/integrations/errors.d.ts.map +1 -1
- package/dist/plus/integrations/errors.js +6 -2
- package/dist/plus/integrations/errors.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +8 -5
- package/dist/plus/integrations/integrationService.d.ts.map +1 -1
- package/dist/plus/integrations/integrationService.js +20 -652
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/models/gitHostIntegration.d.ts +10 -17
- package/dist/plus/integrations/models/gitHostIntegration.d.ts.map +1 -1
- package/dist/plus/integrations/models/gitHostIntegration.js +38 -88
- package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
- package/dist/plus/integrations/models/issuesIntegration.d.ts +4 -21
- package/dist/plus/integrations/models/issuesIntegration.d.ts.map +1 -1
- package/dist/plus/integrations/models/issuesIntegration.js +5 -47
- package/dist/plus/integrations/models/issuesIntegration.js.map +1 -1
- package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
- package/dist/plus/integrations/reads/broaden.d.ts +20 -0
- package/dist/plus/integrations/reads/broaden.d.ts.map +1 -0
- package/dist/plus/integrations/reads/broaden.js +326 -0
- package/dist/plus/integrations/reads/broaden.js.map +1 -0
- package/dist/plus/integrations/reads/context.d.ts +22 -0
- package/dist/plus/integrations/reads/context.d.ts.map +1 -1
- package/dist/plus/integrations/reads/hierarchy.d.ts +1 -1
- package/dist/plus/integrations/reads/hierarchy.d.ts.map +1 -1
- package/dist/plus/integrations/reads/hierarchy.js +109 -137
- package/dist/plus/integrations/reads/hierarchy.js.map +1 -1
- package/dist/plus/integrations/reads/hierarchy.utils.d.ts +25 -1
- package/dist/plus/integrations/reads/hierarchy.utils.d.ts.map +1 -1
- package/dist/plus/integrations/reads/hierarchy.utils.js +43 -0
- package/dist/plus/integrations/reads/hierarchy.utils.js.map +1 -1
- package/dist/plus/integrations/reads/issueTracker.d.ts +1 -1
- package/dist/plus/integrations/reads/issueTracker.d.ts.map +1 -1
- package/dist/plus/integrations/reads/issueTracker.js +13 -25
- package/dist/plus/integrations/reads/issueTracker.js.map +1 -1
- package/dist/plus/integrations/reads/issues.d.ts +2 -2
- package/dist/plus/integrations/reads/issues.d.ts.map +1 -1
- package/dist/plus/integrations/reads/issues.js.map +1 -1
- package/dist/plus/integrations/reads/pullRequests.d.ts +1 -1
- package/dist/plus/integrations/reads/pullRequests.d.ts.map +1 -1
- package/dist/plus/integrations/reads/pullRequests.js +1 -1
- package/dist/plus/integrations/reads/pullRequests.js.map +1 -1
- package/dist/plus/integrations/reads/resolveRepository.d.ts +25 -0
- package/dist/plus/integrations/reads/resolveRepository.d.ts.map +1 -0
- package/dist/plus/integrations/reads/resolveRepository.js +235 -0
- package/dist/plus/integrations/reads/resolveRepository.js.map +1 -0
- package/dist/plus/integrations/reads/sweeps.d.ts +11 -0
- package/dist/plus/integrations/reads/sweeps.d.ts.map +1 -0
- package/dist/plus/integrations/reads/sweeps.js +125 -0
- package/dist/plus/integrations/reads/sweeps.js.map +1 -0
- package/package.json +1 -1
- package/src/plus/integrations/errors.ts +6 -2
- package/src/plus/integrations/integrationService.ts +27 -801
- package/src/plus/integrations/models/gitHostIntegration.ts +71 -93
- package/src/plus/integrations/models/issuesIntegration.ts +5 -52
- package/src/plus/integrations/providers/azureDevOps.ts +1 -1
- package/src/plus/integrations/reads/broaden.ts +452 -0
- package/src/plus/integrations/reads/context.ts +24 -0
- package/src/plus/integrations/reads/hierarchy.ts +133 -153
- package/src/plus/integrations/reads/hierarchy.utils.ts +50 -1
- package/src/plus/integrations/reads/issueTracker.ts +15 -27
- package/src/plus/integrations/reads/issues.ts +4 -2
- package/src/plus/integrations/reads/pullRequests.ts +2 -9
- package/src/plus/integrations/reads/resolveRepository.ts +272 -0
- package/src/plus/integrations/reads/sweeps.ts +185 -0
|
@@ -4,37 +4,30 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { createRemoteProviderMatcher } from '../../git/remotes/matcher.js';
|
|
8
|
-
import { parseGitRemoteUrl } from '../../git/utils/remote.utils.js';
|
|
9
7
|
import { gate } from '../../utils/decorators/gate.js';
|
|
10
8
|
import { debug, trace } from '../../utils/decorators/log.js';
|
|
11
9
|
import { fromDisposables } from '../../utils/disposable.js';
|
|
12
10
|
import { Emitter } from '../../utils/event.js';
|
|
13
11
|
import { filterMap, flatten } from '../../utils/iterable.js';
|
|
14
12
|
import { getScopedLogger } from '../../utils/logger.scoped.js';
|
|
15
|
-
import { mapBounded } from '../../utils/promise.js';
|
|
16
13
|
import { CloudIntegrationService } from './authentication/cloudIntegrationService.js';
|
|
17
14
|
import { ConfiguredIntegrationService } from './authentication/configuredIntegrationService.js';
|
|
18
15
|
import { IntegrationAuthenticationService } from './authentication/integrationAuthenticationService.js';
|
|
19
16
|
import { getSupportedCloudIntegrationIds, isSupportedCloudIntegrationId, toIntegrationId, } from './authentication/models.js';
|
|
20
|
-
import {
|
|
21
|
-
import { GitCloudHostIntegrationId, GitSelfManagedHostIntegrationId, IssuesCloudHostIntegrationId, providerFanOutConcurrency, } from './constants.js';
|
|
22
|
-
import { AuthenticationError, RequestNotFoundError } from './errors.js';
|
|
23
|
-
import { isIssuesIntegration } from './models/issuesIntegration.js';
|
|
17
|
+
import { GitCloudHostIntegrationId, GitSelfManagedHostIntegrationId, IssuesCloudHostIntegrationId, } from './constants.js';
|
|
24
18
|
import { createApiClients } from './providers/apiClients.js';
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import { getSupportedFilters, resolveAccountWidePullRequestFilters, resolvePullRequestFilters, } from './reads/filters.js';
|
|
19
|
+
import { providersMetadata } from './providers/models.js';
|
|
20
|
+
import { broadenIssues } from './reads/broaden.js';
|
|
21
|
+
import { getSupportedFilters } from './reads/filters.js';
|
|
29
22
|
import { listOrgs, listProjects, listRepos } from './reads/hierarchy.js';
|
|
30
23
|
import { listIssuesPage } from './reads/issues.js';
|
|
31
24
|
import { listIssueTrackerIssuesPage } from './reads/issueTracker.js';
|
|
32
|
-
import { resolveContinuation, toProviderPageInfo } from './reads/paging.js';
|
|
33
25
|
import { listPullRequestsPage } from './reads/pullRequests.js';
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
26
|
+
import { resolveRepository } from './reads/resolveRepository.js';
|
|
27
|
+
import { sweepClosedPullRequests, sweepPullRequests } from './reads/sweeps.js';
|
|
28
|
+
import { noConnectionWarning } from './reads/warnings.js';
|
|
36
29
|
import { hostFromDomain } from './utils/domain.utils.js';
|
|
37
|
-
import { convertRemoteProviderIdToIntegrationId, getIntegrationIdForRemote, isCloudGitSelfManagedHostIntegrationId, isGitCloudHostIntegrationId,
|
|
30
|
+
import { convertRemoteProviderIdToIntegrationId, getIntegrationIdForRemote, isCloudGitSelfManagedHostIntegrationId, isGitCloudHostIntegrationId, isGitSelfManagedHostIntegrationId, isNonExpiringZeroTokenIntegrationId, remoteProviderTypeForConfig, remoteProviderTypeForIntegration, } from './utils/integration.utils.js';
|
|
38
31
|
const maxSmallIntegerV8 = 2 ** 30 - 1; // Max number that can be stored in V8's smis (small integers)
|
|
39
32
|
export class IntegrationService {
|
|
40
33
|
authenticationService;
|
|
@@ -634,140 +627,14 @@ export class IntegrationService {
|
|
|
634
627
|
* honored only when `providerIds` resolves to a single provider (otherwise ambiguous).
|
|
635
628
|
*/
|
|
636
629
|
async sweepPullRequests(options) {
|
|
637
|
-
|
|
638
|
-
const maxPages = options?.maxPages ?? 100;
|
|
639
|
-
const repos = options?.repos ?? [];
|
|
640
|
-
const results = await mapBounded(targets, providerFanOutConcurrency, async (target) => {
|
|
641
|
-
const { providerId: id, connectionId, domain: requestedDomain } = target;
|
|
642
|
-
if (isIssuesHostIntegrationId(id)) {
|
|
643
|
-
return {
|
|
644
|
-
items: [],
|
|
645
|
-
warnings: [gitHostOnlySurfaceWarning(id, requestedDomain, connectionId, 'pull request sweeps')],
|
|
646
|
-
fetchFailed: true,
|
|
647
|
-
truncated: false,
|
|
648
|
-
providerId: id,
|
|
649
|
-
failedProvider: true,
|
|
650
|
-
};
|
|
651
|
-
}
|
|
652
|
-
const integration = await this.getIntegrationForRead(id, connectionId, requestedDomain);
|
|
653
|
-
if (integration == null) {
|
|
654
|
-
// A requested connection that can't be resolved is a broken connection — surface it as a
|
|
655
|
-
// warning + fetchFailed rather than dropping the provider's slice silently.
|
|
656
|
-
const early = this.earlyReturnConnectionWarnings(id, connectionId, requestedDomain);
|
|
657
|
-
if (early.warnings.length === 0 && !attributeUnavailableProviders)
|
|
658
|
-
return undefined;
|
|
659
|
-
return {
|
|
660
|
-
items: [],
|
|
661
|
-
warnings: early.warnings.length !== 0
|
|
662
|
-
? early.warnings
|
|
663
|
-
: [noConnectionWarning(id, requestedDomain, connectionId)],
|
|
664
|
-
fetchFailed: true,
|
|
665
|
-
truncated: false,
|
|
666
|
-
providerId: id,
|
|
667
|
-
failedProvider: true,
|
|
668
|
-
};
|
|
669
|
-
}
|
|
670
|
-
if (!isGitHostIntegration(integration)) {
|
|
671
|
-
return {
|
|
672
|
-
items: [],
|
|
673
|
-
warnings: [gitHostOnlySurfaceWarning(id, requestedDomain, connectionId, 'pull request sweeps')],
|
|
674
|
-
fetchFailed: true,
|
|
675
|
-
truncated: false,
|
|
676
|
-
providerId: id,
|
|
677
|
-
failedProvider: true,
|
|
678
|
-
};
|
|
679
|
-
}
|
|
680
|
-
await this.forceRefreshIfRequested(integration, options?.forceSync, connectionId);
|
|
681
|
-
const domain = this.domainForRead(integration, id, connectionId, requestedDomain);
|
|
682
|
-
const accountWide = repos.length === 0;
|
|
683
|
-
const requestedFilters = target.filters ?? options?.filters;
|
|
684
|
-
const resolved = accountWide
|
|
685
|
-
? resolveAccountWidePullRequestFilters(id, requestedFilters)
|
|
686
|
-
: resolvePullRequestFilters(id, requestedFilters);
|
|
687
|
-
if (resolved.unsupported) {
|
|
688
|
-
return {
|
|
689
|
-
items: [],
|
|
690
|
-
warnings: [
|
|
691
|
-
accountWide
|
|
692
|
-
? unsupportedAccountWidePullRequestFiltersWarning(id, domain, connectionId, requestedFilters ?? [])
|
|
693
|
-
: unsupportedFiltersWarning(id, domain, connectionId),
|
|
694
|
-
],
|
|
695
|
-
fetchFailed: true,
|
|
696
|
-
truncated: false,
|
|
697
|
-
providerId: id,
|
|
698
|
-
failedProvider: true,
|
|
699
|
-
};
|
|
700
|
-
}
|
|
701
|
-
const drain = await drainPullRequests(integration, id, domain, repos, options?.states, resolved.filters, accountWide ? (options?.includeReviewRequested ?? false) : false, connectionId, maxPages, attributeUnavailableProviders);
|
|
702
|
-
const currentAccountId = drain.items.some(pr => pr.author != null)
|
|
703
|
-
? await getCurrentAccountId(integration, connectionId)
|
|
704
|
-
: undefined;
|
|
705
|
-
// Normalize the raw provider-apis PRs to the GitLens-owned shape here, where the per-provider
|
|
706
|
-
// `integration` (the mapper's provider reference) is in scope; the aggregation below only sees drains.
|
|
707
|
-
return {
|
|
708
|
-
...drain,
|
|
709
|
-
items: drain.items.map(pr => fromProviderPullRequest(pr, integration, { currentAccountId: currentAccountId })),
|
|
710
|
-
providerId: id,
|
|
711
|
-
};
|
|
712
|
-
});
|
|
713
|
-
const items = [];
|
|
714
|
-
const warnings = [];
|
|
715
|
-
const failedProviderIds = new Set();
|
|
716
|
-
const incompleteProviderIds = new Set();
|
|
717
|
-
let fetchFailed = false;
|
|
718
|
-
let truncated = false;
|
|
719
|
-
for (const drain of results) {
|
|
720
|
-
if (drain == null) {
|
|
721
|
-
continue;
|
|
722
|
-
}
|
|
723
|
-
items.push(...drain.items);
|
|
724
|
-
for (const w of drain.warnings) {
|
|
725
|
-
appendDedupedWarning(warnings, w);
|
|
726
|
-
}
|
|
727
|
-
if (drain.fetchFailed) {
|
|
728
|
-
fetchFailed = true;
|
|
729
|
-
}
|
|
730
|
-
if (drain.failedProvider) {
|
|
731
|
-
failedProviderIds.add(drain.providerId);
|
|
732
|
-
}
|
|
733
|
-
else if (drain.fetchFailed || drain.truncated) {
|
|
734
|
-
incompleteProviderIds.add(drain.providerId);
|
|
735
|
-
}
|
|
736
|
-
if (drain.truncated) {
|
|
737
|
-
truncated = true;
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
return {
|
|
741
|
-
items: items,
|
|
742
|
-
warnings: warnings,
|
|
743
|
-
// `allPages` asserts completeness — it must be false when any provider truncated (a single-page
|
|
744
|
-
// account-wide read that couldn't confirm it drained everything) OR a drain aborted on a read
|
|
745
|
-
// failure (its slice is incomplete). Either way the sweep did not read every page.
|
|
746
|
-
page: {
|
|
747
|
-
currentPage: 1,
|
|
748
|
-
itemsPerPage: items.length,
|
|
749
|
-
allPages: !truncated && !fetchFailed,
|
|
750
|
-
truncated: truncated || undefined,
|
|
751
|
-
},
|
|
752
|
-
// A sweep drains every page itself and exposes no cursor to resume — so `hasMore` must be false even
|
|
753
|
-
// when the read was incomplete. Terminal incompleteness is expressed through `page.truncated` +
|
|
754
|
-
// `allPages: false` + warnings; setting `hasMore: true` here would make a consumer that drains while
|
|
755
|
-
// `hasMore` re-run the identical sweep forever with no cursor to advance.
|
|
756
|
-
hasMore: false,
|
|
757
|
-
fetchFailed: fetchFailed || undefined,
|
|
758
|
-
failedProviderIds: [...failedProviderIds],
|
|
759
|
-
incompleteProviderIds: [...incompleteProviderIds],
|
|
760
|
-
};
|
|
630
|
+
return sweepPullRequests(this, options);
|
|
761
631
|
}
|
|
762
632
|
/**
|
|
763
633
|
* Closed/merged counterpart of {@link sweepPullRequests}, feeding Kepler's Kanban "done" column. Applies
|
|
764
634
|
* the native cross-provider state filter (`Closed` + `Merged`) so it works beyond GitHub.
|
|
765
635
|
*/
|
|
766
636
|
async sweepClosedPullRequests(options) {
|
|
767
|
-
return this
|
|
768
|
-
...options,
|
|
769
|
-
states: ['closed', 'merged'],
|
|
770
|
-
});
|
|
637
|
+
return sweepClosedPullRequests(this, options);
|
|
771
638
|
}
|
|
772
639
|
/**
|
|
773
640
|
* Broadens the user's issues by fanning out over the supplied orgs: for each org it lists the org's
|
|
@@ -781,301 +648,7 @@ export class IntegrationService {
|
|
|
781
648
|
* rather than globally.
|
|
782
649
|
*/
|
|
783
650
|
async broadenIssues(options) {
|
|
784
|
-
|
|
785
|
-
// Kepler's existing contract persists only a page number. When no opaque continuation was supplied,
|
|
786
|
-
// advance through prior pages internally so cursor-only providers still return the requested page.
|
|
787
|
-
// Each recursive call below carries a cursor, so it bypasses this block and performs exactly one round.
|
|
788
|
-
if (options.cursor == null && page > 1) {
|
|
789
|
-
let cursor;
|
|
790
|
-
let previous;
|
|
791
|
-
const traversalWarnings = [];
|
|
792
|
-
const broadenedProviderIds = new Set();
|
|
793
|
-
const failedProviderIds = new Set();
|
|
794
|
-
const incompleteProviderIds = new Set();
|
|
795
|
-
const mergeProviderAttribution = (result) => {
|
|
796
|
-
for (const providerId of result.failedProviderIds) {
|
|
797
|
-
if (broadenedProviderIds.has(providerId) || result.broadenedProviderIds.includes(providerId)) {
|
|
798
|
-
incompleteProviderIds.add(providerId);
|
|
799
|
-
}
|
|
800
|
-
else {
|
|
801
|
-
failedProviderIds.add(providerId);
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
for (const providerId of result.incompleteProviderIds) {
|
|
805
|
-
failedProviderIds.delete(providerId);
|
|
806
|
-
incompleteProviderIds.add(providerId);
|
|
807
|
-
}
|
|
808
|
-
for (const providerId of result.broadenedProviderIds) {
|
|
809
|
-
broadenedProviderIds.add(providerId);
|
|
810
|
-
if (failedProviderIds.delete(providerId)) {
|
|
811
|
-
incompleteProviderIds.add(providerId);
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
};
|
|
815
|
-
let traversalFetchFailed = false;
|
|
816
|
-
let traversalTruncated = false;
|
|
817
|
-
for (let currentPage = 1; currentPage < page; currentPage++) {
|
|
818
|
-
previous = await this.broadenIssues({
|
|
819
|
-
...options,
|
|
820
|
-
page: currentPage,
|
|
821
|
-
cursor: cursor,
|
|
822
|
-
// A forced refresh belongs to the logical read, not every cursor-advancement round.
|
|
823
|
-
forceSync: currentPage === 1 ? options.forceSync : false,
|
|
824
|
-
});
|
|
825
|
-
for (const warning of previous.warnings) {
|
|
826
|
-
appendDedupedWarning(traversalWarnings, warning);
|
|
827
|
-
}
|
|
828
|
-
mergeProviderAttribution(previous);
|
|
829
|
-
traversalFetchFailed ||= previous.fetchFailed === true;
|
|
830
|
-
traversalTruncated ||= previous.page.truncated === true;
|
|
831
|
-
if (!previous.hasMore || previous.cursor == null) {
|
|
832
|
-
return {
|
|
833
|
-
items: [],
|
|
834
|
-
warnings: traversalWarnings,
|
|
835
|
-
page: {
|
|
836
|
-
currentPage: page,
|
|
837
|
-
itemsPerPage: 0,
|
|
838
|
-
truncated: traversalTruncated || undefined,
|
|
839
|
-
},
|
|
840
|
-
hasMore: false,
|
|
841
|
-
fetchFailed: traversalFetchFailed || undefined,
|
|
842
|
-
broadenedProviderIds: [...broadenedProviderIds],
|
|
843
|
-
failedProviderIds: [...failedProviderIds],
|
|
844
|
-
incompleteProviderIds: [...incompleteProviderIds],
|
|
845
|
-
fanOutCount: options.orgs.length,
|
|
846
|
-
};
|
|
847
|
-
}
|
|
848
|
-
cursor = previous.cursor;
|
|
849
|
-
}
|
|
850
|
-
const requested = await this.broadenIssues({ ...options, page: page, cursor: cursor, forceSync: false });
|
|
851
|
-
for (const warning of requested.warnings) {
|
|
852
|
-
appendDedupedWarning(traversalWarnings, warning);
|
|
853
|
-
}
|
|
854
|
-
mergeProviderAttribution(requested);
|
|
855
|
-
return {
|
|
856
|
-
...requested,
|
|
857
|
-
warnings: traversalWarnings,
|
|
858
|
-
page: {
|
|
859
|
-
...requested.page,
|
|
860
|
-
truncated: traversalTruncated || requested.page.truncated === true || undefined,
|
|
861
|
-
},
|
|
862
|
-
fetchFailed: traversalFetchFailed || requested.fetchFailed === true || undefined,
|
|
863
|
-
broadenedProviderIds: [...broadenedProviderIds],
|
|
864
|
-
failedProviderIds: [...failedProviderIds],
|
|
865
|
-
incompleteProviderIds: [...incompleteProviderIds],
|
|
866
|
-
};
|
|
867
|
-
}
|
|
868
|
-
const results = await mapBounded(options.orgs, providerFanOutConcurrency, async (org) => {
|
|
869
|
-
const connectionId = org.connectionId;
|
|
870
|
-
const requestedDomain = org.domain;
|
|
871
|
-
const cursorDomain = hostFromDomain(requestedDomain) ?? requestedDomain;
|
|
872
|
-
// An org slice that yielded no issues and has nothing to continue: the org's identity (which the
|
|
873
|
-
// aggregation below keys the per-org cursor bundle by) plus why it produced nothing. `exhausted` marks
|
|
874
|
-
// an org a prior round already drained, so it stays skipped rather than being re-read from page 1.
|
|
875
|
-
const barrenSlice = (warnings, flags) => ({
|
|
876
|
-
items: [],
|
|
877
|
-
warnings: warnings,
|
|
878
|
-
broadenedProviderIds: [],
|
|
879
|
-
providerId: org.providerId,
|
|
880
|
-
org: org.name,
|
|
881
|
-
connectionId: connectionId,
|
|
882
|
-
domain: cursorDomain,
|
|
883
|
-
nextCursor: undefined,
|
|
884
|
-
hasMore: false,
|
|
885
|
-
exhausted: flags?.exhausted ?? false,
|
|
886
|
-
fetchFailed: flags?.fetchFailed ?? false,
|
|
887
|
-
truncated: flags?.truncated ?? false,
|
|
888
|
-
});
|
|
889
|
-
if (isIssuesHostIntegrationId(org.providerId)) {
|
|
890
|
-
return barrenSlice([gitHostOnlySurfaceWarning(org.providerId, requestedDomain, connectionId, 'issue broadening')], { fetchFailed: true });
|
|
891
|
-
}
|
|
892
|
-
const integration = await this.getIntegrationForRead(org.providerId, connectionId, requestedDomain);
|
|
893
|
-
if (integration == null) {
|
|
894
|
-
// A requested connection or domain that can't be resolved is a broken target — surface it as a
|
|
895
|
-
// warning + fetchFailed rather than dropping the org silently.
|
|
896
|
-
const early = this.earlyReturnConnectionWarnings(org.providerId, connectionId, requestedDomain);
|
|
897
|
-
return barrenSlice(early.warnings.length > 0
|
|
898
|
-
? early.warnings
|
|
899
|
-
: [noConnectionWarning(org.providerId, requestedDomain, connectionId)], { fetchFailed: true });
|
|
900
|
-
}
|
|
901
|
-
if (!isGitHostIntegration(integration)) {
|
|
902
|
-
return barrenSlice([gitHostOnlySurfaceWarning(org.providerId, requestedDomain, connectionId, 'issue broadening')], { fetchFailed: true });
|
|
903
|
-
}
|
|
904
|
-
// A git host whose issue tracker is deprecated (Bitbucket) exposes no issues here — surface a
|
|
905
|
-
// warning + fetchFailed and skip it (no repo drain), so broadening never serves a legacy source.
|
|
906
|
-
if (!integration.supportsIssues) {
|
|
907
|
-
return barrenSlice([
|
|
908
|
-
issuesUnsupportedWarning(org.providerId, this.domainForRead(integration, org.providerId, connectionId, requestedDomain), connectionId),
|
|
909
|
-
], { fetchFailed: true });
|
|
910
|
-
}
|
|
911
|
-
// An org a prior round already drained must not be re-read: cursor-only providers would answer a
|
|
912
|
-
// fresh page-1 request with their first page again, duplicating issues across rounds. Skip it
|
|
913
|
-
// before any work (including the repo drain) and keep it marked exhausted so it stays skipped
|
|
914
|
-
// for the rest of the fan-out.
|
|
915
|
-
if (isBroadenIssuesOrgExhausted(options.cursor, org, options.orgs.length)) {
|
|
916
|
-
return barrenSlice([], { exhausted: true });
|
|
917
|
-
}
|
|
918
|
-
await this.forceRefreshIfRequested(integration, options.forceSync, connectionId);
|
|
919
|
-
const domain = this.domainForRead(integration, org.providerId, connectionId, requestedDomain);
|
|
920
|
-
const reposDrain = await drainRepositories(integration, org.providerId, domain, org.name, undefined, connectionId, 100);
|
|
921
|
-
const warnings = [...reposDrain.warnings];
|
|
922
|
-
const fetchFailed = reposDrain.fetchFailed;
|
|
923
|
-
const truncated = reposDrain.truncated;
|
|
924
|
-
const repos = reposDrain.repos.map(r => ({ ...r }));
|
|
925
|
-
if (repos.length === 0) {
|
|
926
|
-
return barrenSlice(warnings, { fetchFailed: fetchFailed, truncated: truncated });
|
|
927
|
-
}
|
|
928
|
-
// Broaden = "all visible": drop the assigned-to-me filter so unassigned issues are included.
|
|
929
|
-
const cursor = getBroadenIssuesCursor(options.cursor, org, page, options.orgs.length);
|
|
930
|
-
const issuesCaptured = await runCaptured(org.providerId, domain, connectionId, () =>
|
|
931
|
-
// Normalized shapes seam, uniform with listIssuesPage.
|
|
932
|
-
integration.getMyIssuesForReposAsShapesResult(repos, {
|
|
933
|
-
includeAllAssignees: true,
|
|
934
|
-
cursor: cursor,
|
|
935
|
-
}, connectionId), { warnOnMissingSession: true });
|
|
936
|
-
if (issuesCaptured.warning != null) {
|
|
937
|
-
warnings.push(issuesCaptured.warning);
|
|
938
|
-
}
|
|
939
|
-
const issuesAssessment = mergeAssessmentInto(warnings, org.providerId, domain, connectionId, issuesCaptured.value?.metadata);
|
|
940
|
-
let issuesFetchFailed = issuesAssessment.fetchFailed || (issuesCaptured.warning != null && issuesCaptured.value == null);
|
|
941
|
-
const items = [];
|
|
942
|
-
let hasMore = false;
|
|
943
|
-
let nextCursor;
|
|
944
|
-
let retryPage;
|
|
945
|
-
// Carry a truncation signal from the issue read too: a provider that couldn't confirm it drained
|
|
946
|
-
// a repo (`paging.truncated`) means this org's issues may be incomplete, on top of any repo-drain
|
|
947
|
-
// truncation already captured above.
|
|
948
|
-
let issuesTruncated = false;
|
|
949
|
-
if (issuesCaptured.value != null) {
|
|
950
|
-
items.push(...issuesCaptured.value.values);
|
|
951
|
-
const paged = toProviderPageInfo(issuesCaptured.value.values.length, issuesCaptured.value.paging);
|
|
952
|
-
// An org that reports another page but no usable cursor can't be resumed: it would neither be
|
|
953
|
-
// recorded in the composite cursor nor marked exhausted, so the next round would re-read its
|
|
954
|
-
// page 1 and repeat every issue. Treat it as terminal-but-incomplete (which also marks the org
|
|
955
|
-
// exhausted below, since `exhausted` keys off `!hasMore`).
|
|
956
|
-
const continuation = resolveContinuation(paged, undefined);
|
|
957
|
-
hasMore = continuation.hasMore;
|
|
958
|
-
nextCursor = continuation.cursor;
|
|
959
|
-
issuesTruncated = continuation.truncated || issuesAssessment.truncated;
|
|
960
|
-
}
|
|
961
|
-
else if (issuesCaptured.warning != null || cursor != null) {
|
|
962
|
-
// Keep the exact position that failed. Without this retry cursor a multi-org continuation would
|
|
963
|
-
// omit this org from the bundle, then synthesize the next numbered page and silently skip the
|
|
964
|
-
// failed page. The synthesized page cursor is also actionable for a first-page cursor-only read:
|
|
965
|
-
// that provider ignores the page marker and retries its first page. A retry slot alone is NOT
|
|
966
|
-
// forward progress, though: advertising `hasMore` for a persistent failure would make an infinite
|
|
967
|
-
// query request it forever. Healthy sibling continuations set `hasMore` independently.
|
|
968
|
-
if (cursor != null) {
|
|
969
|
-
nextCursor = cursor;
|
|
970
|
-
if (issuesCaptured.warning == null) {
|
|
971
|
-
appendDedupedWarning(warnings, otherWarning(org.providerId, domain, connectionId, 'Issue continuation returned no result and must be retried'));
|
|
972
|
-
issuesFetchFailed = true;
|
|
973
|
-
issuesTruncated = true;
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
else {
|
|
977
|
-
retryPage = page;
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
return {
|
|
981
|
-
items: items,
|
|
982
|
-
warnings: warnings,
|
|
983
|
-
broadenedProviderIds: issuesCaptured.value != null ? [org.providerId] : [],
|
|
984
|
-
providerId: org.providerId,
|
|
985
|
-
org: org.name,
|
|
986
|
-
connectionId: connectionId,
|
|
987
|
-
domain: cursorDomain,
|
|
988
|
-
nextCursor: nextCursor,
|
|
989
|
-
retryPage: retryPage,
|
|
990
|
-
hasMore: hasMore,
|
|
991
|
-
// Exhausted once a successful read reports no more pages — recorded in the cursor so later
|
|
992
|
-
// rounds skip it while other orgs keep paging.
|
|
993
|
-
exhausted: issuesCaptured.value != null && !hasMore,
|
|
994
|
-
fetchFailed: fetchFailed || issuesFetchFailed,
|
|
995
|
-
truncated: truncated || issuesTruncated,
|
|
996
|
-
};
|
|
997
|
-
});
|
|
998
|
-
const items = [];
|
|
999
|
-
const warnings = [];
|
|
1000
|
-
const broadenedProviderIds = new Set();
|
|
1001
|
-
const problemProviderIds = new Set();
|
|
1002
|
-
const cursors = [];
|
|
1003
|
-
const exhausted = [];
|
|
1004
|
-
let hasMore = false;
|
|
1005
|
-
let fetchFailed = false;
|
|
1006
|
-
let truncated = false;
|
|
1007
|
-
for (const result of results) {
|
|
1008
|
-
if (result == null) {
|
|
1009
|
-
continue;
|
|
1010
|
-
}
|
|
1011
|
-
items.push(...result.items);
|
|
1012
|
-
warnings.push(...result.warnings);
|
|
1013
|
-
for (const id of result.broadenedProviderIds) {
|
|
1014
|
-
broadenedProviderIds.add(id);
|
|
1015
|
-
}
|
|
1016
|
-
const retryPage = 'retryPage' in result ? result.retryPage : undefined;
|
|
1017
|
-
if (result.nextCursor != null || retryPage != null) {
|
|
1018
|
-
cursors.push({
|
|
1019
|
-
providerId: result.providerId,
|
|
1020
|
-
org: result.org,
|
|
1021
|
-
connectionId: result.connectionId,
|
|
1022
|
-
domain: result.domain,
|
|
1023
|
-
cursor: result.nextCursor,
|
|
1024
|
-
retryPage: retryPage,
|
|
1025
|
-
});
|
|
1026
|
-
}
|
|
1027
|
-
if (result.exhausted) {
|
|
1028
|
-
exhausted.push({
|
|
1029
|
-
providerId: result.providerId,
|
|
1030
|
-
org: result.org,
|
|
1031
|
-
connectionId: result.connectionId,
|
|
1032
|
-
domain: result.domain,
|
|
1033
|
-
});
|
|
1034
|
-
}
|
|
1035
|
-
if (result.hasMore) {
|
|
1036
|
-
hasMore = true;
|
|
1037
|
-
}
|
|
1038
|
-
if (result.fetchFailed) {
|
|
1039
|
-
fetchFailed = true;
|
|
1040
|
-
}
|
|
1041
|
-
if (result.truncated) {
|
|
1042
|
-
truncated = true;
|
|
1043
|
-
}
|
|
1044
|
-
if (result.fetchFailed || result.truncated) {
|
|
1045
|
-
problemProviderIds.add(result.providerId);
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
const cursor = toBroadenIssuesCursor(cursors, exhausted, options.orgs.length);
|
|
1049
|
-
const failedProviderIds = [];
|
|
1050
|
-
const incompleteProviderIds = [];
|
|
1051
|
-
for (const providerId of problemProviderIds) {
|
|
1052
|
-
if (broadenedProviderIds.has(providerId)) {
|
|
1053
|
-
incompleteProviderIds.push(providerId);
|
|
1054
|
-
}
|
|
1055
|
-
else {
|
|
1056
|
-
failedProviderIds.push(providerId);
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
return {
|
|
1060
|
-
items: items,
|
|
1061
|
-
warnings: warnings,
|
|
1062
|
-
// `currentPage` is positional, per ProviderPageInfo.currentPage: this fan-out has no provider-reported
|
|
1063
|
-
// page of its own (its cursor is a per-org bundle, not a page), so the position is the one the caller
|
|
1064
|
-
// addressed — the `page` it supplied, or the page the internal traversal advanced to.
|
|
1065
|
-
page: { currentPage: page, itemsPerPage: items.length, truncated: truncated || undefined },
|
|
1066
|
-
// `hasMore` promises a resumable continuation, so it must be true ONLY when a real cursor was
|
|
1067
|
-
// produced. Repo-drain truncation (a backstop hit with no persisted repo cursor) can't be resumed —
|
|
1068
|
-
// re-invoking would re-drain the same repos and repeat issues — so it is surfaced as the terminal
|
|
1069
|
-
// `page.truncated` incompleteness signal instead of `hasMore`, matching listRepos. Guard `hasMore`
|
|
1070
|
-
// against a missing cursor so we never advertise a continuation the caller can't make.
|
|
1071
|
-
hasMore: hasMore && cursor != null,
|
|
1072
|
-
cursor: cursor,
|
|
1073
|
-
fetchFailed: fetchFailed || undefined,
|
|
1074
|
-
broadenedProviderIds: [...broadenedProviderIds],
|
|
1075
|
-
failedProviderIds: failedProviderIds,
|
|
1076
|
-
incompleteProviderIds: incompleteProviderIds,
|
|
1077
|
-
fanOutCount: options.orgs.length,
|
|
1078
|
-
};
|
|
651
|
+
return broadenIssues(this, options);
|
|
1079
652
|
}
|
|
1080
653
|
/**
|
|
1081
654
|
* Resolves a repository from a remote URL to its provider identity, using core-gitlens' remote matcher
|
|
@@ -1084,220 +657,15 @@ export class IntegrationService {
|
|
|
1084
657
|
* canonicalization policy.
|
|
1085
658
|
*/
|
|
1086
659
|
async resolveRepository(options) {
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
const matcherDomain = parsedDomain || options.host || '';
|
|
1097
|
-
// An explicit cloud provider must agree with the remote's canonical cloud host. Without this guard the
|
|
1098
|
-
// synthetic matcher below can reinterpret, for example, a gitlab.com URL as GitHub and then resolve a
|
|
1099
|
-
// homonymous owner/repo through the wrong account. Match once without caller configs/synthetic entries;
|
|
1100
|
-
// Azure's matcher also normalizes ssh.dev.azure.com and vs-ssh.visualstudio.com to their web host.
|
|
1101
|
-
if (options.providerId != null && isGitCloudHostIntegrationId(options.providerId)) {
|
|
1102
|
-
const nativeProvider = createRemoteProviderMatcher([])(options.remoteUrl, matcherDomain, path, scheme);
|
|
1103
|
-
const nativeId = nativeProvider != null ? getIntegrationIdForRemote(nativeProvider) : undefined;
|
|
1104
|
-
const nativeDomain = nativeProvider?.domain ?? matcherDomain;
|
|
1105
|
-
const canonicalHost = options.providerId === GitCloudHostIntegrationId.GitHub
|
|
1106
|
-
? isGitHubDotCom(nativeDomain)
|
|
1107
|
-
: options.providerId === GitCloudHostIntegrationId.GitLab
|
|
1108
|
-
? isGitLabDotCom(nativeDomain)
|
|
1109
|
-
: options.providerId === GitCloudHostIntegrationId.Bitbucket
|
|
1110
|
-
? isBitbucketCloudDomain(nativeDomain)
|
|
1111
|
-
: isAzureCloudDomain(nativeDomain);
|
|
1112
|
-
if (nativeId !== options.providerId || !canonicalHost)
|
|
1113
|
-
return result('host-mismatch');
|
|
1114
|
-
}
|
|
1115
|
-
// Matcher configs: host remote configs (self-managed/custom domains) plus a synthetic entry for an
|
|
1116
|
-
// explicit providerId + host, so a custom domain still maps to the right provider for path parsing.
|
|
1117
|
-
const configs = [];
|
|
1118
|
-
for (const cfg of this.ctx.config.getRemoteConfigs()) {
|
|
1119
|
-
const type = remoteProviderTypeForConfig(cfg.type);
|
|
1120
|
-
if (type == null)
|
|
1121
|
-
continue;
|
|
1122
|
-
// Forward both domain- and regex-based custom remotes (carrying any protocol override), so a
|
|
1123
|
-
// regex-configured host resolves instead of falling through to `unsupported`.
|
|
1124
|
-
if (cfg.domain) {
|
|
1125
|
-
configs.push({ type: type, domain: cfg.domain, protocol: cfg.protocol });
|
|
1126
|
-
}
|
|
1127
|
-
else if (cfg.regex) {
|
|
1128
|
-
configs.push({ type: type, regex: cfg.regex, protocol: cfg.protocol });
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
|
-
if (options.providerId != null) {
|
|
1132
|
-
const type = remoteProviderTypeForIntegration(options.providerId);
|
|
1133
|
-
const domain = parsedDomain || options.host;
|
|
1134
|
-
if (type != null && domain) {
|
|
1135
|
-
// The synthetic exact-domain entry is unshifted to the front, so it wins the match over the
|
|
1136
|
-
// user's own config for the same host. Carry that config's protocol override across (matched by
|
|
1137
|
-
// domain or regex, mirroring `ignoreSSLErrors`) so a self-managed host configured for a custom
|
|
1138
|
-
// protocol — e.g. plain `http` — isn't silently downgraded to the provider default here.
|
|
1139
|
-
const lowerDomain = domain.toLowerCase();
|
|
1140
|
-
const protocol = configs.find(c => {
|
|
1141
|
-
if (c.type !== type)
|
|
1142
|
-
return false;
|
|
1143
|
-
if (c.domain != null)
|
|
1144
|
-
return c.domain.toLowerCase() === lowerDomain;
|
|
1145
|
-
// Truthy (not just non-null): an empty regex would compile to a match-everything pattern.
|
|
1146
|
-
if (c.regex) {
|
|
1147
|
-
try {
|
|
1148
|
-
return new RegExp(c.regex, 'i').test(lowerDomain);
|
|
1149
|
-
}
|
|
1150
|
-
catch {
|
|
1151
|
-
return false;
|
|
1152
|
-
}
|
|
1153
|
-
}
|
|
1154
|
-
return false;
|
|
1155
|
-
})?.protocol;
|
|
1156
|
-
configs.unshift({ type: type, domain: domain, protocol: protocol });
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
const provider = createRemoteProviderMatcher(configs)(options.remoteUrl, matcherDomain, path, scheme);
|
|
1160
|
-
if (provider == null)
|
|
1161
|
-
return result('invalid-remote-url');
|
|
1162
|
-
let id = options.providerId ?? getIntegrationIdForRemote(provider);
|
|
1163
|
-
// Custom Azure DevOps Server domains matched via getRemoteConfigs return undefined from
|
|
1164
|
-
// getIntegrationIdForRemote because the provider is marked custom; map them to the server id so the
|
|
1165
|
-
// project-scoped lookup uses that host's configured connection and API base URL.
|
|
1166
|
-
if (id == null && provider.id === 'azure-devops' && provider.custom) {
|
|
1167
|
-
id = GitSelfManagedHostIntegrationId.AzureDevOpsServer;
|
|
1168
|
-
}
|
|
1169
|
-
if (id == null)
|
|
1170
|
-
return result('unsupported-provider');
|
|
1171
|
-
const owner = provider.owner;
|
|
1172
|
-
const name = provider.repoName;
|
|
1173
|
-
if (owner == null || name == null)
|
|
1174
|
-
return result('invalid-remote-url');
|
|
1175
|
-
// On a self-managed host, resolve only against a TRUSTED host: the pinned connection's configured
|
|
1176
|
-
// domain, the explicit `domain`, or — when neither was supplied — a configured host matching the
|
|
1177
|
-
// remote's. That last case keeps `remoteUrl` (repository-supplied) out of the trusted path: it selects
|
|
1178
|
-
// among hosts the user already authenticated and can never introduce a new one. Resolving `owner/repo`
|
|
1179
|
-
// against some other host's account would, if that host has the same owner/repo, return a confidently
|
|
1180
|
-
// wrong identity — and would seed the domain-keyed integration cache (never evicted before dispose) with
|
|
1181
|
-
// an entry derived from repository data.
|
|
1182
|
-
const urlHost = hostFromDomain(provider.domain);
|
|
1183
|
-
// Normalize BOTH sides before comparing: a stored connection domain is usually a full URL
|
|
1184
|
-
// (`https://git.example.com`) while `urlHost` is already a bare host, so a raw compare would fail on
|
|
1185
|
-
// scheme/trailing-slash alone and wrongly reject a correctly-configured connection.
|
|
1186
|
-
let trustedHost = options.connectionId != null || options.domain != null
|
|
1187
|
-
? hostFromDomain(this.resolveDomainForRead(id, options.connectionId, options.domain))
|
|
1188
|
-
: undefined;
|
|
1189
|
-
if (isGitSelfManagedHostIntegrationId(id)) {
|
|
1190
|
-
const configuredHosts = this.getConfigured(id).map(c => hostFromDomain(c.domain));
|
|
1191
|
-
if (trustedHost == null && urlHost != null) {
|
|
1192
|
-
trustedHost = configuredHosts.find(host => host === urlHost);
|
|
1193
|
-
}
|
|
1194
|
-
// A configured host that doesn't match the remote's is a genuine mismatch. With nothing configured
|
|
1195
|
-
// there is no host to mismatch against — it's simply not connected, so fall through to the
|
|
1196
|
-
// `unauthorized` path below (still WITHOUT resolving by the URL domain, so repo data can't seed the
|
|
1197
|
-
// cache).
|
|
1198
|
-
if (trustedHost == null && configuredHosts.length !== 0)
|
|
1199
|
-
return result('host-mismatch');
|
|
1200
|
-
if (trustedHost != null && urlHost != null && trustedHost !== urlHost)
|
|
1201
|
-
return result('host-mismatch');
|
|
1202
|
-
}
|
|
1203
|
-
let integration;
|
|
1204
|
-
try {
|
|
1205
|
-
// Resolve the instance through the trusted target (as `getIntegrationForRead` does):
|
|
1206
|
-
// `resolveReadSession` looks the session up against the instance's domain-scoped descriptor, so
|
|
1207
|
-
// selecting the instance by the URL domain could miss the session and degrade to `no-connection`.
|
|
1208
|
-
integration = isGitSelfManagedHostIntegrationId(id)
|
|
1209
|
-
? trustedHost != null
|
|
1210
|
-
? await this.getIntegrationForRead(id, options.connectionId, trustedHost)
|
|
1211
|
-
: undefined
|
|
1212
|
-
: await this.get(id, provider.domain);
|
|
1213
|
-
}
|
|
1214
|
-
catch {
|
|
1215
|
-
integration = undefined;
|
|
1216
|
-
}
|
|
1217
|
-
if (integration == null) {
|
|
1218
|
-
// Attach a warning, as the thrown-AuthenticationError branch below does: a consumer driving auth
|
|
1219
|
-
// recovery off `warning.kind` would otherwise get nothing for an unresolvable target.
|
|
1220
|
-
return {
|
|
1221
|
-
resolution: {
|
|
1222
|
-
status: 'unauthorized',
|
|
1223
|
-
warning: noConnectionWarning(id, provider.domain, options.connectionId),
|
|
1224
|
-
},
|
|
1225
|
-
};
|
|
1226
|
-
}
|
|
1227
|
-
// Issue trackers have no `getRepo` client; a git host without `getRepoFn` leaves `getRepoInfo`
|
|
1228
|
-
// undefined. Either way this provider can't resolve repositories.
|
|
1229
|
-
if (isIssuesIntegration(integration) || integration.getRepoInfo == null) {
|
|
1230
|
-
return result('unsupported-provider');
|
|
1231
|
-
}
|
|
1232
|
-
// Azure repos are org + project scoped; the remote provider exposes project as `providerDesc.repoDomain`.
|
|
1233
|
-
const project = provider.id === 'azure-devops' ? provider.providerDesc?.repoDomain : undefined;
|
|
1234
|
-
const domain = provider.domain;
|
|
1235
|
-
// Azure's lookup is project-scoped and returns `undefined` without one, which the connection-gap branch
|
|
1236
|
-
// below would misreport as `unauthorized` (driving a pointless reconnect). A remote URL that carries no
|
|
1237
|
-
// project simply can't address an Azure repo.
|
|
1238
|
-
if (provider.id === 'azure-devops' && project == null)
|
|
1239
|
-
return result('invalid-remote-url');
|
|
1240
|
-
try {
|
|
1241
|
-
const repo = await integration.getRepoInfo({
|
|
1242
|
-
owner: owner,
|
|
1243
|
-
name: name,
|
|
1244
|
-
project: project,
|
|
1245
|
-
connectionId: options.connectionId,
|
|
1246
|
-
});
|
|
1247
|
-
if (repo == null) {
|
|
1248
|
-
// `getRepoInfo` returns undefined only when no session could be resolved (not connected, or the
|
|
1249
|
-
// requested connection is gone) — a real 404 throws below. So this is a connection gap. Attach a
|
|
1250
|
-
// warning so a consumer driving auth recovery off `warning.kind` sees the same signal it gets from
|
|
1251
|
-
// the thrown-AuthenticationError branch below; without it, the most common unauthorized case is
|
|
1252
|
-
// silent.
|
|
1253
|
-
return {
|
|
1254
|
-
resolution: {
|
|
1255
|
-
status: 'unauthorized',
|
|
1256
|
-
warning: noConnectionWarning(id, domain, options.connectionId),
|
|
1257
|
-
},
|
|
1258
|
-
};
|
|
1259
|
-
}
|
|
1260
|
-
// Prefer the provider's canonical namespace/name (GitHub's REST/GraphQL lookup follows the 301
|
|
1261
|
-
// rename redirect, so a stale old name resolves to the new canonical identity), falling back to the
|
|
1262
|
-
// parsed remote when the response omits them. `renamed` is a case-insensitive compare of input vs
|
|
1263
|
-
// canonical, mirroring gkcli's `EqualFold`, so hosts that merely echo the input casing (e.g.
|
|
1264
|
-
// Bitbucket Server/Azure) don't get spuriously flagged.
|
|
1265
|
-
const canonicalOwner = repo.namespace || owner;
|
|
1266
|
-
const canonicalName = repo.name || name;
|
|
1267
|
-
const renamed = canonicalOwner.toLowerCase() !== owner.toLowerCase() ||
|
|
1268
|
-
canonicalName.toLowerCase() !== name.toLowerCase();
|
|
1269
|
-
const identity = {
|
|
1270
|
-
providerId: id,
|
|
1271
|
-
domain: domain,
|
|
1272
|
-
owner: canonicalOwner,
|
|
1273
|
-
name: canonicalName,
|
|
1274
|
-
project: project,
|
|
1275
|
-
remoteUrl: options.remoteUrl,
|
|
1276
|
-
renamed: renamed,
|
|
1277
|
-
};
|
|
1278
|
-
return { resolution: { status: 'resolved', identity: identity } };
|
|
1279
|
-
}
|
|
1280
|
-
catch (ex) {
|
|
1281
|
-
// Order matters: 404 throws RequestNotFoundError (not `undefined`), so check not-found before auth
|
|
1282
|
-
// and before the generic 5xx/unknown bucket — never classify a 401/403 as not-found.
|
|
1283
|
-
let resolution;
|
|
1284
|
-
if (ex instanceof RequestNotFoundError) {
|
|
1285
|
-
resolution = { status: 'not-found' };
|
|
1286
|
-
}
|
|
1287
|
-
else if (ex instanceof AuthenticationError) {
|
|
1288
|
-
resolution = {
|
|
1289
|
-
status: 'unauthorized',
|
|
1290
|
-
warning: toProviderWarning(id, domain, options.connectionId, ex),
|
|
1291
|
-
};
|
|
1292
|
-
}
|
|
1293
|
-
else {
|
|
1294
|
-
resolution = {
|
|
1295
|
-
status: 'undetermined',
|
|
1296
|
-
warning: toProviderWarning(id, domain, options.connectionId, ex),
|
|
1297
|
-
};
|
|
1298
|
-
}
|
|
1299
|
-
return { resolution: resolution };
|
|
1300
|
-
}
|
|
660
|
+
return resolveRepository(this, options);
|
|
661
|
+
}
|
|
662
|
+
/** {@link RepositoryResolutionContext} seam: the user's `remotes` configs, for the remote matcher. */
|
|
663
|
+
getRemoteConfigs() {
|
|
664
|
+
return this.ctx.config.getRemoteConfigs();
|
|
665
|
+
}
|
|
666
|
+
/** {@link RepositoryResolutionContext} seam: instance lookup by host, for the cloud-host resolution branch. */
|
|
667
|
+
getIntegrationForDomain(id, domain) {
|
|
668
|
+
return this.get(id, domain);
|
|
1301
669
|
}
|
|
1302
670
|
// #endregion ProviderBackend surface (#5438)
|
|
1303
671
|
_ignoreSSLErrors = new Map();
|