(
state: State<'_, AppState>,
startup_trace: State<'_, DesktopStartupTrace>,
request: GitRepositoryRequest,
)
| 597 | |
| 598 | #[tauri::command] |
| 599 | pub async fn git_get_repository_basic( |
| 600 | state: State<'_, AppState>, |
| 601 | startup_trace: State<'_, DesktopStartupTrace>, |
| 602 | request: GitRepositoryRequest, |
| 603 | ) -> Result<GitRepository, String> { |
| 604 | let trace_started = Instant::now(); |
| 605 | let result = async { |
| 606 | if let Some(target) = resolve_remote_git_target(&request.repository_path).await { |
| 607 | let current_branch = execute_remote_git_success( |
| 608 | &state, |
| 609 | &target, |
| 610 | &["branch".to_string(), "--show-current".to_string()], |
| 611 | ) |
| 612 | .await |
| 613 | .map(|s| { |
| 614 | let branch = s.trim(); |
| 615 | if branch.is_empty() { |
| 616 | "HEAD".to_string() |
| 617 | } else { |
| 618 | branch.to_string() |
| 619 | } |
| 620 | })?; |
| 621 | |
| 622 | let name = target |
| 623 | .repository_path |
| 624 | .rsplit('/') |
| 625 | .find(|part| !part.is_empty()) |
| 626 | .unwrap_or("/") |
| 627 | .to_string(); |
| 628 | |
| 629 | Ok(GitRepository { |
| 630 | path: target.repository_path, |
| 631 | name, |
| 632 | current_branch, |
| 633 | is_bare: false, |
| 634 | has_changes: false, |
| 635 | remotes: Vec::new(), |
| 636 | }) |
| 637 | } else { |
| 638 | GitService::get_repository_basic(&request.repository_path) |
| 639 | .await |
| 640 | .map_err(|e| { |
| 641 | error!( |
| 642 | "Failed to get basic Git repository info: path={}, error={}", |
| 643 | request.repository_path, e |
| 644 | ); |
| 645 | format!("Failed to get basic Git repository info: {}", e) |
| 646 | }) |
| 647 | } |
| 648 | } |
| 649 | .await; |
| 650 | |
| 651 | startup_trace.record_tauri_command_elapsed("git_get_repository_basic", None, trace_started); |
| 652 | result |
| 653 | } |
| 654 | |
| 655 | #[tauri::command] |
| 656 | pub async fn git_get_status( |
nothing calls this directly
no test coverage detected