Tweaks to remotes code

This commit is contained in:
Caleb Owens 2024-05-29 09:52:03 +02:00
parent aed23f3e69
commit c5d841a417
3 changed files with 10 additions and 12 deletions

View File

@ -604,13 +604,11 @@ impl Repository {
}
pub fn remotes(&self) -> Result<Vec<String>> {
self.git_repository.remotes().map_err(anyhow::Error::from)
Ok(self.git_repository.remotes()?)
}
pub fn add_remote(&self, name: &str, url: &str) -> Result<()> {
self.git_repository
.add_remote(name, url)
.map_err(anyhow::Error::from)
Ok(self.git_repository.add_remote(name, url)?)
}
pub fn repo(&self) -> &git2::Repository {

View File

@ -14,22 +14,22 @@ impl Controller {
Self { projects }
}
pub async fn remotes(&self, project_id: &ProjectId) -> Result<Vec<String>, Error> {
let project = self.projects.get(project_id)?;
pub async fn remotes(&self, project_id: ProjectId) -> Result<Vec<String>, Error> {
let project = self.projects.get(&project_id)?;
let project_repository = project_repository::Repository::open(&project)?;
project_repository.remotes().map_err(Into::into)
Ok(project_repository.remotes()?)
}
pub async fn add_remote(
&self,
project_id: &ProjectId,
project_id: ProjectId,
name: &str,
url: &str,
) -> Result<(), Error> {
let project = self.projects.get(project_id)?;
let project = self.projects.get(&project_id)?;
let project_repository = project_repository::Repository::open(&project)?;
project_repository.add_remote(name, url).map_err(Into::into)
Ok(project_repository.add_remote(name, url)?)
}
}

View File

@ -11,7 +11,7 @@ pub async fn list_remotes(
) -> Result<Vec<String>, Error> {
handle
.state::<Controller>()
.remotes(&project_id)
.remotes(project_id)
.await
.map_err(Into::into)
}
@ -26,7 +26,7 @@ pub async fn add_remote(
) -> Result<(), Error> {
handle
.state::<Controller>()
.add_remote(&project_id, name, url)
.add_remote(project_id, name, url)
.await
.map_err(Into::into)
}