(
client: &reqwest::blocking::Client,
url: &str,
)
| 241 | } |
| 242 | |
| 243 | fn github_api_request( |
| 244 | client: &reqwest::blocking::Client, |
| 245 | url: &str, |
| 246 | ) -> reqwest::blocking::RequestBuilder { |
| 247 | let request = client |
| 248 | .get(url) |
| 249 | .header(reqwest::header::ACCEPT, "application/vnd.github+json") |
| 250 | .header("X-GitHub-Api-Version", "2022-11-28"); |
| 251 | |
| 252 | // Authenticated requests use the user's 5000 req/h quota instead of the |
| 253 | // shared unauthenticated 60 req/h per-IP bucket, which other tools on the |
| 254 | // same machine or NAT can exhaust and cause spurious 403s on update |
| 255 | // checks. Falls back to unauthenticated when no token is available. |
| 256 | if let Some(token) = jcode_base::github::github_public_api_token() { |
| 257 | request.bearer_auth(token) |
| 258 | } else { |
| 259 | request |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | fn latest_main_sha_blocking() -> Result<String> { |
| 264 | let url = format!("https://api.github.com/repos/{}/commits/main", GITHUB_REPO); |
no test coverage detected