From f96cab286ca7d51e6fb49fbfbc6933897b47685c Mon Sep 17 00:00:00 2001
From: Stanislav Alekseev <43210583+WeetHet@users.noreply.github.com>
Date: Tue, 30 Apr 2024 13:57:10 +0300
Subject: [PATCH] Add avatar support for codeberg in git blame (#10991)
Release Notes:
- Added support for avatars in git blame for repositories hosted on
codeberg
Questions:
- Should we move git stuff like `Commit`, `Author`, etc outside of
hosting-specific files (I don't think so, as other hostings can have
different stuff)
- Should we also add support for self hosted forgejo instances or should
it be a different PR?
---
crates/git/src/hosting_provider.rs | 35 ++++++++------
crates/util/src/codeberg.rs | 78 ++++++++++++++++++++++++++++++
crates/util/src/git_author.rs | 5 ++
crates/util/src/github.rs | 15 ++----
crates/util/src/util.rs | 2 +
5 files changed, 107 insertions(+), 28 deletions(-)
create mode 100644 crates/util/src/codeberg.rs
create mode 100644 crates/util/src/git_author.rs
diff --git a/crates/git/src/hosting_provider.rs b/crates/git/src/hosting_provider.rs
index eb7f9c5523..e51e5905c2 100644
--- a/crates/git/src/hosting_provider.rs
+++ b/crates/git/src/hosting_provider.rs
@@ -3,7 +3,7 @@ use std::{ops::Range, sync::Arc};
use anyhow::Result;
use url::Url;
-use util::{github, http::HttpClient};
+use util::{codeberg, github, http::HttpClient};
use crate::Oid;
@@ -59,7 +59,7 @@ impl HostingProvider {
pub fn supports_avatars(&self) -> bool {
match self {
- HostingProvider::Github => true,
+ HostingProvider::Github | HostingProvider::Codeberg => true,
_ => false,
}
}
@@ -71,24 +71,27 @@ impl HostingProvider {
commit: Oid,
client: Arc,
) -> Result