git_ui: Fix double slash in commit URLs (#44996)
Release Notes: - Fixed double slash in commit URLs The github_url variable was generating URLs with an extra slash like "https://github.com//user/repo/commit/xxxx" due to manual string formatting of the base_url() result. Fixed by replacing manual URL construction with the proper build_commit_permalink() method that uses Url::join() for correct path handling, consistent with how other Git hosting providers construct URLs. Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
This commit is contained in:
1 parent
267abdab06
commit
6457f1f47b
1 file changed
+13
-8
@@ -3,7 +3,10 @@ use buffer_diff::{BufferDiff, BufferDiffSnapshot};
|
||||
use editor::display_map::{BlockPlacement, BlockProperties, BlockStyle};
|
||||
use editor::{Editor, EditorEvent, ExcerptRange, MultiBuffer, multibuffer_context_lines};
|
||||
use git::repository::{CommitDetails, CommitDiff, RepoPath};
|
||||
use git::{GitHostingProviderRegistry, GitRemote, parse_git_remote_url};
|
||||
use git::{
|
||||
BuildCommitPermalinkParams, GitHostingProviderRegistry, GitRemote, ParsedGitRemote,
|
||||
parse_git_remote_url,
|
||||
};
|
||||
use gpui::{
|
||||
AnyElement, App, AppContext as _, AsyncApp, AsyncWindowContext, Context, Element, Entity,
|
||||
EventEmitter, FocusHandle, Focusable, InteractiveElement, IntoElement, ParentElement,
|
||||
@@ -393,13 +396,15 @@ impl CommitView {
|
||||
|
||||
let remote_info = self.remote.as_ref().map(|remote| {
|
||||
let provider = remote.host.name();
|
||||
let url = format!(
|
||||
"{}/{}/{}/commit/{}",
|
||||
remote.host.base_url(),
|
||||
remote.owner,
|
||||
remote.repo,
|
||||
commit.sha
|
||||
);
|
||||
let parsed_remote = ParsedGitRemote {
|
||||
owner: remote.owner.as_ref().into(),
|
||||
repo: remote.repo.as_ref().into(),
|
||||
};
|
||||
let params = BuildCommitPermalinkParams { sha: &commit.sha };
|
||||
let url = remote
|
||||
.host
|
||||
.build_commit_permalink(&parsed_remote, params)
|
||||
.to_string();
|
||||
(provider, url)
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user