wtg_cli/
remote.rs

1use crossterm::style::Stylize;
2
3/// Check git remote status and print snarky messages
4pub fn check_remote_and_snark(remote_info: Option<(String, String)>, repo_path: &std::path::Path) {
5    match remote_info {
6        Some((_owner, _repo)) => {
7            // We have GitHub! All good
8        }
9        None => {
10            // Check if there's any remote at all
11            if let Ok(repo) = git2::Repository::open(repo_path)
12                && let Ok(remotes) = repo.remotes()
13            {
14                if remotes.is_empty() {
15                    println!(
16                        "{}",
17                        "🤐 No remotes configured - what are you hiding?"
18                            .yellow()
19                            .italic()
20                    );
21                    println!(
22                        "{}",
23                        "   (Or maybe... go do some OSS? 👀)".yellow().italic()
24                    );
25                    println!();
26                } else {
27                    // Has remotes but not GitHub
28                    for remote_name in remotes.iter().flatten() {
29                        if let Ok(remote) = repo.find_remote(remote_name)
30                            && let Some(url) = remote.url()
31                        {
32                            if url.contains("gitlab") {
33                                println!(
34                                            "{}",
35                                            "💸 Ooh, GitLab? Too cheap for GitHub? I get it, Microsoft wants all your money."
36                                                .yellow()
37                                                .italic()
38                                        );
39                            } else if url.contains("bitbucket") {
40                                println!(
41                                            "{}",
42                                            "💸 Bitbucket, eh? Too cheap for GitHub? I get it, Microsoft wants all your money."
43                                                .yellow()
44                                                .italic()
45                                        );
46                            } else if !url.contains("github") {
47                                println!(
48                                            "{}",
49                                            "💸 Non-GitHub remote? Too cheap for GitHub? I get it, Microsoft wants all your money."
50                                                .yellow()
51                                                .italic()
52                                        );
53                            }
54
55                            println!(
56                                        "{}",
57                                        "   (I can only do GitHub API stuff, but let me show you local git info...)"
58                                            .yellow()
59                                            .italic()
60                                    );
61                            println!();
62                            break;
63                        }
64                    }
65                }
66            }
67        }
68    }
69}