mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-26 19:15:25 +03:00
look mom im a rust programmer
(make the get base_base_branch_data use proxied assets)
This commit is contained in:
parent
4bd00063d0
commit
fbe54b844d
@ -687,7 +687,77 @@ async fn get_base_branch_data(
|
||||
) -> Result<Option<virtual_branches::BaseBranch>, Error> {
|
||||
let app = handle.state::<app::App>();
|
||||
let target = app.get_base_branch_data(project_id)?;
|
||||
Ok(target)
|
||||
|
||||
let out = match target {
|
||||
None => Ok(target),
|
||||
Some(t) => {
|
||||
let proxy = handle.state::<assets::Proxy>();
|
||||
let mut proxy_map = HashMap::new();
|
||||
let recent_commits_author_urls = t
|
||||
.clone()
|
||||
.recent_commits
|
||||
.into_iter()
|
||||
.map(|commit| commit.author.gravatar_url.clone())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let upstream_commits_author_urls = t
|
||||
.clone()
|
||||
.upstream_commits
|
||||
.into_iter()
|
||||
.map(|commit| commit.author.gravatar_url.clone())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let author_urls = recent_commits_author_urls
|
||||
.into_iter()
|
||||
.chain(upstream_commits_author_urls.into_iter())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
for url in author_urls {
|
||||
if !proxy_map.contains_key(&url) {
|
||||
let proxied_url = proxy.proxy(&url).await?;
|
||||
proxy_map.insert(url, proxied_url);
|
||||
}
|
||||
}
|
||||
|
||||
let target = Some(virtual_branches::BaseBranch {
|
||||
recent_commits: t
|
||||
.clone()
|
||||
.recent_commits
|
||||
.into_iter()
|
||||
.map(|commit| virtual_branches::VirtualBranchCommit {
|
||||
author: virtual_branches::Author {
|
||||
gravatar_url: proxy_map
|
||||
.get(&commit.author.gravatar_url)
|
||||
.unwrap()
|
||||
.clone(),
|
||||
..commit.author
|
||||
},
|
||||
..commit
|
||||
})
|
||||
.collect(),
|
||||
upstream_commits: t
|
||||
.clone()
|
||||
.upstream_commits
|
||||
.into_iter()
|
||||
.map(|commit| virtual_branches::VirtualBranchCommit {
|
||||
author: virtual_branches::Author {
|
||||
gravatar_url: proxy_map
|
||||
.get(&commit.author.gravatar_url)
|
||||
.unwrap()
|
||||
.clone(),
|
||||
..commit.author
|
||||
},
|
||||
..commit
|
||||
})
|
||||
.collect(),
|
||||
..t
|
||||
});
|
||||
|
||||
Ok(target)
|
||||
}
|
||||
};
|
||||
return out;
|
||||
// Ok(target)
|
||||
}
|
||||
|
||||
#[timed(duration(printer = "debug!"))]
|
||||
|
Loading…
Reference in New Issue
Block a user