2024-05-28 12:54:01 +03:00
|
|
|
use crate::error::Error;
|
|
|
|
use gitbutler_core::{projects::ProjectId, remotes::Controller};
|
|
|
|
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> {
|
|
|
|
handle
|
|
|
|
.state::<Controller>()
|
2024-05-29 10:52:03 +03:00
|
|
|
.remotes(project_id)
|
2024-05-28 12:54:01 +03:00
|
|
|
.await
|
|
|
|
.map_err(Into::into)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[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> {
|
|
|
|
handle
|
|
|
|
.state::<Controller>()
|
2024-05-29 10:52:03 +03:00
|
|
|
.add_remote(project_id, name, url)
|
2024-05-28 12:54:01 +03:00
|
|
|
.await
|
|
|
|
.map_err(Into::into)
|
|
|
|
}
|