Skip to main content

git_side/commands/
info.rs

1use colored::Colorize;
2
3use crate::error::Result;
4use crate::side_repo::SideRepo;
5use crate::tracked::TrackedPaths;
6
7/// Show info about git-side.
8///
9/// # Errors
10///
11/// Returns an error if the side repo cannot be opened.
12pub fn run() -> Result<()> {
13    println!("{}", "git-side".bold());
14    println!("Version: {}", env!("CARGO_PKG_VERSION"));
15    println!();
16    println!("A Git subcommand that versions files and directories that");
17    println!("should not live in the main repo, using a per-project bare repo.");
18    println!();
19    println!("{}", "Author:".cyan());
20    println!("  MiPnamic <mipnamic@mipnamic.net>");
21    println!("  https://github.com/MiPnamic");
22    println!();
23    println!("{}", "Project:".cyan());
24    println!("  https://github.com/Solexma/git-side");
25    println!("  MIT License - Solexma LLC");
26    println!();
27
28    // Show project-specific info if in a git repo
29    if let Ok(repo) = SideRepo::open() {
30        println!("{}", "Current project:".cyan());
31        println!("  Root SHA: {}", repo.root_sha);
32        println!("  Side repo: {}", repo.git_dir.display());
33        println!("  Initialized: {}", if repo.is_initialized() { "yes".green() } else { "no".yellow() });
34
35        if repo.is_initialized() {
36            if let Ok(tracked) = TrackedPaths::load(&repo) {
37                let paths: Vec<_> = tracked.paths().iter().collect();
38                if paths.is_empty() {
39                    println!("  Tracked paths: {}", "none".yellow());
40                } else {
41                    println!("  Tracked paths:");
42                    for path in paths {
43                        println!("    - {}", path.display());
44                    }
45                }
46            }
47        }
48    }
49
50    Ok(())
51}