Skip to main content

detect_remote

Function detect_remote 

Source
pub fn detect_remote() -> Option<RepoSplit>
Expand description

Detect the repository from the current directory’s git remote.

Opens the git repository by discovering from the current directory, finds the origin remote (or the first available remote), and parses its URL to extract the owner and repository name.

Supports both HTTPS URLs (https://github.com/owner/repo.git) and SSH URLs (git@github.com:owner/repo.git).

Returns None if no git repository is found, no remote is configured, or the remote URL cannot be parsed as a GitHub repository.

§Examples

use gor::repository::detect_remote;

// This will return None if not in a git repo with a GitHub remote
let result = detect_remote();