fix: remove old implementation of forgejo get all branches

This commit is contained in:
Paul Campbell 2024-05-28 06:45:34 +01:00
parent 012668dd0a
commit 9f04b1ae6c
3 changed files with 0 additions and 50 deletions

View file

@ -1,45 +0,0 @@
use git_next_config as config;
use git_next_git as git;
use kxio::network::{self, Network};
pub async fn get_all(
repo_details: &git::RepoDetails,
net: &Network,
) -> git::branch::Result<Vec<config::BranchName>> {
let hostname = &repo_details.forge.hostname();
let repo_path = &repo_details.repo_path;
use secrecy::ExposeSecret;
let token = repo_details.forge.token().expose_secret();
let url = network::NetUrl::new(format!(
"https://{hostname}/api/v1/repos/{repo_path}/branches?token={token}"
));
let request = network::NetRequest::new(
network::RequestMethod::Get,
url,
network::NetRequestHeaders::new(),
network::RequestBody::None,
network::ResponseType::Json,
None,
network::NetRequestLogging::None,
);
let response = net.get::<Vec<Branch>>(request).await?;
let branches = response
.response_body()
.unwrap_or_default()
.into_iter()
.map(config::BranchName::from)
.collect::<Vec<_>>();
Ok(branches)
}
#[derive(Debug, serde::Deserialize)]
struct Branch {
name: String,
}
impl From<Branch> for config::BranchName {
fn from(value: Branch) -> Self {
Self::new(value.name)
}
}

View file

@ -1,3 +0,0 @@
mod get_all;
pub use get_all::get_all;

View file

@ -1,5 +1,3 @@
pub mod branch;
use git_next_git as git; use git_next_git as git;
use kxio::network::{self, Network}; use kxio::network::{self, Network};