parent
d5c5394693
commit
c2428f9f5d
6 changed files with 40 additions and 18 deletions
|
@ -4,6 +4,7 @@ use anyhow::Result;
|
|||
use collections::HashMap;
|
||||
use git::{
|
||||
blame::{Blame, BlameEntry},
|
||||
permalink::{build_commit_permalink, parse_git_remote_url},
|
||||
Oid,
|
||||
};
|
||||
use gpui::{Model, ModelContext, Subscription, Task};
|
||||
|
@ -286,11 +287,13 @@ impl GitBlame {
|
|||
entries,
|
||||
permalinks,
|
||||
messages,
|
||||
remote_url,
|
||||
} = blame.await?;
|
||||
|
||||
let entries = build_blame_entry_sum_tree(entries, snapshot.max_point().row);
|
||||
let commit_details =
|
||||
parse_commit_messages(messages, &permalinks, &languages).await;
|
||||
parse_commit_messages(messages, remote_url, &permalinks, &languages)
|
||||
.await;
|
||||
|
||||
anyhow::Ok((entries, commit_details))
|
||||
}
|
||||
|
@ -379,13 +382,31 @@ fn build_blame_entry_sum_tree(entries: Vec<BlameEntry>, max_row: u32) -> SumTree
|
|||
|
||||
async fn parse_commit_messages(
|
||||
messages: impl IntoIterator<Item = (Oid, String)>,
|
||||
permalinks: &HashMap<Oid, Url>,
|
||||
remote_url: Option<String>,
|
||||
deprecated_permalinks: &HashMap<Oid, Url>,
|
||||
languages: &Arc<LanguageRegistry>,
|
||||
) -> HashMap<Oid, CommitDetails> {
|
||||
let mut commit_details = HashMap::default();
|
||||
|
||||
let parsed_remote_url = remote_url.as_deref().and_then(parse_git_remote_url);
|
||||
|
||||
for (oid, message) in messages {
|
||||
let parsed_message = parse_markdown(&message, &languages).await;
|
||||
let permalink = permalinks.get(&oid).cloned();
|
||||
|
||||
let permalink = if let Some(git_remote) = parsed_remote_url.as_ref() {
|
||||
Some(build_commit_permalink(
|
||||
git::permalink::BuildCommitPermalinkParams {
|
||||
remote: git_remote,
|
||||
sha: oid.to_string().as_str(),
|
||||
},
|
||||
))
|
||||
} else {
|
||||
// DEPRECATED (18 Apr 24): Sending permalinks over the wire is deprecated. Clients
|
||||
// now do the parsing. This is here for backwards compatibility, so that
|
||||
// when an old peer sends a client no `parsed_remote_url` but `deprecated_permalinks`,
|
||||
// we fall back to that.
|
||||
deprecated_permalinks.get(&oid).cloned()
|
||||
};
|
||||
|
||||
commit_details.insert(
|
||||
oid,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue