use std::path::{Path, PathBuf};
#[derive(Debug, Clone)]
pub struct Worktree {
pub path: PathBuf,
pub branch: Option<String>,
#[allow(dead_code)]
pub is_main: bool,
}
#[derive(Debug, Clone)]
pub struct Repo {
pub name: String,
pub path: PathBuf,
pub worktrees: Vec<Worktree>,
pub session_name: String,
}
impl Repo {
pub fn tmux_session_name(&self, worktree_path: &Path) -> String {
if worktree_path == self.path {
self.session_name.replace('.', "_")
} else {
worktree_path
.file_name()
.unwrap_or_default()
.to_string_lossy()
.replacen(&self.name, &self.session_name, 1)
.replace('.', "_")
}
}
}