#![allow(dead_code)]
pub mod context;
pub mod github;
pub mod pr_open;
pub mod remote_comments;
pub mod selector;
pub mod submit;
pub mod traits;
use std::path::Path;
use git2::Repository;
use crate::forge::github::gh::parse_github_remote_url;
use crate::forge::traits::ForgeRepository;
pub fn detect_github_repository(repo_root: &Path) -> Option<ForgeRepository> {
let repo = Repository::discover(repo_root).ok()?;
if let Ok(remote) = repo.find_remote("origin")
&& let Some(url) = remote.url()
&& let Some(parsed) = parse_github_remote_url(url)
{
return Some(parsed);
}
let remotes = repo.remotes().ok()?;
for name in remotes.iter().flatten() {
if let Ok(remote) = repo.find_remote(name)
&& let Some(url) = remote.url()
&& let Some(parsed) = parse_github_remote_url(url)
{
return Some(parsed);
}
}
None
}