2024-07-08 16:33:26 +03:00
|
|
|
use gitbutler_project as projects;
|
|
|
|
use gitbutler_project::ProjectId;
|
2024-07-08 11:58:16 +03:00
|
|
|
use gitbutler_repo::RepoCommands;
|
2024-07-14 17:12:25 +03:00
|
|
|
use tauri::State;
|
2024-05-28 12:54:01 +03:00
|
|
|
use tracing::instrument;
|
|
|
|
|
2024-07-28 21:48:13 +03:00
|
|
|
use crate::error::Error;
|
|
|
|
|
2024-05-28 12:54:01 +03:00
|
|
|
#[tauri::command(async)]
|
2024-07-14 17:12:25 +03:00
|
|
|
#[instrument(skip(projects), err(Debug))]
|
2024-07-28 21:36:55 +03:00
|
|
|
pub fn list_remotes(
|
2024-07-14 17:12:25 +03:00
|
|
|
projects: State<'_, projects::Controller>,
|
2024-05-28 12:54:01 +03:00
|
|
|
project_id: ProjectId,
|
|
|
|
) -> Result<Vec<String>, Error> {
|
2024-07-14 17:12:25 +03:00
|
|
|
let project = projects.get(project_id)?;
|
2024-07-08 11:58:16 +03:00
|
|
|
project.remotes().map_err(Into::into)
|
2024-05-28 12:54:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[tauri::command(async)]
|
2024-07-14 17:12:25 +03:00
|
|
|
#[instrument(skip(projects), err(Debug))]
|
2024-07-28 21:36:55 +03:00
|
|
|
pub fn add_remote(
|
2024-07-14 17:12:25 +03:00
|
|
|
projects: State<'_, projects::Controller>,
|
2024-05-28 12:54:01 +03:00
|
|
|
project_id: ProjectId,
|
|
|
|
name: &str,
|
|
|
|
url: &str,
|
|
|
|
) -> Result<(), Error> {
|
2024-07-14 17:12:25 +03:00
|
|
|
let project = projects.get(project_id)?;
|
2024-07-08 11:58:16 +03:00
|
|
|
project.add_remote(name, url).map_err(Into::into)
|
2024-05-28 12:54:01 +03:00
|
|
|
}
|