get_github_repo

Function get_github_repo 

Source
pub fn get_github_repo(cwd: &Path) -> Option<String>
Expand description

Get the GitHub repository from git remote origin.

Uses direct file system access for speed (~30µs vs ~1344µs with libgit2). Reads the git config file and parses the origin remote URL.

Returns None if:

  • The directory is not a git repository
  • No origin remote is configured
  • The origin remote is not a GitHub URL

§Supported URL formats

  • SSH: git@github.com:owner/repo.git
  • HTTPS: https://github.com/owner/repo.git or https://github.com/owner/repo
  • SSH URL: ssh://git@github.com/owner/repo.git

§Example

use std::path::Path;
use mi6_core::context::get_github_repo;

let repo = get_github_repo(Path::new("/path/to/git/repo"));
// Returns Some("owner/repo") if valid GitHub remote