Git Blame "Open on Github" supports any url - #282970
Git Blame "Open on Github" supports any url#282970Somodi Soma (sigidi) wants to merge 23 commits into
Conversation
Updated getRepositoryFromUrl and getRepositoryDefaultRemote functions to include baseUrl in the return type.
Updated getBranchLink and getCommitLink functions to use a base URL derived from hostPrefix or repo.baseUrl.
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: Ladislau Szomoru (@lszomoru)Matched files:
|
@microsoft-github-policy-service agree |
|
Hi Ladislau Szomoru (@lszomoru), I’m new to the VS Code repo. Are there any specific steps I need to take for the review process, or is there anything else you need from my side? Thanks! |
|
Hi Ladislau Szomoru (@lszomoru), |
|
Hi Ladislau Szomoru (@lszomoru), I imagine Somodi Soma (@sigidi) is too embarassed to ping you a third time without answer, so I will instead. How does this PR get progressed? |
|
Ladislau Szomoru (@lszomoru) are you still an assigned person to look at this or should we ask someone else? |
|
This feature seems quite handy to me as I use a selfhosted gitlab instance most of the time. It would be nice if someone could get the community PR Approvals ready ;). |
There was a problem hiding this comment.
Pull request overview
This PR updates the built-in GitHub extension’s “Open on GitHub” link generation and UI labeling so that links can be derived from the repository remote’s base URL (showing “Open on <host>” instead of always “Open on GitHub”), aligning with the Git Blame/commit-opening workflow.
Changes:
- Extend remote URL parsing to return a
baseUrland attempt to support non-github.comremotes. - Update commit/branch link helpers to use the derived
baseUrlwhen no explicit host override is provided. - Update SCM history hover command label/tooltip (and issue link formatting) to use the derived host label/base URL.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
extensions/github/src/util.ts |
Expands remote URL parsing to include baseUrl and adds generic host matching. |
extensions/github/src/links.ts |
Uses parsed baseUrl to build commit/branch web links by default. |
extensions/github/src/historyItemDetailsProvider.ts |
Changes hover command labeling to “Open on <host>” and uses baseUrl for generated issue links. |
| } | ||
|
|
||
| // Generic HTTPS URL: https://host/owner/repo[.git] | ||
| match = /^https:\/\/([^/]+)\/([^/]+)\/([^/]+?)(\.git)?$/i.exec(url); |
| const baseUrl = hostPrefix ?? repo.baseUrl; | ||
| return `${baseUrl}/${repo.owner}/${repo.repo}/commit/${hash}`; |
| return [{ | ||
| title: l10n.t('{0} Open on GitHub', '$(github)'), | ||
| tooltip: l10n.t('Open on GitHub'), | ||
| title: l10n.t('{0} Open on {1}', '$(github)', host), |
| match = /^https:\/\/([^/]+)\/([^/]+)\/([^/]+?)(\.git)?$/i.exec(url); | ||
| if (match) { | ||
| return { owner: match[2], repo: match[3], baseUrl: `https://${match[1]}` }; | ||
| } |
Fixes #239878
Now instead of "Open on Github" in git blame github extension, it shows Open on .
baseUrl still comes from remote origin's url.