Skip to main content

git_source_url

Function git_source_url 

Source
pub fn git_source_url(
    repo: &str,
    commit: &str,
    root: &Path,
    item_path: &Path,
) -> Option<String>
Expand description

Build the {repo}/blob/{commit}/{rel} URL for a source file.

Returns None if item_path is not under root (i.e. for absolute external paths). commit falls back to "HEAD" when empty (GitHub’s blob/HEAD/... resolves to the repository’s default branch regardless of whether it is main, master, or anything else).

Path components are joined with / so the URL is well-formed on Windows.