|
1 | 1 | pub mod commands { |
2 | | - use anyhow::{Context, Result}; |
| 2 | + use anyhow::Result; |
3 | 3 | use gitbutler_branch_actions::RemoteBranchFile; |
4 | 4 | use gitbutler_project as projects; |
5 | 5 | use gitbutler_project::ProjectId; |
6 | 6 | use gitbutler_repo::RepoCommands; |
7 | | - use gix::progress::Discard; |
8 | 7 | use std::path::Path; |
9 | 8 | use std::sync::atomic::AtomicBool; |
10 | 9 | use tauri::State; |
11 | 10 | use tracing::instrument; |
12 | 11 |
|
13 | | - use crate::error::Error; |
| 12 | + use crate::error::{Error, UnmarkedError}; |
14 | 13 |
|
15 | 14 | #[tauri::command(async)] |
16 | 15 | #[instrument(skip(projects), err(Debug))] |
@@ -46,19 +45,16 @@ pub mod commands { |
46 | 45 | } |
47 | 46 |
|
48 | 47 | #[tauri::command(async)] |
49 | | - pub fn git_clone_repository(repository_url: &str, target_dir: &Path) -> Result<(), Error> { |
50 | | - let url = |
51 | | - gix::url::parse(repository_url.into()).context("Failed to parse repository URL")?; |
| 48 | + pub fn git_clone_repository( |
| 49 | + repository_url: &str, |
| 50 | + target_dir: &Path, |
| 51 | + ) -> Result<(), UnmarkedError> { |
52 | 52 | let should_interrupt = AtomicBool::new(false); |
53 | | - let mut prepared_clone = |
54 | | - gix::prepare_clone(url, target_dir).context("Failed to prepare clone")?; |
55 | | - let (mut prepared_checkout, _) = prepared_clone |
56 | | - .fetch_then_checkout(Discard, &should_interrupt) |
57 | | - .context("Failed to fetch")?; |
58 | | - let should_interrupt = AtomicBool::new(false); |
59 | | - prepared_checkout |
60 | | - .main_worktree(Discard, &should_interrupt) |
61 | | - .context("Failed to checkout main worktree")?; |
| 53 | + |
| 54 | + gix::prepare_clone(repository_url, target_dir)? |
| 55 | + .fetch_then_checkout(gix::progress::Discard, &should_interrupt) |
| 56 | + .map(|(checkout, _outcome)| checkout)? |
| 57 | + .main_worktree(gix::progress::Discard, &should_interrupt)?; |
62 | 58 | Ok(()) |
63 | 59 | } |
64 | 60 |
|
|
0 commit comments