blob: 252ed60d2e8be40a80a03c34e8f9f9f01c084678 [file] [log] [blame]
Mohammed Naser7f6414c2025-02-17 16:02:00 -05001use crate::RepositoryClient;
2use async_trait::async_trait;
3use gitea_sdk::Auth;
4use gitea_sdk::Client as GiteaClient;
5use std::error::Error;
6
7pub struct Client {
8 client: GiteaClient,
9}
10
11impl Client {
12 pub fn new() -> Self {
13 Client {
14 client: GiteaClient::new("https://opendev.org", Auth::None::<String>),
15 }
16 }
17}
18
19#[async_trait]
20impl RepositoryClient for Client {
21 async fn get_latest_commit(
22 &self,
23 repository: &crate::repository::Repository,
24 branch: &str,
25 ) -> Result<String, Box<dyn Error>> {
26 let branch_info = self
27 .client
28 .repos(repository.owner.clone(), repository.name.clone())
29 .get_branch(branch)
30 .send(&self.client)
31 .await?;
32
33 Ok(branch_info.commit.id)
34 }
35}