cascade_cli/cli/commands/
diagnose.rs1use crate::cli::output::Output;
2use crate::errors::Result;
3use crate::git::GitRepository;
4use std::path::Path;
5
6pub async fn run() -> Result<()> {
8 Output::section("Cascade CLI - Git2 Diagnostics");
9
10 let version = git2::Version::get();
12 Output::section("Git2 Feature Support");
13
14 if version.https() {
15 Output::success("HTTPS/TLS support: YES");
16 } else {
17 Output::error("HTTPS/TLS support: NO");
18 }
19
20 if version.ssh() {
21 Output::success("SSH support: YES");
22 } else {
23 Output::error("SSH support: NO");
24 }
25
26 let libgit2_version = version.libgit2_version();
28 Output::sub_item(format!(
29 "libgit2 version: {}.{}.{}",
30 libgit2_version.0, libgit2_version.1, libgit2_version.2
31 ));
32
33 println!();
34
35 if let Ok(repo) = GitRepository::open(Path::new(".")) {
37 Output::section("Current Repository Analysis");
38
39 repo.diagnose_git2_support()?;
41
42 if let Ok(remote_url) = repo.get_remote_url("origin") {
44 Output::section("Remote Configuration");
45 Output::sub_item(format!("Origin URL: {remote_url}"));
46
47 if remote_url.starts_with("https://") {
48 if version.https() {
49 Output::success("HTTPS remote with TLS support - should work!");
50 } else {
51 Output::error("HTTPS remote but NO TLS support - will fallback to git CLI");
52 }
53 } else if remote_url.starts_with("git@") || remote_url.starts_with("ssh://") {
54 if version.ssh() {
55 Output::success("SSH remote with SSH support - should work!");
56 } else {
57 Output::error("SSH remote but NO SSH support - will fallback to git CLI");
58 }
59 }
60 }
61 } else {
62 Output::info("Not in a git repository - skipping repository-specific checks");
63 }
64
65 Output::section("Recommendations");
67
68 if !version.https() || !version.ssh() {
69 Output::error("MISSING FEATURES DETECTED:");
70 Output::sub_item("Your git2 is missing TLS/SSH support.");
71 Output::sub_item("This causes performance issues due to git CLI fallbacks.");
72 println!();
73 Output::tip("TO FIX: Update Cargo.toml git2 dependency:");
74 Output::command_example("git2 = { version = \"0.20.2\", features = [\"vendored-libgit2\", \"https\", \"ssh\"] }");
75 println!();
76 Output::success("BENEFITS: Direct git2 operations (faster, more reliable)");
77 } else {
78 Output::success("git2 has full TLS/SSH support!");
79 Output::sub_item("If you're still experiencing issues, they may be:");
80 Output::bullet("Network connectivity problems");
81 Output::bullet("Authentication/credential issues");
82 Output::bullet("Corporate firewall/proxy settings");
83 Output::bullet("SSL certificate verification problems");
84 }
85
86 Ok(())
87}