mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-01 12:26:02 +03:00
Tweaks to remotes code
This commit is contained in:
parent
aed23f3e69
commit
c5d841a417
@ -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 {
|
||||
|
@ -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)?)
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user