@gitkraken/core-gitlens 0.45.0 → 0.46.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.
Files changed (235) hide show
  1. package/CHANGELOG.md +27 -1
  2. package/dist/git/models/remote.js +2 -2
  3. package/dist/git/models/remote.js.map +1 -1
  4. package/dist/git/remotes/matcher.js +25 -3
  5. package/dist/git/remotes/matcher.js.map +1 -1
  6. package/dist/git/utils/branchLanded.utils.d.ts +7 -0
  7. package/dist/git/utils/branchLanded.utils.js +10 -1
  8. package/dist/git/utils/branchLanded.utils.js.map +1 -1
  9. package/dist/git/utils/remote.utils.d.ts +1 -0
  10. package/dist/git/utils/remote.utils.js +14 -5
  11. package/dist/git/utils/remote.utils.js.map +1 -1
  12. package/dist/git-cli/parsers/logParser.js +227 -468
  13. package/dist/git-cli/parsers/logParser.js.map +1 -1
  14. package/dist/git-cli/parsers/refParser.js +4 -4
  15. package/dist/git-cli/parsers/refParser.js.map +1 -1
  16. package/dist/git-cli/providers/branches.d.ts +5 -0
  17. package/dist/git-cli/providers/branches.js +25 -21
  18. package/dist/git-cli/providers/branches.js.map +1 -1
  19. package/dist/plus/git-github/api/github.d.ts +6 -1
  20. package/dist/plus/git-github/api/github.js +14 -4
  21. package/dist/plus/git-github/api/github.js.map +1 -1
  22. package/dist/plus/git-github/api/issueWrites.d.ts +6 -1
  23. package/dist/plus/git-github/api/issueWrites.js +61 -31
  24. package/dist/plus/git-github/api/issueWrites.js.map +1 -1
  25. package/dist/plus/integrations/authentication/cloudIntegrationAuthenticationProvider.d.ts +44 -0
  26. package/dist/plus/integrations/authentication/cloudIntegrationAuthenticationProvider.js +199 -0
  27. package/dist/plus/integrations/authentication/cloudIntegrationAuthenticationProvider.js.map +1 -0
  28. package/dist/plus/integrations/authentication/configuredIntegrationService.d.ts +7 -0
  29. package/dist/plus/integrations/authentication/configuredIntegrationService.js +53 -7
  30. package/dist/plus/integrations/authentication/configuredIntegrationService.js.map +1 -1
  31. package/dist/plus/integrations/authentication/integrationAuthenticationProvider.d.ts +2 -38
  32. package/dist/plus/integrations/authentication/integrationAuthenticationProvider.js +0 -199
  33. package/dist/plus/integrations/authentication/integrationAuthenticationService.d.ts +4 -2
  34. package/dist/plus/integrations/authentication/integrationAuthenticationService.js +12 -1
  35. package/dist/plus/integrations/authentication/integrationAuthenticationService.js.map +1 -1
  36. package/dist/plus/integrations/authentication/models.d.ts +0 -1
  37. package/dist/plus/integrations/authentication/models.js +1 -2
  38. package/dist/plus/integrations/authentication/models.js.map +1 -1
  39. package/dist/plus/integrations/constants.d.ts +0 -10
  40. package/dist/plus/integrations/constants.js +1 -95
  41. package/dist/plus/integrations/constants.js.map +1 -1
  42. package/dist/plus/integrations/context.d.ts +13 -13
  43. package/dist/plus/integrations/index.d.ts +39 -24
  44. package/dist/plus/integrations/index.js +40 -8
  45. package/dist/plus/integrations/index.js.map +1 -1
  46. package/dist/plus/integrations/integrationService.d.ts +15 -22
  47. package/dist/plus/integrations/integrationService.js +39 -12
  48. package/dist/plus/integrations/integrationService.js.map +1 -1
  49. package/dist/plus/integrations/lite.js +1 -1
  50. package/dist/plus/integrations/lite.js.map +1 -1
  51. package/dist/plus/integrations/manager.d.ts +65 -17
  52. package/dist/plus/integrations/models/actionablePullRequest.d.ts +213 -0
  53. package/dist/plus/integrations/models/actionablePullRequest.js +25 -0
  54. package/dist/plus/integrations/models/actionablePullRequest.js.map +1 -0
  55. package/dist/plus/integrations/models/gitHostIntegration.d.ts +13 -46
  56. package/dist/plus/integrations/models/gitHostIntegration.js +15 -4
  57. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  58. package/dist/plus/integrations/models/integration.d.ts +10 -175
  59. package/dist/plus/integrations/models/integration.js +11 -72
  60. package/dist/plus/integrations/models/integration.js.map +1 -1
  61. package/dist/plus/integrations/models/issuesIntegration.d.ts +9 -5
  62. package/dist/plus/integrations/models/issuesIntegration.js +5 -3
  63. package/dist/plus/integrations/models/issuesIntegration.js.map +1 -1
  64. package/dist/plus/integrations/models/publicIntegration.d.ts +252 -0
  65. package/dist/plus/integrations/models/publicIntegration.js +21 -0
  66. package/dist/plus/integrations/models/publicIntegration.js.map +1 -0
  67. package/dist/plus/integrations/providerFilters.d.ts +58 -0
  68. package/dist/plus/integrations/providerFilters.js.map +1 -1
  69. package/dist/plus/integrations/providers/actionablePullRequests.d.ts +19 -0
  70. package/dist/plus/integrations/providers/actionablePullRequests.js +32 -0
  71. package/dist/plus/integrations/providers/actionablePullRequests.js.map +1 -0
  72. package/dist/plus/integrations/providers/apiClients.d.ts +1 -2
  73. package/dist/plus/integrations/providers/apiClients.js.map +1 -1
  74. package/dist/plus/integrations/providers/asana.d.ts +3 -2
  75. package/dist/plus/integrations/providers/asana.js +2 -1
  76. package/dist/plus/integrations/providers/asana.js.map +1 -1
  77. package/dist/plus/integrations/providers/azure/azure.d.ts +1 -1
  78. package/dist/plus/integrations/providers/azure/azure.utils.d.ts +10 -3
  79. package/dist/plus/integrations/providers/azure/azure.utils.js +5 -1
  80. package/dist/plus/integrations/providers/azure/azure.utils.js.map +1 -1
  81. package/dist/plus/integrations/providers/azure/models.d.ts +1 -5
  82. package/dist/plus/integrations/providers/azure/models.js +1 -1
  83. package/dist/plus/integrations/providers/azure/models.js.map +1 -1
  84. package/dist/plus/integrations/providers/azureDevOps.d.ts +8 -5
  85. package/dist/plus/integrations/providers/azureDevOps.js +2 -1
  86. package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
  87. package/dist/plus/integrations/providers/azureDevOpsServer.d.ts +5 -4
  88. package/dist/plus/integrations/providers/azureDevOpsServer.js +3 -1
  89. package/dist/plus/integrations/providers/azureDevOpsServer.js.map +1 -1
  90. package/dist/plus/integrations/providers/bitbucket/bitbucket.d.ts +2 -2
  91. package/dist/plus/integrations/providers/bitbucket/bitbucket.js.map +1 -1
  92. package/dist/plus/integrations/providers/bitbucket/models.d.ts +1 -1
  93. package/dist/plus/integrations/providers/bitbucket/models.js.map +1 -1
  94. package/dist/plus/integrations/providers/bitbucket-server.d.ts +5 -4
  95. package/dist/plus/integrations/providers/bitbucket-server.js +2 -1
  96. package/dist/plus/integrations/providers/bitbucket-server.js.map +1 -1
  97. package/dist/plus/integrations/providers/bitbucket.d.ts +4 -3
  98. package/dist/plus/integrations/providers/bitbucket.js +2 -1
  99. package/dist/plus/integrations/providers/bitbucket.js.map +1 -1
  100. package/dist/plus/integrations/providers/github/github.d.ts +0 -1
  101. package/dist/plus/integrations/providers/github/github.js +1 -1
  102. package/dist/plus/integrations/providers/github/github.js.map +1 -1
  103. package/dist/plus/integrations/providers/github.d.ts +11 -6
  104. package/dist/plus/integrations/providers/github.js +70 -26
  105. package/dist/plus/integrations/providers/github.js.map +1 -1
  106. package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +2 -2
  107. package/dist/plus/integrations/providers/gitlab/gitlab.js +1 -2
  108. package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
  109. package/dist/plus/integrations/providers/gitlab/gitlab.utils.d.ts +14 -1
  110. package/dist/plus/integrations/providers/gitlab/gitlab.utils.js.map +1 -1
  111. package/dist/plus/integrations/providers/gitlab/models.d.ts +2 -10
  112. package/dist/plus/integrations/providers/gitlab/models.js.map +1 -1
  113. package/dist/plus/integrations/providers/gitlab.d.ts +7 -5
  114. package/dist/plus/integrations/providers/gitlab.js +2 -1
  115. package/dist/plus/integrations/providers/gitlab.js.map +1 -1
  116. package/dist/plus/integrations/providers/jira-server.d.ts +4 -4
  117. package/dist/plus/integrations/providers/jira-server.js +3 -2
  118. package/dist/plus/integrations/providers/jira-server.js.map +1 -1
  119. package/dist/plus/integrations/providers/jira.d.ts +3 -3
  120. package/dist/plus/integrations/providers/jira.js +3 -2
  121. package/dist/plus/integrations/providers/jira.js.map +1 -1
  122. package/dist/plus/integrations/providers/jiraIssueByKey.d.ts +1 -1
  123. package/dist/plus/integrations/providers/jiraIssueByKey.js.map +1 -1
  124. package/dist/plus/integrations/providers/linear.d.ts +4 -3
  125. package/dist/plus/integrations/providers/linear.js +3 -2
  126. package/dist/plus/integrations/providers/linear.js.map +1 -1
  127. package/dist/plus/integrations/providers/linearIssuesEtag.d.ts +1 -1
  128. package/dist/plus/integrations/providers/linearIssuesEtag.js +1 -1
  129. package/dist/plus/integrations/providers/linearIssuesEtag.js.map +1 -1
  130. package/dist/plus/integrations/providers/metadata.d.ts +136 -0
  131. package/dist/plus/integrations/providers/metadata.js +513 -0
  132. package/dist/plus/integrations/providers/metadata.js.map +1 -0
  133. package/dist/plus/integrations/providers/models.d.ts +10 -206
  134. package/dist/plus/integrations/providers/models.js +8 -539
  135. package/dist/plus/integrations/providers/models.js.map +1 -1
  136. package/dist/plus/integrations/providers/providersApi.d.ts +3 -2
  137. package/dist/plus/integrations/providers/providersApi.js +2 -1
  138. package/dist/plus/integrations/providers/providersApi.js.map +1 -1
  139. package/dist/plus/integrations/providers/trello.d.ts +1 -1
  140. package/dist/plus/integrations/providers/trello.js +2 -1
  141. package/dist/plus/integrations/providers/trello.js.map +1 -1
  142. package/dist/plus/integrations/providers/utils/providerPaging.d.ts +2 -0
  143. package/dist/plus/integrations/providers/utils/providerPaging.js +3 -2
  144. package/dist/plus/integrations/providers/utils/providerPaging.js.map +1 -1
  145. package/dist/plus/integrations/providers/utils.d.ts +119 -10
  146. package/dist/plus/integrations/providers/utils.js +57 -3
  147. package/dist/plus/integrations/providers/utils.js.map +1 -1
  148. package/dist/plus/integrations/reads/autolinks.d.ts +1 -1
  149. package/dist/plus/integrations/reads/autolinks.js +1 -1
  150. package/dist/plus/integrations/reads/autolinks.js.map +1 -1
  151. package/dist/plus/integrations/reads/broaden.d.ts +1 -1
  152. package/dist/plus/integrations/reads/broaden.js +3 -2
  153. package/dist/plus/integrations/reads/broaden.js.map +1 -1
  154. package/dist/plus/integrations/reads/context.d.ts +1 -1
  155. package/dist/plus/integrations/reads/counts.d.ts +1 -88
  156. package/dist/plus/integrations/reads/counts.js +4 -2
  157. package/dist/plus/integrations/reads/counts.js.map +1 -1
  158. package/dist/plus/integrations/reads/currentAccount.d.ts +1 -18
  159. package/dist/plus/integrations/reads/currentAccount.js.map +1 -1
  160. package/dist/plus/integrations/reads/drains.d.ts +3 -3
  161. package/dist/plus/integrations/reads/drains.js +1 -1
  162. package/dist/plus/integrations/reads/drains.js.map +1 -1
  163. package/dist/plus/integrations/reads/etag.d.ts +174 -3
  164. package/dist/plus/integrations/reads/etag.js +69 -14
  165. package/dist/plus/integrations/reads/etag.js.map +1 -1
  166. package/dist/plus/integrations/reads/filters.d.ts +3 -61
  167. package/dist/plus/integrations/reads/filters.js +1 -1
  168. package/dist/plus/integrations/reads/filters.js.map +1 -1
  169. package/dist/plus/integrations/reads/hierarchy.d.ts +1 -1
  170. package/dist/plus/integrations/reads/hierarchy.js +4 -2
  171. package/dist/plus/integrations/reads/hierarchy.js.map +1 -1
  172. package/dist/plus/integrations/reads/issueBatch.d.ts +2 -102
  173. package/dist/plus/integrations/reads/issueBatch.js +3 -4
  174. package/dist/plus/integrations/reads/issueBatch.js.map +1 -1
  175. package/dist/plus/integrations/reads/issueTracker.d.ts +1 -1
  176. package/dist/plus/integrations/reads/issueTracker.js +4 -3
  177. package/dist/plus/integrations/reads/issueTracker.js.map +1 -1
  178. package/dist/plus/integrations/reads/issues.d.ts +1 -1
  179. package/dist/plus/integrations/reads/issues.js +4 -2
  180. package/dist/plus/integrations/reads/issues.js.map +1 -1
  181. package/dist/plus/integrations/reads/paging.d.ts +1 -1
  182. package/dist/plus/integrations/reads/paging.js +1 -1
  183. package/dist/plus/integrations/reads/paging.js.map +1 -1
  184. package/dist/plus/integrations/reads/pullRequestActivity.d.ts +1 -24
  185. package/dist/plus/integrations/reads/pullRequestActivity.js +2 -1
  186. package/dist/plus/integrations/reads/pullRequestActivity.js.map +1 -1
  187. package/dist/plus/integrations/reads/pullRequestBatch.d.ts +2 -56
  188. package/dist/plus/integrations/reads/pullRequestBatch.js +23 -3
  189. package/dist/plus/integrations/reads/pullRequestBatch.js.map +1 -1
  190. package/dist/plus/integrations/reads/pullRequestBranches.d.ts +1 -47
  191. package/dist/plus/integrations/reads/pullRequestBranches.js +2 -1
  192. package/dist/plus/integrations/reads/pullRequestBranches.js.map +1 -1
  193. package/dist/plus/integrations/reads/pullRequestCheckLogs.d.ts +1 -15
  194. package/dist/plus/integrations/reads/pullRequestCheckLogs.js +2 -1
  195. package/dist/plus/integrations/reads/pullRequestCheckLogs.js.map +1 -1
  196. package/dist/plus/integrations/reads/pullRequests.js +4 -2
  197. package/dist/plus/integrations/reads/pullRequests.js.map +1 -1
  198. package/dist/plus/integrations/reads/pullRequestsForCommits.d.ts +1 -16
  199. package/dist/plus/integrations/reads/pullRequestsForCommits.js +2 -1
  200. package/dist/plus/integrations/reads/pullRequestsForCommits.js.map +1 -1
  201. package/dist/plus/integrations/reads/resolveRepository.js +10 -5
  202. package/dist/plus/integrations/reads/resolveRepository.js.map +1 -1
  203. package/dist/plus/integrations/reads/searchIssues.js +2 -1
  204. package/dist/plus/integrations/reads/searchIssues.js.map +1 -1
  205. package/dist/plus/integrations/reads/searchPullRequests.js +2 -1
  206. package/dist/plus/integrations/reads/searchPullRequests.js.map +1 -1
  207. package/dist/plus/integrations/reads/sweeps.d.ts +1 -1
  208. package/dist/plus/integrations/reads/sweeps.js +3 -2
  209. package/dist/plus/integrations/reads/sweeps.js.map +1 -1
  210. package/dist/plus/integrations/reads/warnings.d.ts +1 -1
  211. package/dist/plus/integrations/reads/warnings.js +1 -1
  212. package/dist/plus/integrations/reads/warnings.js.map +1 -1
  213. package/dist/plus/integrations/results.d.ts +324 -2
  214. package/dist/plus/integrations/results.js.map +1 -1
  215. package/dist/plus/integrations/telemetry.d.ts +0 -10
  216. package/dist/plus/integrations/telemetry.js +0 -11
  217. package/dist/plus/integrations/utils/domain.utils.d.ts +1 -0
  218. package/dist/plus/integrations/utils/domain.utils.js +10 -2
  219. package/dist/plus/integrations/utils/domain.utils.js.map +1 -1
  220. package/dist/plus/integrations/utils/integration.utils.d.ts +1 -6
  221. package/dist/plus/integrations/utils/integration.utils.js +2 -9
  222. package/dist/plus/integrations/utils/integration.utils.js.map +1 -1
  223. package/dist/utils/keys/chord.d.ts +13 -2
  224. package/dist/utils/keys/chord.js +76 -17
  225. package/dist/utils/keys/chord.js.map +1 -1
  226. package/dist/utils/keys/keybinding.d.ts +12 -0
  227. package/dist/utils/keys/keybinding.js +52 -2
  228. package/dist/utils/keys/keybinding.js.map +1 -1
  229. package/dist/utils/markdown.d.ts +21 -0
  230. package/dist/utils/markdown.js +33 -1
  231. package/dist/utils/markdown.js.map +1 -1
  232. package/docs/integrations.md +99 -16
  233. package/package.json +5 -1
  234. package/dist/plus/integrations/authentication/integrationAuthenticationProvider.js.map +0 -1
  235. package/dist/plus/integrations/telemetry.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -6,6 +6,31 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.46.0] - 2026-11-23
10
+
11
+ ### Added
12
+
13
+ - Extends `IntegrationManager.resolveIssueWriteTarget`, `writeIssue`, and `deleteIssue` to GitHub Enterprise Server. The caller supplies the installation, connection and repository. The write can verify the expected login with the selected credential. Create, edit, close, reopen, and delete return typed receipts or display-safe failure reasons. Deletion depends on the installation's schema and the viewer's permissions. For a GHES `unknown` result, `mutationDispatched: false` means the failure happened before the write was sent (plus/integrations, plus/git-github)
14
+ - Adds `plus/integrations/constants.js` to the published entry points: integration ids, enums and pure id predicates, with no runtime imports, so it is safe in browser bundles (plus/integrations)
15
+ - Expands the `plus/integrations/index.js` facade into the full integrations API GitLens itself now consumes. `IntegrationManager` adds `get` (interface-only `GitHostIntegration`/`IssuesIntegration` views, no provider classes; a git host's view carries `mergePullRequest`, `enqueuePullRequest` and `dequeuePullRequest`, which 0.34.0 left unreachable from the facade, and the optional `getMergeQueueEntriesByPullRequestNumber`), `getIntegrationsForAccountWideRead`, `isConnectedForAccountWideRead`, `connectCloudIntegrations`, `manageCloudIntegrations`, `reset`, `getMyPullRequests`, `getMyIssues`, `ignoreSSLErrors` and `github`. The facade also exports:
16
+ - the `isIntegration`/`isGitHostIntegration`/`isIssuesIntegration` guards
17
+ - the integration-id and remote helpers (including `isAzureProviderId`, `getAzureRepositoryIdentity` and `splitOwnerAndRepo`), and provider metadata
18
+ - a neutral entity-identifier codec (`encodeEntityIdentifier`/`decodeEntityIdentifier` and the git-config helpers)
19
+ - neutral actionable pull request types with `getActionablePullRequests`
20
+
21
+ None of these signatures reference `@gitkraken/provider-apis` types (plus/integrations)
22
+
23
+ - Adds optional pull request, issue and repository lookups to `IntegrationManagerCacheProvider`. A lookup the cache omits runs uncached. Each one receives an `IntegrationCacheDescriptor`, which adds `maybeConnected` and `sessionFingerprint` to `IntegrationAccountCacheDescriptor` (now an alias of it) so a cache can invalidate on a reconnect or a token change (plus/integrations)
24
+
25
+ ### Changed
26
+
27
+ - `IssueCountScope.repos` and `PullRequestCountScope.repos` are typed with the package's own `ProviderRepositoriesInput` instead of a provider-apis repository input (plus/integrations)
28
+ - `getBranchMergedStatus` caches its check against a remote target and its check against that target's local branch separately, so when only one of them moves (a fetch moving the remote target) the other isn't rerun, saving a full merged check of git runs. It also resolves the local branch only when the branch isn't merged into the remote target (git)
29
+
30
+ ### Fixed
31
+
32
+ - Resolves self-managed repository remotes that spell out their web protocol's default port, such as an HTTPS remote with `:443`, against the configured host (plus/integrations)
33
+
9
34
  ## [0.45.0] - 2026-11-23
10
35
 
11
36
  ### Added
@@ -1396,7 +1421,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1396
1421
 
1397
1422
  - Initial release. Bundles `@gitlens/utils`, `@gitlens/git`, `@gitlens/git-cli`, `@gitlens/ai`, and `@gitlens/git-github` into a single core npm package with subpath exports.
1398
1423
 
1399
- [unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.45.0...HEAD
1424
+ [unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.46.0...HEAD
1425
+ [0.46.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.45.0...gitkraken:releases/core/v0.46.0
1400
1426
  [0.45.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.44.0...gitkraken:releases/core/v0.45.0
1401
1427
  [0.44.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.43.0...gitkraken:releases/core/v0.44.0
1402
1428
  [0.42.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.41.0...gitkraken:releases/core/v0.42.0
@@ -2,7 +2,7 @@ import { equalsIgnoreCase } from "../../utils/string.js";
2
2
  import { loggable } from "../../utils/decorators/log.js";
3
3
  import { memoize } from "../../utils/decorators/memoize.js";
4
4
  import __decorate from "../../_virtual/@oxc-project+runtime/helpers/esm/decorate.js";
5
- import { parseGitRemoteUrl } from "../utils/remote.utils.js";
5
+ import { getCloudWebDomain, parseGitRemoteUrl } from "../utils/remote.utils.js";
6
6
  import { serializable } from "../../utils/decorators/serializable.js";
7
7
  //#region ../git/src/models/remote.ts
8
8
  var _GitRemote;
@@ -54,7 +54,7 @@ let GitRemote = _GitRemote = class GitRemote {
54
54
  if (equalsIgnoreCase(urlOrDomain, this.url)) return true;
55
55
  [, urlOrDomain, path] = parseGitRemoteUrl(urlOrDomain);
56
56
  }
57
- return equalsIgnoreCase(urlOrDomain, this.domain) && equalsIgnoreCase(path, this.path);
57
+ return equalsIgnoreCase(getCloudWebDomain(urlOrDomain), this.domain) && equalsIgnoreCase(path, this.path) || equalsIgnoreCase(urlOrDomain, this._domain) && equalsIgnoreCase(path, this._path);
58
58
  }
59
59
  /** Creates a copy of this remote with a different repoPath — ONLY used for worktree-aware caching */
60
60
  withRepoPath(repoPath) {
@@ -1 +1 @@
1
- {"version":3,"file":"remote.js","names":[],"sources":["../../../../git/src/models/remote.ts"],"sourcesContent":["import { loggable } from '@gitlens/utils/decorators/log.js';\nimport { memoize } from '@gitlens/utils/decorators/memoize.js';\nimport { serializable } from '@gitlens/utils/decorators/serializable.js';\nimport { equalsIgnoreCase } from '@gitlens/utils/string.js';\nimport type { Shape } from '@gitlens/utils/types.js';\nimport { parseGitRemoteUrl } from '../utils/remote.utils.js';\nimport type { RemoteProvider } from './remoteProvider.js';\n\nexport type GitRemoteShape = Shape<GitRemote>;\nexport type GitRemoteType = 'fetch' | 'push';\n\n@loggable(i => i.id)\n@serializable\nexport class GitRemote<TProvider extends RemoteProvider | undefined = RemoteProvider | undefined> {\n\tconstructor(\n\t\tpublic readonly repoPath: string,\n\t\tpublic readonly name: string,\n\t\tpublic readonly scheme: string,\n\t\tprivate readonly _domain: string,\n\t\tprivate readonly _path: string,\n\t\tpublic readonly urls: { type: GitRemoteType; url: string }[],\n\t\t/** Remote provider instance for URL generation and identity */\n\t\tpublic readonly provider: TProvider = undefined as TProvider,\n\t\tisDefault: boolean = false,\n\t) {\n\t\tthis._default = isDefault;\n\t}\n\n\tprivate readonly _default: boolean;\n\t/** Whether this remote is the user-designated default for the repository */\n\tget default(): boolean {\n\t\treturn this._default;\n\t}\n\n\t@memoize()\n\tget domain(): string {\n\t\treturn this.provider?.domain ?? this._domain;\n\t}\n\n\t@memoize()\n\tget id(): string {\n\t\treturn `${this.name}/${this.remoteKey}`;\n\t}\n\n\t@memoize()\n\tget path(): string {\n\t\treturn this.provider?.path ?? this._path;\n\t}\n\n\t@memoize()\n\tget remoteKey(): string {\n\t\treturn this._domain ? `${this._domain}/${this._path}` : this.path;\n\t}\n\n\t@memoize()\n\tget url(): string {\n\t\tlet bestUrl: string | undefined;\n\t\tfor (const remoteUrl of this.urls) {\n\t\t\tif (remoteUrl.type === 'push') {\n\t\t\t\treturn remoteUrl.url;\n\t\t\t}\n\n\t\t\tbestUrl ??= remoteUrl.url;\n\t\t}\n\n\t\treturn bestUrl ?? '';\n\t}\n\n\tmatches(url: string): boolean;\n\tmatches(domain: string, path: string): boolean;\n\tmatches(urlOrDomain: string, path?: string): boolean {\n\t\tif (path == null) {\n\t\t\tif (equalsIgnoreCase(urlOrDomain, this.url)) return true;\n\n\t\t\t[, urlOrDomain, path] = parseGitRemoteUrl(urlOrDomain);\n\t\t}\n\n\t\treturn equalsIgnoreCase(urlOrDomain, this.domain) && equalsIgnoreCase(path, this.path);\n\t}\n\n\t/** Creates a copy of this remote with a different repoPath — ONLY used for worktree-aware caching */\n\twithRepoPath(repoPath: string): GitRemote<TProvider> {\n\t\tif (repoPath === this.repoPath) return this;\n\n\t\treturn new GitRemote<TProvider>(\n\t\t\trepoPath,\n\t\t\tthis.name,\n\t\t\tthis.scheme,\n\t\t\tthis._domain,\n\t\t\tthis._path,\n\t\t\tthis.urls,\n\t\t\tthis.provider,\n\t\t\tthis.default,\n\t\t);\n\t}\n\n\tstatic is(remote: unknown): remote is GitRemote {\n\t\treturn remote instanceof GitRemote;\n\t}\n}\n"],"mappings":";;;;;;;;AAaO,IAAM,YAAA,aAAN,MAAM,UAAqF;CAEhF;CACA;CACA;CACC;CACA;CACD;CAEA;CARjB,YACC,UACA,MACA,QACA,SACA,OACA,MAEA,WAAsC,KAAA,GACtC,YAAqB,OACpB;EATe,KAAA,WAAA;EACA,KAAA,OAAA;EACA,KAAA,SAAA;EACC,KAAA,UAAA;EACA,KAAA,QAAA;EACD,KAAA,OAAA;EAEA,KAAA,WAAA;EAGhB,KAAK,WAAW;CACjB;CAEA;;CAEA,IAAI,UAAmB;EACtB,OAAO,KAAK;CACb;CAEA,IACI,SAAiB;EACpB,OAAO,KAAK,UAAU,UAAU,KAAK;CACtC;CAEA,IACI,KAAa;EAChB,OAAO,GAAG,KAAK,KAAK,GAAG,KAAK;CAC7B;CAEA,IACI,OAAe;EAClB,OAAO,KAAK,UAAU,QAAQ,KAAK;CACpC;CAEA,IACI,YAAoB;EACvB,OAAO,KAAK,UAAU,GAAG,KAAK,QAAQ,GAAG,KAAK,UAAU,KAAK;CAC9D;CAEA,IACI,MAAc;EACjB,IAAI;EACJ,KAAK,MAAM,aAAa,KAAK,MAAM;GAClC,IAAI,UAAU,SAAS,QACtB,OAAO,UAAU;GAGlB,YAAY,UAAU;EACvB;EAEA,OAAO,WAAW;CACnB;CAIA,QAAQ,aAAqB,MAAwB;EACpD,IAAI,QAAQ,MAAM;GACjB,IAAI,iBAAiB,aAAa,KAAK,GAAG,GAAG,OAAO;GAEpD,GAAG,aAAa,QAAQ,kBAAkB,WAAW;EACtD;EAEA,OAAO,iBAAiB,aAAa,KAAK,MAAM,KAAK,iBAAiB,MAAM,KAAK,IAAI;CACtF;;CAGA,aAAa,UAAwC;EACpD,IAAI,aAAa,KAAK,UAAU,OAAO;EAEvC,OAAO,IAAA,WACN,UACA,KAAK,MACL,KAAK,QACL,KAAK,SACL,KAAK,OACL,KAAK,MACL,KAAK,UACL,KAAK,OACN;CACD;CAEA,OAAO,GAAG,QAAsC;EAC/C,OAAO,kBAAA;CACR;AACD;AAjEE,WAAA,CAAA,QAAQ,CAAA,GAAA,UAAA,WAAA,UAAA,IAAA;AAKR,WAAA,CAAA,QAAQ,CAAA,GAAA,UAAA,WAAA,MAAA,IAAA;AAKR,WAAA,CAAA,QAAQ,CAAA,GAAA,UAAA,WAAA,QAAA,IAAA;AAKR,WAAA,CAAA,QAAQ,CAAA,GAAA,UAAA,WAAA,aAAA,IAAA;AAKR,WAAA,CAAA,QAAQ,CAAA,GAAA,UAAA,WAAA,OAAA,IAAA;AA3CT,YAAA,aAAA,WAAA,CAAA,UAAS,MAAK,EAAE,EAAE,GAClB,YAAA,GAAA,SAAA"}
1
+ {"version":3,"file":"remote.js","names":[],"sources":["../../../../git/src/models/remote.ts"],"sourcesContent":["import { loggable } from '@gitlens/utils/decorators/log.js';\nimport { memoize } from '@gitlens/utils/decorators/memoize.js';\nimport { serializable } from '@gitlens/utils/decorators/serializable.js';\nimport { equalsIgnoreCase } from '@gitlens/utils/string.js';\nimport type { Shape } from '@gitlens/utils/types.js';\nimport { getCloudWebDomain, parseGitRemoteUrl } from '../utils/remote.utils.js';\nimport type { RemoteProvider } from './remoteProvider.js';\n\nexport type GitRemoteShape = Shape<GitRemote>;\nexport type GitRemoteType = 'fetch' | 'push';\n\n@loggable(i => i.id)\n@serializable\nexport class GitRemote<TProvider extends RemoteProvider | undefined = RemoteProvider | undefined> {\n\tconstructor(\n\t\tpublic readonly repoPath: string,\n\t\tpublic readonly name: string,\n\t\tpublic readonly scheme: string,\n\t\tprivate readonly _domain: string,\n\t\tprivate readonly _path: string,\n\t\tpublic readonly urls: { type: GitRemoteType; url: string }[],\n\t\t/** Remote provider instance for URL generation and identity */\n\t\tpublic readonly provider: TProvider = undefined as TProvider,\n\t\tisDefault: boolean = false,\n\t) {\n\t\tthis._default = isDefault;\n\t}\n\n\tprivate readonly _default: boolean;\n\t/** Whether this remote is the user-designated default for the repository */\n\tget default(): boolean {\n\t\treturn this._default;\n\t}\n\n\t@memoize()\n\tget domain(): string {\n\t\treturn this.provider?.domain ?? this._domain;\n\t}\n\n\t@memoize()\n\tget id(): string {\n\t\treturn `${this.name}/${this.remoteKey}`;\n\t}\n\n\t@memoize()\n\tget path(): string {\n\t\treturn this.provider?.path ?? this._path;\n\t}\n\n\t@memoize()\n\tget remoteKey(): string {\n\t\treturn this._domain ? `${this._domain}/${this._path}` : this.path;\n\t}\n\n\t@memoize()\n\tget url(): string {\n\t\tlet bestUrl: string | undefined;\n\t\tfor (const remoteUrl of this.urls) {\n\t\t\tif (remoteUrl.type === 'push') {\n\t\t\t\treturn remoteUrl.url;\n\t\t\t}\n\n\t\t\tbestUrl ??= remoteUrl.url;\n\t\t}\n\n\t\treturn bestUrl ?? '';\n\t}\n\n\tmatches(url: string): boolean;\n\tmatches(domain: string, path: string): boolean;\n\tmatches(urlOrDomain: string, path?: string): boolean {\n\t\tif (path == null) {\n\t\t\tif (equalsIgnoreCase(urlOrDomain, this.url)) return true;\n\n\t\t\t[, urlOrDomain, path] = parseGitRemoteUrl(urlOrDomain);\n\t\t}\n\n\t\treturn (\n\t\t\t(equalsIgnoreCase(getCloudWebDomain(urlOrDomain), this.domain) && equalsIgnoreCase(path, this.path)) ||\n\t\t\t(equalsIgnoreCase(urlOrDomain, this._domain) && equalsIgnoreCase(path, this._path))\n\t\t);\n\t}\n\n\t/** Creates a copy of this remote with a different repoPath — ONLY used for worktree-aware caching */\n\twithRepoPath(repoPath: string): GitRemote<TProvider> {\n\t\tif (repoPath === this.repoPath) return this;\n\n\t\treturn new GitRemote<TProvider>(\n\t\t\trepoPath,\n\t\t\tthis.name,\n\t\t\tthis.scheme,\n\t\t\tthis._domain,\n\t\t\tthis._path,\n\t\t\tthis.urls,\n\t\t\tthis.provider,\n\t\t\tthis.default,\n\t\t);\n\t}\n\n\tstatic is(remote: unknown): remote is GitRemote {\n\t\treturn remote instanceof GitRemote;\n\t}\n}\n"],"mappings":";;;;;;;;AAaO,IAAM,YAAA,aAAN,MAAM,UAAqF;CAEhF;CACA;CACA;CACC;CACA;CACD;CAEA;CARjB,YACC,UACA,MACA,QACA,SACA,OACA,MAEA,WAAsC,KAAA,GACtC,YAAqB,OACpB;EATe,KAAA,WAAA;EACA,KAAA,OAAA;EACA,KAAA,SAAA;EACC,KAAA,UAAA;EACA,KAAA,QAAA;EACD,KAAA,OAAA;EAEA,KAAA,WAAA;EAGhB,KAAK,WAAW;CACjB;CAEA;;CAEA,IAAI,UAAmB;EACtB,OAAO,KAAK;CACb;CAEA,IACI,SAAiB;EACpB,OAAO,KAAK,UAAU,UAAU,KAAK;CACtC;CAEA,IACI,KAAa;EAChB,OAAO,GAAG,KAAK,KAAK,GAAG,KAAK;CAC7B;CAEA,IACI,OAAe;EAClB,OAAO,KAAK,UAAU,QAAQ,KAAK;CACpC;CAEA,IACI,YAAoB;EACvB,OAAO,KAAK,UAAU,GAAG,KAAK,QAAQ,GAAG,KAAK,UAAU,KAAK;CAC9D;CAEA,IACI,MAAc;EACjB,IAAI;EACJ,KAAK,MAAM,aAAa,KAAK,MAAM;GAClC,IAAI,UAAU,SAAS,QACtB,OAAO,UAAU;GAGlB,YAAY,UAAU;EACvB;EAEA,OAAO,WAAW;CACnB;CAIA,QAAQ,aAAqB,MAAwB;EACpD,IAAI,QAAQ,MAAM;GACjB,IAAI,iBAAiB,aAAa,KAAK,GAAG,GAAG,OAAO;GAEpD,GAAG,aAAa,QAAQ,kBAAkB,WAAW;EACtD;EAEA,OACE,iBAAiB,kBAAkB,WAAW,GAAG,KAAK,MAAM,KAAK,iBAAiB,MAAM,KAAK,IAAI,KACjG,iBAAiB,aAAa,KAAK,OAAO,KAAK,iBAAiB,MAAM,KAAK,KAAK;CAEnF;;CAGA,aAAa,UAAwC;EACpD,IAAI,aAAa,KAAK,UAAU,OAAO;EAEvC,OAAO,IAAA,WACN,UACA,KAAK,MACL,KAAK,QACL,KAAK,SACL,KAAK,OACL,KAAK,MACL,KAAK,UACL,KAAK,OACN;CACD;CAEA,OAAO,GAAG,QAAsC;EAC/C,OAAO,kBAAA;CACR;AACD;AApEE,WAAA,CAAA,QAAQ,CAAA,GAAA,UAAA,WAAA,UAAA,IAAA;AAKR,WAAA,CAAA,QAAQ,CAAA,GAAA,UAAA,WAAA,MAAA,IAAA;AAKR,WAAA,CAAA,QAAQ,CAAA,GAAA,UAAA,WAAA,QAAA,IAAA;AAKR,WAAA,CAAA,QAAQ,CAAA,GAAA,UAAA,WAAA,aAAA,IAAA;AAKR,WAAA,CAAA,QAAQ,CAAA,GAAA,UAAA,WAAA,OAAA,IAAA;AA3CT,YAAA,aAAA,WAAA,CAAA,UAAS,MAAK,EAAE,EAAE,GAClB,YAAA,GAAA,SAAA"}
@@ -1,4 +1,5 @@
1
1
  import { Logger as _logger } from "../../utils/logger.js";
2
+ import { getCloudWebDomain } from "../utils/remote.utils.js";
2
3
  import { AzureDevOpsRemoteProvider, isVsts } from "./azure-devops.js";
3
4
  import { BitbucketServerRemoteProvider } from "./bitbucket-server.js";
4
5
  import { BitbucketRemoteProvider } from "./bitbucket.js";
@@ -9,10 +10,12 @@ import { GitHubRemoteProvider } from "./github.js";
9
10
  import { GitLabRemoteProvider } from "./gitlab.js";
10
11
  import { GoogleSourceRemoteProvider } from "./google-source.js";
11
12
  //#region ../git/src/remotes/matcher.ts
13
+ /** Regex sources already warned about for missing capture groups; module-level because entries are rebuilt on every remotes load */
14
+ const warnedMissingGroups = /* @__PURE__ */ new Set();
12
15
  const builtInProviders = [
13
16
  {
14
17
  custom: false,
15
- matcher: /^(?:ssh\.)?bitbucket\.org$/i,
18
+ matcher: /^(?:(?:alt)?ssh\.)?bitbucket\.org$/i,
16
19
  type: "bitbucket"
17
20
  },
18
21
  {
@@ -20,11 +23,21 @@ const builtInProviders = [
20
23
  matcher: "github.com",
21
24
  type: "github"
22
25
  },
26
+ {
27
+ custom: false,
28
+ matcher: "ssh.github.com",
29
+ type: "github"
30
+ },
23
31
  {
24
32
  custom: false,
25
33
  matcher: "gitlab.com",
26
34
  type: "gitlab"
27
35
  },
36
+ {
37
+ custom: false,
38
+ matcher: "altssh.gitlab.com",
39
+ type: "gitlab"
40
+ },
28
41
  {
29
42
  custom: false,
30
43
  matcher: /\bdev\.azure\.com$/i,
@@ -73,9 +86,10 @@ function createProvider(entry, domain, path, scheme, context) {
73
86
  return createBuiltInProvider(entry.type, domain, path, protocol, entry.name, entry.custom, context);
74
87
  }
75
88
  function createBuiltInProvider(type, domain, path, protocol, name, custom, context) {
89
+ domain = getCloudWebDomain(domain);
76
90
  switch (type) {
77
91
  case "azure-devops": return new AzureDevOpsRemoteProvider(domain, path, protocol, name, isVsts(domain), context);
78
- case "bitbucket": return new BitbucketRemoteProvider(domain.toLowerCase() === "ssh.bitbucket.org" ? "bitbucket.org" : domain, path, protocol, name, custom, context);
92
+ case "bitbucket": return new BitbucketRemoteProvider(domain, path, protocol, name, custom, context);
79
93
  case "bitbucket-server": return new BitbucketServerRemoteProvider(domain, path, protocol, name, custom, context);
80
94
  case "custom": return;
81
95
  case "gerrit": return new GerritRemoteProvider(domain, path, protocol, name, custom, void 0, context);
@@ -122,7 +136,15 @@ function matchEntries(entries, url, domain, path, scheme, hooks) {
122
136
  if (entry.matcher.test(key)) return createProvider(entry, domain, path, scheme, hooks);
123
137
  if (!entry.matchUrl) continue;
124
138
  const match = entry.matcher.exec(url);
125
- if (match != null) return createProvider(entry, match[1].replace(/^[a-zA-Z][\w+.-]*:\/\//, ""), match[2], scheme, hooks);
139
+ if (match == null) continue;
140
+ if (!match[1] || !match[2]) {
141
+ if (!warnedMissingGroups.has(entry.matcher.source)) {
142
+ warnedMissingGroups.add(entry.matcher.source);
143
+ _logger.warn(`Remote provider config '${entry.name ?? entry.type}' regex matched a remote URL but didn't capture both the domain (group 1) and path (group 2); ignoring it for full URL matches`);
144
+ }
145
+ continue;
146
+ }
147
+ return createProvider(entry, match[1].replace(/^[a-zA-Z][\w+.-]*:\/\//, ""), match[2], scheme, hooks);
126
148
  }
127
149
  }
128
150
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"matcher.js","names":[],"sources":["../../../../git/src/remotes/matcher.ts"],"sourcesContent":["import { Logger } from '@gitlens/utils/logger.js';\nimport type { RemoteProviderContext } from '../context.js';\nimport type {\n\tRemoteProvider,\n\tRemoteProviderId,\n\tRemoteProviderMatcher,\n\tRemotesUrlsConfig,\n} from '../models/remoteProvider.js';\nimport { AzureDevOpsRemoteProvider, isVsts } from './azure-devops.js';\nimport { BitbucketServerRemoteProvider } from './bitbucket-server.js';\nimport { BitbucketRemoteProvider } from './bitbucket.js';\nimport { CustomRemoteProvider } from './custom.js';\nimport { GerritRemoteProvider } from './gerrit.js';\nimport { GiteaRemoteProvider } from './gitea.js';\nimport { GitHubRemoteProvider } from './github.js';\nimport { GitLabRemoteProvider } from './gitlab.js';\nimport { GoogleSourceRemoteProvider } from './google-source.js';\n\nexport type { RemoteProviderMatcher } from '../models/remoteProvider.js';\n\n/**\n * Configuration for a remote provider, provided by the host.\n * The library uses these to build a {@link RemoteProviderMatcher} internally.\n *\n * Each config describes either a user-configured custom remote (from settings)\n * or a cloud self-managed host (from integration descriptors).\n */\nexport interface RemoteProviderConfig {\n\treadonly type: RemoteProviderId;\n\t/** Domain for exact string matching (mutually exclusive with `regex`) */\n\treadonly domain?: string;\n\t/** Regex pattern for flexible matching (mutually exclusive with `domain`) */\n\treadonly regex?: string;\n\t/** URL protocol override (e.g., `'https'`) */\n\treadonly protocol?: string;\n\t/** Display name override */\n\treadonly name?: string;\n\t/** Custom URL templates — required when `type` is `'Custom'` */\n\treadonly urls?: RemotesUrlsConfig;\n}\n\ninterface ProviderEntry {\n\tcustom: boolean;\n\t/** When true, the regex is also tested against the full URL (not just the domain) */\n\tmatchUrl?: boolean;\n\tmatcher: string | RegExp;\n\ttype: RemoteProviderId;\n\tprotocol?: string;\n\tname?: string;\n\turls?: RemotesUrlsConfig;\n}\n\nconst builtInProviders: ProviderEntry[] = [\n\t{ custom: false, matcher: /^(?:ssh\\.)?bitbucket\\.org$/i, type: 'bitbucket' },\n\t{ custom: false, matcher: 'github.com', type: 'github' },\n\t{ custom: false, matcher: 'gitlab.com', type: 'gitlab' },\n\t{ custom: false, matcher: /\\bdev\\.azure\\.com$/i, type: 'azure-devops' },\n\t{ custom: false, matchUrl: true, matcher: /^(.+\\/(?:bitbucket|stash))\\/scm\\/(.+)$/i, type: 'bitbucket-server' },\n\t{ custom: false, matcher: /\\bgitlab\\b/i, type: 'gitlab' },\n\t{ custom: false, matcher: /\\bvisualstudio\\.com$/i, type: 'azure-devops' },\n\t{ custom: false, matcher: /\\bgitea\\b/i, type: 'gitea' },\n\t{ custom: false, matcher: /\\bgerrithub\\.io$/i, type: 'gerrit' },\n\t{ custom: false, matcher: /\\bgooglesource\\.com$/i, type: 'google-source' },\n];\n\nconst protocolRegex = /(\\w+)\\W*/;\nfunction cleanProtocol(scheme: string | undefined): string | undefined {\n\tconst protocol = scheme?.match(protocolRegex)?.[1];\n\t// Only preserve web protocols; non-web schemes (e.g. `ssh`, `git`) must fall back to the\n\t// provider's default so web URLs (commit/issue/PR pages) don't inherit an unreachable scheme\n\treturn protocol === 'http' || protocol === 'https' ? protocol : undefined;\n}\n\nfunction createProvider(\n\tentry: ProviderEntry,\n\tdomain: string,\n\tpath: string,\n\tscheme: string | undefined,\n\tcontext?: RemoteProviderContext,\n): RemoteProvider | undefined {\n\tconst protocol = cleanProtocol(entry.protocol ?? scheme);\n\n\tif (entry.type === 'custom' && entry.urls != null) {\n\t\treturn new CustomRemoteProvider(domain, path, entry.urls, protocol, entry.name);\n\t}\n\n\treturn createBuiltInProvider(entry.type, domain, path, protocol, entry.name, entry.custom, context);\n}\n\nfunction createBuiltInProvider(\n\ttype: RemoteProviderId,\n\tdomain: string,\n\tpath: string,\n\tprotocol?: string,\n\tname?: string,\n\tcustom?: boolean,\n\tcontext?: RemoteProviderContext,\n): RemoteProvider | undefined {\n\tswitch (type) {\n\t\tcase 'azure-devops':\n\t\t\treturn new AzureDevOpsRemoteProvider(domain, path, protocol, name, isVsts(domain), context);\n\t\tcase 'bitbucket':\n\t\t\treturn new BitbucketRemoteProvider(\n\t\t\t\tdomain.toLowerCase() === 'ssh.bitbucket.org' ? 'bitbucket.org' : domain,\n\t\t\t\tpath,\n\t\t\t\tprotocol,\n\t\t\t\tname,\n\t\t\t\tcustom,\n\t\t\t\tcontext,\n\t\t\t);\n\t\tcase 'bitbucket-server':\n\t\t\treturn new BitbucketServerRemoteProvider(domain, path, protocol, name, custom, context);\n\t\tcase 'custom':\n\t\t\treturn undefined; // Custom requires urls — handled in config entries\n\t\tcase 'gerrit':\n\t\t\treturn new GerritRemoteProvider(domain, path, protocol, name, custom, undefined, context);\n\t\tcase 'google-source':\n\t\t\treturn new GoogleSourceRemoteProvider(domain, path, protocol, name, custom, context);\n\t\tcase 'gitea':\n\t\t\treturn new GiteaRemoteProvider(domain, path, protocol, name, custom, context);\n\t\tcase 'github':\n\t\t\treturn new GitHubRemoteProvider(domain, path, protocol, name, custom, context);\n\t\tcase 'gitlab':\n\t\t\treturn new GitLabRemoteProvider(domain, path, protocol, name, custom, context);\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nfunction configsToEntries(configs: RemoteProviderConfig[]): ProviderEntry[] {\n\tconst entries: ProviderEntry[] = [];\n\tfor (const cfg of configs) {\n\t\tlet matcher: string | RegExp | undefined;\n\t\ttry {\n\t\t\tmatcher = cfg.regex ? new RegExp(cfg.regex, 'i') : cfg.domain?.toLowerCase();\n\t\t\tif (matcher == null) {\n\t\t\t\tLogger.error(undefined, `Remote provider config for '${cfg.name ?? cfg.type}' has no domain or regex`);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tLogger.error(ex, `Loading remote provider config '${cfg.name ?? cfg.type}' failed`);\n\t\t\tcontinue;\n\t\t}\n\n\t\tentries.push({\n\t\t\tcustom: true,\n\t\t\tmatchUrl: true,\n\t\t\tmatcher: matcher,\n\t\t\ttype: cfg.type,\n\t\t\tprotocol: cfg.protocol,\n\t\t\tname: cfg.name,\n\t\t\turls: cfg.urls,\n\t\t});\n\t}\n\treturn entries;\n}\n\nfunction matchEntries(\n\tentries: ProviderEntry[],\n\turl: string,\n\tdomain: string,\n\tpath: string,\n\tscheme: string | undefined,\n\thooks?: RemoteProviderContext,\n): RemoteProvider | undefined {\n\tconst key = domain?.toLowerCase();\n\tfor (const entry of entries) {\n\t\tif (typeof entry.matcher === 'string') {\n\t\t\tif (entry.matcher === key) {\n\t\t\t\treturn createProvider(entry, domain, path, scheme, hooks);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (entry.matcher.test(key)) {\n\t\t\treturn createProvider(entry, domain, path, scheme, hooks);\n\t\t}\n\t\tif (!entry.matchUrl) continue;\n\n\t\tconst match = entry.matcher.exec(url);\n\t\tif (match != null) {\n\t\t\tconst matchDomain = match[1].replace(/^[a-zA-Z][\\w+.-]*:\\/\\//, '');\n\t\t\treturn createProvider(entry, matchDomain, match[2], scheme, hooks);\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Creates a {@link RemoteProviderMatcher} from optional extra configs and built-in providers.\n *\n * Extra configs (from user settings or cloud integrations) are matched first, then built-ins.\n * The optional {@link RemoteProviderContext} is attached to each created provider so it can\n * call host-side providers (e.g., cross-fork PR URLs, autolink decoration).\n *\n * @param configs - Extra provider configs beyond built-ins (user custom remotes, cloud self-managed hosts)\n * @param context - Optional host-provided context to attach to created providers\n */\nexport function createRemoteProviderMatcher(\n\tconfigs?: RemoteProviderConfig[],\n\tcontext?: RemoteProviderContext,\n): RemoteProviderMatcher {\n\tconst extraEntries = configs?.length ? configsToEntries(configs) : undefined;\n\n\treturn (url: string, domain: string, path: string, scheme: string | undefined): RemoteProvider | undefined => {\n\t\ttry {\n\t\t\t// Try extra configs first (user-configured + cloud self-managed take priority)\n\t\t\tif (extraEntries != null) {\n\t\t\t\tconst provider = matchEntries(extraEntries, url, domain, path, scheme, context);\n\t\t\t\tif (provider != null) return provider;\n\t\t\t}\n\n\t\t\t// Fall back to built-in providers\n\t\t\treturn matchEntries(builtInProviders, url, domain, path, scheme, context);\n\t\t} catch (ex) {\n\t\t\tdebugger;\n\t\t\tLogger.error(ex, 'createRemoteProviderMatcher');\n\t\t\treturn undefined;\n\t\t}\n\t};\n}\n"],"mappings":";;;;;;;;;;;AAoDA,MAAM,mBAAoC;CACzC;EAAE,QAAQ;EAAO,SAAS;EAA+B,MAAM;CAAY;CAC3E;EAAE,QAAQ;EAAO,SAAS;EAAc,MAAM;CAAS;CACvD;EAAE,QAAQ;EAAO,SAAS;EAAc,MAAM;CAAS;CACvD;EAAE,QAAQ;EAAO,SAAS;EAAuB,MAAM;CAAe;CACtE;EAAE,QAAQ;EAAO,UAAU;EAAM,SAAS;EAA2C,MAAM;CAAmB;CAC9G;EAAE,QAAQ;EAAO,SAAS;EAAe,MAAM;CAAS;CACxD;EAAE,QAAQ;EAAO,SAAS;EAAyB,MAAM;CAAe;CACxE;EAAE,QAAQ;EAAO,SAAS;EAAc,MAAM;CAAQ;CACtD;EAAE,QAAQ;EAAO,SAAS;EAAqB,MAAM;CAAS;CAC9D;EAAE,QAAQ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;EAC7G,IAAI;GAEH,IAAI,gBAAgB,MAAM;IACzB,MAAM,WAAW,aAAa,cAAc,KAAK,QAAQ,MAAM,QAAQ,OAAO;IAC9E,IAAI,YAAY,MAAM,OAAO;GAC9B;GAGA,OAAO,aAAa,kBAAkB,KAAK,QAAQ,MAAM,QAAQ,OAAO;EACzE,SAAS,IAAI;GACZ;GACA,QAAO,MAAM,IAAI,6BAA6B;GAC9C;EACD;CACD;AACD"}
1
+ {"version":3,"file":"matcher.js","names":[],"sources":["../../../../git/src/remotes/matcher.ts"],"sourcesContent":["import { Logger } from '@gitlens/utils/logger.js';\nimport type { RemoteProviderContext } from '../context.js';\nimport type {\n\tRemoteProvider,\n\tRemoteProviderId,\n\tRemoteProviderMatcher,\n\tRemotesUrlsConfig,\n} from '../models/remoteProvider.js';\nimport { getCloudWebDomain } from '../utils/remote.utils.js';\nimport { AzureDevOpsRemoteProvider, isVsts } from './azure-devops.js';\nimport { BitbucketServerRemoteProvider } from './bitbucket-server.js';\nimport { BitbucketRemoteProvider } from './bitbucket.js';\nimport { CustomRemoteProvider } from './custom.js';\nimport { GerritRemoteProvider } from './gerrit.js';\nimport { GiteaRemoteProvider } from './gitea.js';\nimport { GitHubRemoteProvider } from './github.js';\nimport { GitLabRemoteProvider } from './gitlab.js';\nimport { GoogleSourceRemoteProvider } from './google-source.js';\n\nexport type { RemoteProviderMatcher } from '../models/remoteProvider.js';\n\n/**\n * Configuration for a remote provider, provided by the host.\n * The library uses these to build a {@link RemoteProviderMatcher} internally.\n *\n * Each config describes either a user-configured custom remote (from settings)\n * or a cloud self-managed host (from integration descriptors).\n */\nexport interface RemoteProviderConfig {\n\treadonly type: RemoteProviderId;\n\t/** Domain for exact string matching (mutually exclusive with `regex`) */\n\treadonly domain?: string;\n\t/** Regex pattern for flexible matching (mutually exclusive with `domain`) */\n\treadonly regex?: string;\n\t/** URL protocol override (e.g., `'https'`) */\n\treadonly protocol?: string;\n\t/** Display name override */\n\treadonly name?: string;\n\t/** Custom URL templates — required when `type` is `'Custom'` */\n\treadonly urls?: RemotesUrlsConfig;\n}\n\ninterface ProviderEntry {\n\tcustom: boolean;\n\t/** When true, the regex is also tested against the full URL (not just the domain) */\n\tmatchUrl?: boolean;\n\tmatcher: string | RegExp;\n\ttype: RemoteProviderId;\n\tprotocol?: string;\n\tname?: string;\n\turls?: RemotesUrlsConfig;\n}\n\n/** Regex sources already warned about for missing capture groups; module-level because entries are rebuilt on every remotes load */\nconst warnedMissingGroups = new Set<string>();\n\nconst builtInProviders: ProviderEntry[] = [\n\t{ custom: false, matcher: /^(?:(?:alt)?ssh\\.)?bitbucket\\.org$/i, type: 'bitbucket' },\n\t{ custom: false, matcher: 'github.com', type: 'github' },\n\t{ custom: false, matcher: 'ssh.github.com', type: 'github' },\n\t{ custom: false, matcher: 'gitlab.com', type: 'gitlab' },\n\t{ custom: false, matcher: 'altssh.gitlab.com', type: 'gitlab' },\n\t{ custom: false, matcher: /\\bdev\\.azure\\.com$/i, type: 'azure-devops' },\n\t{ custom: false, matchUrl: true, matcher: /^(.+\\/(?:bitbucket|stash))\\/scm\\/(.+)$/i, type: 'bitbucket-server' },\n\t{ custom: false, matcher: /\\bgitlab\\b/i, type: 'gitlab' },\n\t{ custom: false, matcher: /\\bvisualstudio\\.com$/i, type: 'azure-devops' },\n\t{ custom: false, matcher: /\\bgitea\\b/i, type: 'gitea' },\n\t{ custom: false, matcher: /\\bgerrithub\\.io$/i, type: 'gerrit' },\n\t{ custom: false, matcher: /\\bgooglesource\\.com$/i, type: 'google-source' },\n];\n\nconst protocolRegex = /(\\w+)\\W*/;\nfunction cleanProtocol(scheme: string | undefined): string | undefined {\n\tconst protocol = scheme?.match(protocolRegex)?.[1];\n\t// Only preserve web protocols; non-web schemes (e.g. `ssh`, `git`) must fall back to the\n\t// provider's default so web URLs (commit/issue/PR pages) don't inherit an unreachable scheme\n\treturn protocol === 'http' || protocol === 'https' ? protocol : undefined;\n}\n\nfunction createProvider(\n\tentry: ProviderEntry,\n\tdomain: string,\n\tpath: string,\n\tscheme: string | undefined,\n\tcontext?: RemoteProviderContext,\n): RemoteProvider | undefined {\n\tconst protocol = cleanProtocol(entry.protocol ?? scheme);\n\n\tif (entry.type === 'custom' && entry.urls != null) {\n\t\treturn new CustomRemoteProvider(domain, path, entry.urls, protocol, entry.name);\n\t}\n\n\treturn createBuiltInProvider(entry.type, domain, path, protocol, entry.name, entry.custom, context);\n}\n\nfunction createBuiltInProvider(\n\ttype: RemoteProviderId,\n\tdomain: string,\n\tpath: string,\n\tprotocol?: string,\n\tname?: string,\n\tcustom?: boolean,\n\tcontext?: RemoteProviderContext,\n): RemoteProvider | undefined {\n\tdomain = getCloudWebDomain(domain);\n\n\tswitch (type) {\n\t\tcase 'azure-devops':\n\t\t\treturn new AzureDevOpsRemoteProvider(domain, path, protocol, name, isVsts(domain), context);\n\t\tcase 'bitbucket':\n\t\t\treturn new BitbucketRemoteProvider(domain, path, protocol, name, custom, context);\n\t\tcase 'bitbucket-server':\n\t\t\treturn new BitbucketServerRemoteProvider(domain, path, protocol, name, custom, context);\n\t\tcase 'custom':\n\t\t\treturn undefined; // Custom requires urls — handled in config entries\n\t\tcase 'gerrit':\n\t\t\treturn new GerritRemoteProvider(domain, path, protocol, name, custom, undefined, context);\n\t\tcase 'google-source':\n\t\t\treturn new GoogleSourceRemoteProvider(domain, path, protocol, name, custom, context);\n\t\tcase 'gitea':\n\t\t\treturn new GiteaRemoteProvider(domain, path, protocol, name, custom, context);\n\t\tcase 'github':\n\t\t\treturn new GitHubRemoteProvider(domain, path, protocol, name, custom, context);\n\t\tcase 'gitlab':\n\t\t\treturn new GitLabRemoteProvider(domain, path, protocol, name, custom, context);\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nfunction configsToEntries(configs: RemoteProviderConfig[]): ProviderEntry[] {\n\tconst entries: ProviderEntry[] = [];\n\tfor (const cfg of configs) {\n\t\tlet matcher: string | RegExp | undefined;\n\t\ttry {\n\t\t\tmatcher = cfg.regex ? new RegExp(cfg.regex, 'i') : cfg.domain?.toLowerCase();\n\t\t\tif (matcher == null) {\n\t\t\t\tLogger.error(undefined, `Remote provider config for '${cfg.name ?? cfg.type}' has no domain or regex`);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tLogger.error(ex, `Loading remote provider config '${cfg.name ?? cfg.type}' failed`);\n\t\t\tcontinue;\n\t\t}\n\n\t\tentries.push({\n\t\t\tcustom: true,\n\t\t\tmatchUrl: true,\n\t\t\tmatcher: matcher,\n\t\t\ttype: cfg.type,\n\t\t\tprotocol: cfg.protocol,\n\t\t\tname: cfg.name,\n\t\t\turls: cfg.urls,\n\t\t});\n\t}\n\treturn entries;\n}\n\nfunction matchEntries(\n\tentries: ProviderEntry[],\n\turl: string,\n\tdomain: string,\n\tpath: string,\n\tscheme: string | undefined,\n\thooks?: RemoteProviderContext,\n): RemoteProvider | undefined {\n\tconst key = domain?.toLowerCase();\n\tfor (const entry of entries) {\n\t\tif (typeof entry.matcher === 'string') {\n\t\t\tif (entry.matcher === key) {\n\t\t\t\treturn createProvider(entry, domain, path, scheme, hooks);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (entry.matcher.test(key)) {\n\t\t\treturn createProvider(entry, domain, path, scheme, hooks);\n\t\t}\n\t\tif (!entry.matchUrl) continue;\n\n\t\tconst match = entry.matcher.exec(url);\n\t\tif (match == null) continue;\n\n\t\t// A full-URL match must capture a non-empty domain (group 1) and path (group 2) — without\n\t\t// them there is nothing to build the provider from, so skip to the next entry\n\t\tif (!match[1] || !match[2]) {\n\t\t\tif (!warnedMissingGroups.has(entry.matcher.source)) {\n\t\t\t\twarnedMissingGroups.add(entry.matcher.source);\n\t\t\t\t// Don't log the regex itself — users can embed credentials in it\n\t\t\t\tLogger.warn(\n\t\t\t\t\t`Remote provider config '${entry.name ?? entry.type}' regex matched a remote URL but didn't capture both the domain (group 1) and path (group 2); ignoring it for full URL matches`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst matchDomain = match[1].replace(/^[a-zA-Z][\\w+.-]*:\\/\\//, '');\n\t\treturn createProvider(entry, matchDomain, match[2], scheme, hooks);\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Creates a {@link RemoteProviderMatcher} from optional extra configs and built-in providers.\n *\n * Extra configs (from user settings or cloud integrations) are matched first, then built-ins.\n * The optional {@link RemoteProviderContext} is attached to each created provider so it can\n * call host-side providers (e.g., cross-fork PR URLs, autolink decoration).\n *\n * @param configs - Extra provider configs beyond built-ins (user custom remotes, cloud self-managed hosts)\n * @param context - Optional host-provided context to attach to created providers\n */\nexport function createRemoteProviderMatcher(\n\tconfigs?: RemoteProviderConfig[],\n\tcontext?: RemoteProviderContext,\n): RemoteProviderMatcher {\n\tconst extraEntries = configs?.length ? configsToEntries(configs) : undefined;\n\n\treturn (url: string, domain: string, path: string, scheme: string | undefined): RemoteProvider | undefined => {\n\t\ttry {\n\t\t\t// Try extra configs first (user-configured + cloud self-managed take priority)\n\t\t\tif (extraEntries != null) {\n\t\t\t\tconst provider = matchEntries(extraEntries, url, domain, path, scheme, context);\n\t\t\t\tif (provider != null) return provider;\n\t\t\t}\n\n\t\t\t// Fall back to built-in providers\n\t\t\treturn matchEntries(builtInProviders, url, domain, path, scheme, context);\n\t\t} catch (ex) {\n\t\t\tdebugger;\n\t\t\tLogger.error(ex, 'createRemoteProviderMatcher');\n\t\t\treturn undefined;\n\t\t}\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;AAsDA,MAAM,sCAAsB,IAAI,IAAY;AAE5C,MAAM,mBAAoC;CACzC;EAAE,QAAQ;EAAO,SAAS;EAAuC,MAAM;CAAY;CACnF;EAAE,QAAQ;EAAO,SAAS;EAAc,MAAM;CAAS;CACvD;EAAE,QAAQ;EAAO,SAAS;EAAkB,MAAM;CAAS;CAC3D;EAAE,QAAQ;EAAO,SAAS;EAAc,MAAM;CAAS;CACvD;EAAE,QAAQ;EAAO,S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AQ,MAAM,QAAQ,KAAK;EAEzD,IAAI,CAAC,MAAM,UAAU;EAErB,MAAM,QAAQ,MAAM,QAAQ,KAAK,GAAG;EACpC,IAAI,SAAS,MAAM;EAInB,IAAI,CAAC,MAAM,MAAM,CAAC,MAAM,IAAI;GAC3B,IAAI,CAAC,oBAAoB,IAAI,MAAM,QAAQ,MAAM,GAAG;IACnD,oBAAoB,IAAI,MAAM,QAAQ,MAAM;IAE5C,QAAO,KACN,2BAA2B,MAAM,QAAQ,MAAM,KAAK,+HACrD;GACD;GACA;EACD;EAGA,OAAO,eAAe,OADF,MAAM,EAAE,CAAC,QAAQ,0BAA0B,EACxB,GAAG,MAAM,IAAI,QAAQ,KAAK;CAClE;AAGD;;;;;;;;;;;AAYA,SAAgB,4BACf,SACA,SACwB;CACxB,MAAM,eAAe,SAAS,SAAS,iBAAiB,OAAO,IAAI,KAAA;CAEnE,QAAQ,KAAa,QAAgB,MAAc,WAA2D;EAC7G,IAAI;GAEH,IAAI,gBAAgB,MAAM;IACzB,MAAM,WAAW,aAAa,cAAc,KAAK,QAAQ,MAAM,QAAQ,OAAO;IAC9E,IAAI,YAAY,MAAM,OAAO;GAC9B;GAGA,OAAO,aAAa,kBAAkB,KAAK,QAAQ,MAAM,QAAQ,OAAO;EACzE,SAAS,IAAI;GACZ;GACA,QAAO,MAAM,IAAI,6BAA6B;GAC9C;EACD;CACD;AACD"}
@@ -30,6 +30,13 @@ export interface BranchLandedState {
30
30
  newCommits: number;
31
31
  };
32
32
  }
33
+ /**
34
+ * Whether a pull request can vouch for the branch's work landing in the merge target. One merged into another base
35
+ * (a release branch, or the branch below in a stack) didn't land the work in the target, so it can't. One whose base
36
+ * isn't known still can, and an open one always can: at the tip, it's live.
37
+ * @param targetWithoutRemote The merge target's branch name without its remote, as a pull request's base names it
38
+ */
39
+ export declare function isPullRequestRelevantToMergeTarget(pr: Pick<PullRequestShape, 'state' | 'refs'>, targetWithoutRemote: string): boolean;
33
40
  /**
34
41
  * What a branch's pull requests say about whether its work landed. The head sha decides, never recency:
35
42
  * - an open pull request whose head is the tip is live (`live`), so nothing landed
@@ -1,6 +1,15 @@
1
1
  import { getPullRequestNumberFromUrl } from "./pullRequest.utils.js";
2
2
  //#region ../git/src/utils/branchLanded.utils.ts
3
3
  /**
4
+ * Whether a pull request can vouch for the branch's work landing in the merge target. One merged into another base
5
+ * (a release branch, or the branch below in a stack) didn't land the work in the target, so it can't. One whose base
6
+ * isn't known still can, and an open one always can: at the tip, it's live.
7
+ * @param targetWithoutRemote The merge target's branch name without its remote, as a pull request's base names it
8
+ */
9
+ function isPullRequestRelevantToMergeTarget(pr, targetWithoutRemote) {
10
+ return pr.state !== "merged" || !pr.refs?.base?.branch || pr.refs.base.branch === targetWithoutRemote;
11
+ }
12
+ /**
4
13
  * What a branch's pull requests say about whether its work landed. The head sha decides, never recency:
5
14
  * - an open pull request whose head is the tip is live (`live`), so nothing landed
6
15
  * - a merged pull request whose head is the tip landed
@@ -51,6 +60,6 @@ function toLandedPullRequest(pr) {
51
60
  };
52
61
  }
53
62
  //#endregion
54
- export { getBranchLandedState };
63
+ export { getBranchLandedState, isPullRequestRelevantToMergeTarget };
55
64
 
56
65
  //# sourceMappingURL=branchLanded.utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"branchLanded.utils.js","names":[],"sources":["../../../../git/src/utils/branchLanded.utils.ts"],"sourcesContent":["import type { PullRequestShape } from '../models/pullRequest.js';\nimport { getPullRequestNumberFromUrl } from './pullRequest.utils.js';\n\nexport interface BranchLandedPullRequestCandidate {\n\treadonly pullRequest: Pick<PullRequestShape, 'id' | 'url' | 'title' | 'state' | 'refs'>;\n\t/**\n\t * Commits on the branch that are in neither this pull request's head nor the merge target, when known. Only read\n\t * for a merged pull request whose head isn't the tip; leaving it `undefined` leaves that pull request undecided.\n\t */\n\treadonly newCommits?: number;\n}\n\nexport interface BranchLandedState {\n\t/** An open pull request's head is the tip, so the branch is live and nothing landed, whatever git evidence says */\n\tlive?: true;\n\tlanded?: {\n\t\tvia: 'pr';\n\t\tconfidence: 'highest';\n\t\t/** `id` is the pull request's display number where its url names one */\n\t\tpullRequest: { id: string; url: string; title?: string };\n\t};\n\t/** The pull request merged, but the branch has commits it didn't carry — so the branch itself hasn't landed */\n\tsuccessor?: { pullRequest: { id: string; url: string }; newCommits: number };\n}\n\n/**\n * What a branch's pull requests say about whether its work landed. The head sha decides, never recency:\n * - an open pull request whose head is the tip is live (`live`), so nothing landed\n * - a merged pull request whose head is the tip landed\n * - else the merged pull request with the fewest new commits (the first on a tie): none → landed, some → successor\n *\n * A pull request without a head sha (some non-GitHub hosts) never decides, so git evidence can.\n */\nexport function getBranchLandedState(\n\ttipSha: string | undefined,\n\tcandidates: readonly BranchLandedPullRequestCandidate[],\n): BranchLandedState {\n\tif (!tipSha) return {};\n\n\tlet atTip: BranchLandedPullRequestCandidate | undefined;\n\tlet best: BranchLandedPullRequestCandidate | undefined;\n\tfor (const candidate of candidates) {\n\t\tconst { state, refs } = candidate.pullRequest;\n\t\tconst headSha = refs?.head?.sha;\n\t\tif (!headSha) continue;\n\n\t\tif (headSha === tipSha) {\n\t\t\tif (state === 'opened') return { live: true };\n\n\t\t\tif (state === 'merged') {\n\t\t\t\tatTip ??= candidate;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (state !== 'merged' || candidate.newCommits == null) continue;\n\n\t\tif (best?.newCommits == null || candidate.newCommits < best.newCommits) {\n\t\t\tbest = candidate;\n\t\t}\n\t}\n\n\tif (atTip != null) return { landed: toLanded(atTip.pullRequest) };\n\tif (best?.newCommits == null) return {};\n\tif (best.newCommits === 0) return { landed: toLanded(best.pullRequest) };\n\n\tconst { id, url } = toLandedPullRequest(best.pullRequest);\n\treturn {\n\t\tsuccessor: {\n\t\t\tpullRequest: { id: id, url: url },\n\t\t\tnewCommits: best.newCommits,\n\t\t},\n\t};\n}\n\nfunction toLanded(pr: BranchLandedPullRequestCandidate['pullRequest']): NonNullable<BranchLandedState['landed']> {\n\treturn {\n\t\tvia: 'pr',\n\t\tconfidence: 'highest',\n\t\tpullRequest: toLandedPullRequest(pr),\n\t};\n}\n\nfunction toLandedPullRequest(pr: BranchLandedPullRequestCandidate['pullRequest']): {\n\tid: string;\n\turl: string;\n\ttitle?: string;\n} {\n\treturn {\n\t\tid: getPullRequestNumberFromUrl(pr.url) ?? pr.id,\n\t\turl: pr.url,\n\t\ttitle: pr.title,\n\t};\n}\n"],"mappings":";;;;;;;;;;AAiCA,SAAgB,qBACf,QACA,YACoB;CACpB,IAAI,CAAC,QAAQ,OAAO,CAAC;CAErB,IAAI;CACJ,IAAI;CACJ,KAAK,MAAM,aAAa,YAAY;EACnC,MAAM,EAAE,OAAO,SAAS,UAAU;EAClC,MAAM,UAAU,MAAM,MAAM;EAC5B,IAAI,CAAC,SAAS;EAEd,IAAI,YAAY,QAAQ;GACvB,IAAI,UAAU,UAAU,OAAO,EAAE,MAAM,KAAK;GAE5C,IAAI,UAAU,UACb,UAAU;GAEX;EACD;EAEA,IAAI,UAAU,YAAY,UAAU,cAAc,MAAM;EAExD,IAAI,MAAM,cAAc,QAAQ,UAAU,aAAa,KAAK,YAC3D,OAAO;CAET;CAEA,IAAI,SAAS,MAAM,OAAO,EAAE,QAAQ,SAAS,MAAM,WAAW,EAAE;CAChE,IAAI,MAAM,cAAc,MAAM,OAAO,CAAC;CACtC,IAAI,KAAK,eAAe,GAAG,OAAO,EAAE,QAAQ,SAAS,KAAK,WAAW,EAAE;CAEvE,MAAM,EAAE,IAAI,QAAQ,oBAAoB,KAAK,WAAW;CACxD,OAAO,EACN,WAAW;EACV,aAAa;GAAM;GAAS;EAAI;EAChC,YAAY,KAAK;CAClB,EACD;AACD;AAEA,SAAS,SAAS,IAA+F;CAChH,OAAO;EACN,KAAK;EACL,YAAY;EACZ,aAAa,oBAAoB,EAAE;CACpC;AACD;AAEA,SAAS,oBAAoB,IAI3B;CACD,OAAO;EACN,IAAI,4BAA4B,GAAG,GAAG,KAAK,GAAG;EAC9C,KAAK,GAAG;EACR,OAAO,GAAG;CACX;AACD"}
1
+ {"version":3,"file":"branchLanded.utils.js","names":[],"sources":["../../../../git/src/utils/branchLanded.utils.ts"],"sourcesContent":["import type { PullRequestShape } from '../models/pullRequest.js';\nimport { getPullRequestNumberFromUrl } from './pullRequest.utils.js';\n\nexport interface BranchLandedPullRequestCandidate {\n\treadonly pullRequest: Pick<PullRequestShape, 'id' | 'url' | 'title' | 'state' | 'refs'>;\n\t/**\n\t * Commits on the branch that are in neither this pull request's head nor the merge target, when known. Only read\n\t * for a merged pull request whose head isn't the tip; leaving it `undefined` leaves that pull request undecided.\n\t */\n\treadonly newCommits?: number;\n}\n\nexport interface BranchLandedState {\n\t/** An open pull request's head is the tip, so the branch is live and nothing landed, whatever git evidence says */\n\tlive?: true;\n\tlanded?: {\n\t\tvia: 'pr';\n\t\tconfidence: 'highest';\n\t\t/** `id` is the pull request's display number where its url names one */\n\t\tpullRequest: { id: string; url: string; title?: string };\n\t};\n\t/** The pull request merged, but the branch has commits it didn't carry — so the branch itself hasn't landed */\n\tsuccessor?: { pullRequest: { id: string; url: string }; newCommits: number };\n}\n\n/**\n * Whether a pull request can vouch for the branch's work landing in the merge target. One merged into another base\n * (a release branch, or the branch below in a stack) didn't land the work in the target, so it can't. One whose base\n * isn't known still can, and an open one always can: at the tip, it's live.\n * @param targetWithoutRemote The merge target's branch name without its remote, as a pull request's base names it\n */\nexport function isPullRequestRelevantToMergeTarget(\n\tpr: Pick<PullRequestShape, 'state' | 'refs'>,\n\ttargetWithoutRemote: string,\n): boolean {\n\treturn pr.state !== 'merged' || !pr.refs?.base?.branch || pr.refs.base.branch === targetWithoutRemote;\n}\n\n/**\n * What a branch's pull requests say about whether its work landed. The head sha decides, never recency:\n * - an open pull request whose head is the tip is live (`live`), so nothing landed\n * - a merged pull request whose head is the tip landed\n * - else the merged pull request with the fewest new commits (the first on a tie): none → landed, some → successor\n *\n * A pull request without a head sha (some non-GitHub hosts) never decides, so git evidence can.\n */\nexport function getBranchLandedState(\n\ttipSha: string | undefined,\n\tcandidates: readonly BranchLandedPullRequestCandidate[],\n): BranchLandedState {\n\tif (!tipSha) return {};\n\n\tlet atTip: BranchLandedPullRequestCandidate | undefined;\n\tlet best: BranchLandedPullRequestCandidate | undefined;\n\tfor (const candidate of candidates) {\n\t\tconst { state, refs } = candidate.pullRequest;\n\t\tconst headSha = refs?.head?.sha;\n\t\tif (!headSha) continue;\n\n\t\tif (headSha === tipSha) {\n\t\t\tif (state === 'opened') return { live: true };\n\n\t\t\tif (state === 'merged') {\n\t\t\t\tatTip ??= candidate;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (state !== 'merged' || candidate.newCommits == null) continue;\n\n\t\tif (best?.newCommits == null || candidate.newCommits < best.newCommits) {\n\t\t\tbest = candidate;\n\t\t}\n\t}\n\n\tif (atTip != null) return { landed: toLanded(atTip.pullRequest) };\n\tif (best?.newCommits == null) return {};\n\tif (best.newCommits === 0) return { landed: toLanded(best.pullRequest) };\n\n\tconst { id, url } = toLandedPullRequest(best.pullRequest);\n\treturn {\n\t\tsuccessor: {\n\t\t\tpullRequest: { id: id, url: url },\n\t\t\tnewCommits: best.newCommits,\n\t\t},\n\t};\n}\n\nfunction toLanded(pr: BranchLandedPullRequestCandidate['pullRequest']): NonNullable<BranchLandedState['landed']> {\n\treturn {\n\t\tvia: 'pr',\n\t\tconfidence: 'highest',\n\t\tpullRequest: toLandedPullRequest(pr),\n\t};\n}\n\nfunction toLandedPullRequest(pr: BranchLandedPullRequestCandidate['pullRequest']): {\n\tid: string;\n\turl: string;\n\ttitle?: string;\n} {\n\treturn {\n\t\tid: getPullRequestNumberFromUrl(pr.url) ?? pr.id,\n\t\turl: pr.url,\n\t\ttitle: pr.title,\n\t};\n}\n"],"mappings":";;;;;;;;AA+BA,SAAgB,mCACf,IACA,qBACU;CACV,OAAO,GAAG,UAAU,YAAY,CAAC,GAAG,MAAM,MAAM,UAAU,GAAG,KAAK,KAAK,WAAW;AACnF;;;;;;;;;AAUA,SAAgB,qBACf,QACA,YACoB;CACpB,IAAI,CAAC,QAAQ,OAAO,CAAC;CAErB,IAAI;CACJ,IAAI;CACJ,KAAK,MAAM,aAAa,YAAY;EACnC,MAAM,EAAE,OAAO,SAAS,UAAU;EAClC,MAAM,UAAU,MAAM,MAAM;EAC5B,IAAI,CAAC,SAAS;EAEd,IAAI,YAAY,QAAQ;GACvB,IAAI,UAAU,UAAU,OAAO,EAAE,MAAM,KAAK;GAE5C,IAAI,UAAU,UACb,UAAU;GAEX;EACD;EAEA,IAAI,UAAU,YAAY,UAAU,cAAc,MAAM;EAExD,IAAI,MAAM,cAAc,QAAQ,UAAU,aAAa,KAAK,YAC3D,OAAO;CAET;CAEA,IAAI,SAAS,MAAM,OAAO,EAAE,QAAQ,SAAS,MAAM,WAAW,EAAE;CAChE,IAAI,MAAM,cAAc,MAAM,OAAO,CAAC;CACtC,IAAI,KAAK,eAAe,GAAG,OAAO,EAAE,QAAQ,SAAS,KAAK,WAAW,EAAE;CAEvE,MAAM,EAAE,IAAI,QAAQ,oBAAoB,KAAK,WAAW;CACxD,OAAO,EACN,WAAW;EACV,aAAa;GAAM;GAAS;EAAI;EAChC,YAAY,KAAK;CAClB,EACD;AACD;AAEA,SAAS,SAAS,IAA+F;CAChH,OAAO;EACN,KAAK;EACL,YAAY;EACZ,aAAa,oBAAoB,EAAE;CACpC;AACD;AAEA,SAAS,oBAAoB,IAI3B;CACD,OAAO;EACN,IAAI,4BAA4B,GAAG,GAAG,KAAK,GAAG;EAC9C,KAAK,GAAG;EACR,OAAO,GAAG;CACX;AACD"}
@@ -17,6 +17,7 @@ export declare function getVisibilityCacheKey(remotes: GitRemote[]): string;
17
17
  export declare const gitSuffixRegex: RegExp;
18
18
  export declare const remoteUrlRegex: RegExp;
19
19
  export declare function parseGitRemoteUrl(url: string): [scheme: string, domain: string, path: string];
20
+ export declare function getCloudWebDomain(domain: string): string;
20
21
  export declare function getNameFromRemoteResource(resource: RemoteResource): string;
21
22
  //#endregion
22
23
  //# sourceMappingURL=remote.utils.d.ts.map
@@ -57,7 +57,7 @@ function getVisibilityCacheKey(remotes) {
57
57
  return remotes.map((r) => r.remoteKey).sort().join(",");
58
58
  }
59
59
  const gitSuffixRegex = /\.git\/?$/;
60
- const remoteUrlRegex = /^(?:(git:\/\/)(.*?)\/|(https?:\/\/)(?:.*?@)?(.*?)\/|git@(.*):|(ssh:\/\/)(?:.*@)?(.*?)(?::.*?)?(?:\/|(?=~))|(?:.*?@)(.*?):)(.*)$/;
60
+ const remoteUrlRegex = /^(?:(git:\/\/)(.*?)\/|(https?:\/\/)(?:[^/?#]*@)?([^/?#]*?)\/|(ssh:\/\/)(?:[^/]*@)?([^/]*?)(?::[^/]*?)?(?:\/|(?=~))|[^/:]*?@(\[[^\]/]*\]|[^/:@]*):)(.*)$/;
61
61
  function parseGitRemoteUrl(url) {
62
62
  const match = remoteUrlRegex.exec(url);
63
63
  if (match == null) return [
@@ -66,11 +66,20 @@ function parseGitRemoteUrl(url) {
66
66
  url
67
67
  ];
68
68
  return [
69
- match[1] || match[3] || match[6],
70
- match[2] || match[4] || match[5] || match[7] || match[8],
71
- match[9].replace(gitSuffixRegex, "")
69
+ match[1] || match[3] || match[5],
70
+ match[2] || match[4] || match[6] || match[7],
71
+ match[8].replace(gitSuffixRegex, "")
72
72
  ];
73
73
  }
74
+ const cloudSshDomains = /* @__PURE__ */ new Map([
75
+ ["ssh.bitbucket.org", "bitbucket.org"],
76
+ ["altssh.bitbucket.org", "bitbucket.org"],
77
+ ["ssh.github.com", "github.com"],
78
+ ["altssh.gitlab.com", "gitlab.com"]
79
+ ]);
80
+ function getCloudWebDomain(domain) {
81
+ return cloudSshDomains.get(domain.toLowerCase()) ?? domain;
82
+ }
74
83
  function getNameFromRemoteResource(resource) {
75
84
  switch (resource.type) {
76
85
  case "branch": return l10n.t("Branch");
@@ -85,6 +94,6 @@ function getNameFromRemoteResource(resource) {
85
94
  }
86
95
  }
87
96
  //#endregion
88
- export { getDefaultRemoteOrHighlander, getDefaultRemoteOrOrigin, getHighlanderProviderName, getHighlanderProviders, getNameFromRemoteResource, getRemoteArrowsGlyph, getRemoteProviderThemeIconString, getRemoteThemeIconString, getRemoteUpstreamDescription, getVisibilityCacheKey, gitSuffixRegex, parseGitRemoteUrl, remoteUrlRegex };
97
+ export { getCloudWebDomain, getDefaultRemoteOrHighlander, getDefaultRemoteOrOrigin, getHighlanderProviderName, getHighlanderProviders, getNameFromRemoteResource, getRemoteArrowsGlyph, getRemoteProviderThemeIconString, getRemoteThemeIconString, getRemoteUpstreamDescription, getVisibilityCacheKey, gitSuffixRegex, parseGitRemoteUrl, remoteUrlRegex };
89
98
 
90
99
  //# sourceMappingURL=remote.utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"remote.utils.js","names":[],"sources":["../../../../git/src/utils/remote.utils.ts"],"sourcesContent":["import * as l10n from '@vscode/l10n';\nimport type { GitRemote } from '../models/remote.js';\nimport type { RemoteProvider } from '../models/remoteProvider.js';\nimport type { RemoteResource } from '../models/remoteResource.js';\nimport { RemoteResourceType } from '../models/remoteResource.js';\n\nexport function getDefaultRemoteOrHighlander<T extends GitRemote>(remotes: T[]): T | undefined {\n\treturn remotes.length === 1 ? remotes[0] : remotes.find(r => r.default);\n}\n\n/** Like {@link getDefaultRemoteOrHighlander}, but falls back to `origin` when no remote is designated\n * default — otherwise features keyed on \"the default remote\" silently do nothing on multi-remote repos */\nexport function getDefaultRemoteOrOrigin<T extends GitRemote>(remotes: T[]): T | undefined {\n\treturn getDefaultRemoteOrHighlander(remotes) ?? remotes.find(r => r.name === 'origin');\n}\n\nexport function getHighlanderProviderName(remotes: GitRemote<RemoteProvider>[]): string | undefined {\n\tif (remotes.length === 0) return undefined;\n\n\tconst remote = getDefaultRemoteOrHighlander(remotes);\n\tif (remote != null) return remote.provider.name;\n\n\tconst providerName = remotes[0].provider.name;\n\t// Only use the real provider name if there is only 1 type of provider\n\tif (remotes.every(r => r.provider.name === providerName)) return providerName;\n\n\treturn undefined;\n}\n\nexport function getHighlanderProviders(remotes: GitRemote<RemoteProvider>[]): RemoteProvider[] | undefined {\n\tif (remotes.length === 0) return undefined;\n\n\tconst remote = getDefaultRemoteOrHighlander(remotes);\n\tif (remote != null) return [remote.provider];\n\n\tconst providerName = remotes[0].provider.name;\n\tif (remotes.every(r => r.provider.name === providerName)) return remotes.map(r => r.provider);\n\n\treturn undefined;\n}\n\nexport function getRemoteArrowsGlyph(remote: GitRemote): string {\n\tlet arrows;\n\tlet left;\n\tlet right;\n\tfor (const { type } of remote.urls) {\n\t\tif (type === 'fetch') {\n\t\t\tleft = true;\n\n\t\t\tif (right) break;\n\t\t} else if (type === 'push') {\n\t\t\tright = true;\n\n\t\t\tif (left) break;\n\t\t}\n\t}\n\n\tif (left && right) {\n\t\tarrows = '\\u21c4'; // ArrowsRightLeft\n\t} else if (right) {\n\t\tarrows = '\\u2192'; // ArrowRight\n\t} else if (left) {\n\t\tarrows = '\\u2190'; // ArrowLeft\n\t} else {\n\t\tarrows = '\\u2014'; // Dash\n\t}\n\n\treturn arrows;\n}\n\nexport function getRemoteThemeIconString(remote: GitRemote | undefined): string {\n\treturn getRemoteProviderThemeIconString(remote?.provider);\n}\n\nexport function getRemoteProviderThemeIconString(provider: RemoteProvider | undefined): string {\n\treturn provider != null ? `gitlens-provider-${provider.icon}` : 'cloud';\n}\n\nexport function getRemoteUpstreamDescription(remote: GitRemote): string {\n\tconst arrows = getRemoteArrowsGlyph(remote);\n\n\tconst { provider } = remote;\n\tif (provider != null) {\n\t\treturn `${arrows}\\u00a0 ${provider.name} \\u00a0\\u2022\\u00a0 ${provider.displayPath}`;\n\t}\n\n\treturn `${arrows}\\u00a0 ${remote.domain ? `${remote.domain} \\u00a0\\u2022\\u00a0 ` : ''}${remote.path}`;\n}\n\nexport function getVisibilityCacheKey(remote: GitRemote): string;\nexport function getVisibilityCacheKey(remotes: GitRemote[]): string;\nexport function getVisibilityCacheKey(remotes: GitRemote | GitRemote[]): string {\n\tif (!Array.isArray(remotes)) return remotes.remoteKey;\n\treturn remotes\n\t\t.map(r => r.remoteKey)\n\t\t.sort()\n\t\t.join(',');\n}\n\nexport const gitSuffixRegex = /\\.git\\/?$/;\n\n// Test git urls\n/*\nhttp://host.xz/user/project.git\nhttps://host.xz/user/project.git\ngit@host.xz:user/project.git\ngit://host.xz/path/to/repo.git/\nssh://host.xz/project.git\nssh://user@host.xz/path/to/repo.git\nuser@host.xz:path/to/repo.git\n*/\nexport const remoteUrlRegex =\n\t/^(?:(git:\\/\\/)(.*?)\\/|(https?:\\/\\/)(?:.*?@)?(.*?)\\/|git@(.*):|(ssh:\\/\\/)(?:.*@)?(.*?)(?::.*?)?(?:\\/|(?=~))|(?:.*?@)(.*?):)(.*)$/;\n\nexport function parseGitRemoteUrl(url: string): [scheme: string, domain: string, path: string] {\n\tconst match = remoteUrlRegex.exec(url);\n\tif (match == null) return ['', '', url];\n\n\treturn [\n\t\tmatch[1] || match[3] || match[6],\n\t\tmatch[2] || match[4] || match[5] || match[7] || match[8],\n\t\tmatch[9].replace(gitSuffixRegex, ''),\n\t];\n}\n\nexport function getNameFromRemoteResource(resource: RemoteResource): string {\n\tswitch (resource.type) {\n\t\tcase RemoteResourceType.Branch:\n\t\t\treturn l10n.t('Branch');\n\t\tcase RemoteResourceType.Branches:\n\t\t\treturn l10n.t('Branches');\n\t\tcase RemoteResourceType.Commit:\n\t\t\treturn l10n.t('Commit');\n\t\tcase RemoteResourceType.Comparison:\n\t\t\treturn l10n.t('Comparison');\n\t\tcase RemoteResourceType.CreatePullRequest:\n\t\t\treturn l10n.t('Create Pull Request');\n\t\tcase RemoteResourceType.File:\n\t\t\treturn l10n.t('File');\n\t\tcase RemoteResourceType.Repo:\n\t\t\treturn l10n.t('Repository');\n\t\tcase RemoteResourceType.Revision:\n\t\t\treturn l10n.t('File');\n\t\tdefault:\n\t\t\treturn '';\n\t}\n}\n"],"mappings":";;;AAMA,SAAgB,6BAAkD,S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git/src/utils/remote.utils.ts"],"sourcesContent":["import * as l10n from '@vscode/l10n';\nimport type { GitRemote } from '../models/remote.js';\nimport type { RemoteProvider } from '../models/remoteProvider.js';\nimport type { RemoteResource } from '../models/remoteResource.js';\nimport { RemoteResourceType } from '../models/remoteResource.js';\n\nexport function getDefaultRemoteOrHighlander<T extends GitRemote>(remotes: T[]): T | undefined {\n\treturn remotes.length === 1 ? remotes[0] : remotes.find(r => r.default);\n}\n\n/** Like {@link getDefaultRemoteOrHighlander}, but falls back to `origin` when no remote is designated\n * default — otherwise features keyed on \"the default remote\" silently do nothing on multi-remote repos */\nexport function getDefaultRemoteOrOrigin<T extends GitRemote>(remotes: T[]): T | undefined {\n\treturn getDefaultRemoteOrHighlander(remotes) ?? remotes.find(r => r.name === 'origin');\n}\n\nexport function getHighlanderProviderName(remotes: GitRemote<RemoteProvider>[]): string | undefined {\n\tif (remotes.length === 0) return undefined;\n\n\tconst remote = getDefaultRemoteOrHighlander(remotes);\n\tif (remote != null) return remote.provider.name;\n\n\tconst providerName = remotes[0].provider.name;\n\t// Only use the real provider name if there is only 1 type of provider\n\tif (remotes.every(r => r.provider.name === providerName)) return providerName;\n\n\treturn undefined;\n}\n\nexport function getHighlanderProviders(remotes: GitRemote<RemoteProvider>[]): RemoteProvider[] | undefined {\n\tif (remotes.length === 0) return undefined;\n\n\tconst remote = getDefaultRemoteOrHighlander(remotes);\n\tif (remote != null) return [remote.provider];\n\n\tconst providerName = remotes[0].provider.name;\n\tif (remotes.every(r => r.provider.name === providerName)) return remotes.map(r => r.provider);\n\n\treturn undefined;\n}\n\nexport function getRemoteArrowsGlyph(remote: GitRemote): string {\n\tlet arrows;\n\tlet left;\n\tlet right;\n\tfor (const { type } of remote.urls) {\n\t\tif (type === 'fetch') {\n\t\t\tleft = true;\n\n\t\t\tif (right) break;\n\t\t} else if (type === 'push') {\n\t\t\tright = true;\n\n\t\t\tif (left) break;\n\t\t}\n\t}\n\n\tif (left && right) {\n\t\tarrows = '\\u21c4'; // ArrowsRightLeft\n\t} else if (right) {\n\t\tarrows = '\\u2192'; // ArrowRight\n\t} else if (left) {\n\t\tarrows = '\\u2190'; // ArrowLeft\n\t} else {\n\t\tarrows = '\\u2014'; // Dash\n\t}\n\n\treturn arrows;\n}\n\nexport function getRemoteThemeIconString(remote: GitRemote | undefined): string {\n\treturn getRemoteProviderThemeIconString(remote?.provider);\n}\n\nexport function getRemoteProviderThemeIconString(provider: RemoteProvider | undefined): string {\n\treturn provider != null ? `gitlens-provider-${provider.icon}` : 'cloud';\n}\n\nexport function getRemoteUpstreamDescription(remote: GitRemote): string {\n\tconst arrows = getRemoteArrowsGlyph(remote);\n\n\tconst { provider } = remote;\n\tif (provider != null) {\n\t\treturn `${arrows}\\u00a0 ${provider.name} \\u00a0\\u2022\\u00a0 ${provider.displayPath}`;\n\t}\n\n\treturn `${arrows}\\u00a0 ${remote.domain ? `${remote.domain} \\u00a0\\u2022\\u00a0 ` : ''}${remote.path}`;\n}\n\nexport function getVisibilityCacheKey(remote: GitRemote): string;\nexport function getVisibilityCacheKey(remotes: GitRemote[]): string;\nexport function getVisibilityCacheKey(remotes: GitRemote | GitRemote[]): string {\n\tif (!Array.isArray(remotes)) return remotes.remoteKey;\n\treturn remotes\n\t\t.map(r => r.remoteKey)\n\t\t.sort()\n\t\t.join(',');\n}\n\nexport const gitSuffixRegex = /\\.git\\/?$/;\n\n// Test git urls\n/*\nhttp://host.xz/user/project.git\nhttps://host.xz/user/project.git\ngit@host.xz:user/project.git\ngit://host.xz/path/to/repo.git/\nssh://host.xz/project.git\nssh://user@host.xz/path/to/repo.git\nuser@host.xz:path/to/repo.git\n*/\n// A user or host never contains a `/` (nor `?` or `#` on the web), and an scp-like host ends at the first `:` — past that, `@` and `:` are path\nexport const remoteUrlRegex =\n\t/^(?:(git:\\/\\/)(.*?)\\/|(https?:\\/\\/)(?:[^/?#]*@)?([^/?#]*?)\\/|(ssh:\\/\\/)(?:[^/]*@)?([^/]*?)(?::[^/]*?)?(?:\\/|(?=~))|[^/:]*?@(\\[[^\\]/]*\\]|[^/:@]*):)(.*)$/;\n\nexport function parseGitRemoteUrl(url: string): [scheme: string, domain: string, path: string] {\n\tconst match = remoteUrlRegex.exec(url);\n\tif (match == null) return ['', '', url];\n\n\treturn [\n\t\tmatch[1] || match[3] || match[5],\n\t\tmatch[2] || match[4] || match[6] || match[7],\n\t\tmatch[8].replace(gitSuffixRegex, ''),\n\t];\n}\n\n// SSH-only hosts of the cloud providers (e.g. SSH over port 443) and the web host their links must point at.\n// Exact names only — other subdomains are not SSH endpoints\nconst cloudSshDomains = new Map<string, string>([\n\t['ssh.bitbucket.org', 'bitbucket.org'],\n\t['altssh.bitbucket.org', 'bitbucket.org'],\n\t['ssh.github.com', 'github.com'],\n\t['altssh.gitlab.com', 'gitlab.com'],\n]);\n\nexport function getCloudWebDomain(domain: string): string {\n\treturn cloudSshDomains.get(domain.toLowerCase()) ?? domain;\n}\n\nexport function getNameFromRemoteResource(resource: RemoteResource): string {\n\tswitch (resource.type) {\n\t\tcase RemoteResourceType.Branch:\n\t\t\treturn l10n.t('Branch');\n\t\tcase RemoteResourceType.Branches:\n\t\t\treturn l10n.t('Branches');\n\t\tcase RemoteResourceType.Commit:\n\t\t\treturn l10n.t('Commit');\n\t\tcase RemoteResourceType.Comparison:\n\t\t\treturn l10n.t('Comparison');\n\t\tcase RemoteResourceType.CreatePullRequest:\n\t\t\treturn l10n.t('Create Pull Request');\n\t\tcase RemoteResourceType.File:\n\t\t\treturn l10n.t('File');\n\t\tcase RemoteResourceType.Repo:\n\t\t\treturn l10n.t('Repository');\n\t\tcase RemoteResourceType.Revision:\n\t\t\treturn l10n.t('File');\n\t\tdefault:\n\t\t\treturn '';\n\t}\n}\n"],"mappings":";;;AAMA,SAAgB,6BAAkD,SAA6B;CAC9F,OAAO,QAAQ,WAAW,IAAI,QAAQ,KAAK,QAAQ,MAAK,MAAK,EAAE,OAAO;AACvE;;;AAIA,SAAgB,yBAA8C,SAA6B;CA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