pub struct GitHubPermalink {
pub owner: String,
pub repo: String,
pub git_ref: String,
pub path: String,
pub line_range: Option<LineRange>,
}Expand description
A parsed GitHub permalink.
Fields§
§owner: StringRepository owner.
repo: StringRepository name.
git_ref: StringGit ref (commit SHA or branch/tag name).
path: StringFile path within the repository.
line_range: Option<LineRange>Optional line range specification.
Implementations§
Source§impl GitHubPermalink
impl GitHubPermalink
Sourcepub fn parse_all(text: &str) -> Vec<GitHubPermalink>
pub fn parse_all(text: &str) -> Vec<GitHubPermalink>
Parses all GitHub permalink URLs from the given text.
Matches URLs with commit SHAs, branch names, or tag names.
The shared link policy applies (see super::parse_links): angle-bracket
wrapped and duplicate URLs are ignored, and at most 3 links are returned.
Sourcepub async fn fetch(
&self,
http_client: &Client,
) -> Result<ExpandedContent, ExpandError>
pub async fn fetch( &self, http_client: &Client, ) -> Result<ExpandedContent, ExpandError>
Fetches the raw file content from GitHub and returns a code block.
Sourcefn read_limit(&self, max_lines: usize) -> ReadLimit
fn read_limit(&self, max_lines: usize) -> ReadLimit
How much of the body Self::build_code_block can consume.
When max_lines caps the display, truncate_lines tells “exactly at the
limit” apart from “truncated” by whether a further line exists. The start of
that line is enough to make it exist, so it is probed rather than read in full.
Sourcefn build_code_block(&self, body: &str, max_lines: usize) -> ExpandedContent
fn build_code_block(&self, body: &str, max_lines: usize) -> ExpandedContent
Builds an ExpandedContent::CodeBlock from raw file content.
With a line range, body starts at the range’s first line: the lines before
it are skipped while reading (see ReadLimit::skip_lines).