2024-05-28 12:54:01 +03:00
|
|
|
use crate::error::Error;
|
2024-07-08 11:58:16 +03:00
|
|
|
use gitbutler_core::projects::{self, ProjectId};
|
|
|
|
use gitbutler_repo::RepoCommands;
|
2024-05-28 12:54:01 +03:00
|
|
|
use tauri::Manager;
|
|
|
|
use tracing::instrument;
|
|
|
|
|
|
|
|
#[tauri::command(async)]
|
|
|
|
#[instrument(skip(handle), err(Debug))]
|
|
|
|
pub async fn list_remotes(
|
|
|
|
handle: tauri::AppHandle,
|
|
|
|
project_id: ProjectId,
|
|
|
|
) -> Result<Vec<String>, Error> {
|
2024-07-08 11:58:16 +03:00
|
|
|
let project = handle.state::<projects::Controller>().get(project_id)?;
|
|
|
|
project.remotes().map_err(Into::into)
|
2024-05-28 12:54:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[tauri::command(async)]
|
|
|
|
#[instrument(skip(handle), err(Debug))]
|
|
|
|
pub async fn add_remote(
|
|
|
|
handle: tauri::AppHandle,
|
|
|
|
project_id: ProjectId,
|
|
|
|
name: &str,
|
|
|
|
url: &str,
|
|
|
|
) -> Result<(), Error> {
|
2024-07-08 11:58:16 +03:00
|
|
|
let project = handle.state::<projects::Controller>().get(project_id)?;
|
|
|
|
project.add_remote(name, url).map_err(Into::into)
|
2024-05-28 12:54:01 +03:00
|
|
|
}
|