mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-08-17 00:00:31 +03:00
move author to core
This commit is contained in:
parent
7627a41c89
commit
41f28383a0
@ -1,6 +1,6 @@
|
||||
use futures::future::join_all;
|
||||
|
||||
use crate::{Author, VirtualBranch, VirtualBranchCommit};
|
||||
use crate::{VirtualBranch, VirtualBranchCommit};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Proxy {
|
||||
@ -35,22 +35,12 @@ impl Proxy {
|
||||
}
|
||||
}
|
||||
|
||||
async fn proxy_author(&self, author: Author) -> Author {
|
||||
Author {
|
||||
gravatar_url: self.core_proxy.proxy(&author.gravatar_url).await.unwrap_or_else(|error| {
|
||||
tracing::error!(gravatar_url = %author.gravatar_url, ?error, "failed to proxy gravatar url");
|
||||
author.gravatar_url
|
||||
}),
|
||||
..author
|
||||
}
|
||||
}
|
||||
|
||||
async fn proxy_virtual_branch_commit(
|
||||
&self,
|
||||
commit: VirtualBranchCommit,
|
||||
) -> VirtualBranchCommit {
|
||||
VirtualBranchCommit {
|
||||
author: self.proxy_author(commit.author).await,
|
||||
author: self.core_proxy.proxy_author(commit.author).await,
|
||||
..commit
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ use std::os::unix::prelude::PermissionsExt;
|
||||
use std::time::SystemTime;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
hash::Hash,
|
||||
path::{Path, PathBuf},
|
||||
time, vec,
|
||||
};
|
||||
@ -15,6 +14,7 @@ use diffy::{apply_bytes as diffy_apply, Line, Patch};
|
||||
use git2::build::TreeUpdateBuilder;
|
||||
use git2::ErrorCode;
|
||||
use git2_hooks::HookResult;
|
||||
use gitbutler_core::virtual_branches::Author;
|
||||
use hex::ToHex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@ -195,33 +195,6 @@ impl VirtualBranchHunk {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Hash, Clone, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Author {
|
||||
pub name: String,
|
||||
pub email: String,
|
||||
pub gravatar_url: url::Url,
|
||||
}
|
||||
|
||||
impl From<git2::Signature<'_>> for Author {
|
||||
fn from(value: git2::Signature) -> Self {
|
||||
let name = value.name().unwrap_or_default().to_string();
|
||||
let email = value.email().unwrap_or_default().to_string();
|
||||
|
||||
let gravatar_url = url::Url::parse(&format!(
|
||||
"https://www.gravatar.com/avatar/{:x}?s=100&r=g&d=retro",
|
||||
md5::compute(email.to_lowercase())
|
||||
))
|
||||
.unwrap();
|
||||
|
||||
Author {
|
||||
name,
|
||||
email,
|
||||
gravatar_url,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase", tag = "type", content = "value")]
|
||||
pub enum NameConflitResolution {
|
||||
|
@ -52,7 +52,7 @@ impl Proxy {
|
||||
}
|
||||
}
|
||||
|
||||
async fn proxy_author(&self, author: Author) -> Author {
|
||||
pub async fn proxy_author(&self, author: Author) -> Author {
|
||||
Author {
|
||||
gravatar_url: self.proxy(&author.gravatar_url).await.unwrap_or_else(|error| {
|
||||
tracing::error!(gravatar_url = %author.gravatar_url, ?error, "failed to proxy gravatar url");
|
||||
|
28
crates/gitbutler-core/src/virtual_branches/author.rs
Normal file
28
crates/gitbutler-core/src/virtual_branches/author.rs
Normal file
@ -0,0 +1,28 @@
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Serialize, Hash, Clone, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Author {
|
||||
pub name: String,
|
||||
pub email: String,
|
||||
pub gravatar_url: url::Url,
|
||||
}
|
||||
|
||||
impl From<git2::Signature<'_>> for Author {
|
||||
fn from(value: git2::Signature) -> Self {
|
||||
let name = value.name().unwrap_or_default().to_string();
|
||||
let email = value.email().unwrap_or_default().to_string();
|
||||
|
||||
let gravatar_url = url::Url::parse(&format!(
|
||||
"https://www.gravatar.com/avatar/{:x}?s=100&r=g&d=retro",
|
||||
md5::compute(email.to_lowercase())
|
||||
))
|
||||
.unwrap();
|
||||
|
||||
Author {
|
||||
name,
|
||||
email,
|
||||
gravatar_url,
|
||||
}
|
||||
}
|
||||
}
|
@ -20,3 +20,6 @@ pub use remote::*;
|
||||
mod state;
|
||||
pub use state::VirtualBranches as VirtualBranchesState;
|
||||
pub use state::VirtualBranchesHandle;
|
||||
|
||||
mod author;
|
||||
pub use author::Author;
|
||||
|
Loading…
Reference in New Issue
Block a user