pub async fn fetch_pr_diff(
base_url: &str,
owner: &str,
repo: &str,
pr_number: u64,
token: &str,
) -> Result<DiffResult, RsGuardError>Expand description
Fetches the diff for a GitHub Pull Request.
Sends a GET request to the GitHub API with the application/vnd.github.v3.diff
accept header. Automatically retries on transient failures (429, 5xx, timeouts).
The base_url is validated against an allowlist before any request is made,
preventing Authorization headers from being sent to untrusted hosts.
§Arguments
base_url— GitHub API base URL (e.g."https://api.github.com").owner— Repository owner.repo— Repository name.pr_number— Pull request number.token— GitHub authentication token.
§Errors
Returns RsGuardError::Config if base_url is not allowlisted,
RsGuardError::GitHubApi on HTTP errors,
RsGuardError::EmptyDiff if the diff is empty,
RsGuardError::InvalidDiffContent if the response is not a valid diff,
or RsGuardError::DiffTooLarge if the diff exceeds size limits.