Include version and contact information in GitHub User Agent (#10785)

## Summary

See: https://github.com/astral-sh/uv/pull/10765#discussion_r1922016112
This commit is contained in:
Charlie Marsh 2025-01-20 14:30:04 -05:00 committed by GitHub
parent 5ee4cf6ff5
commit 25982929c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 13 additions and 4 deletions

View file

@ -16,6 +16,7 @@ use url::Url;
use uv_fs::Simplified;
use uv_static::EnvVars;
use uv_version::version;
use crate::sha::GitOid;
use crate::{GitHubRepository, GitSha};
@ -782,7 +783,10 @@ fn github_fast_path(
debug!("Attempting GitHub fast path for: {url}");
let mut request = client.get(&url);
request = request.header("Accept", "application/vnd.github.3.sha");
request = request.header("User-Agent", "uv");
request = request.header(
"User-Agent",
format!("uv/{} (+https://github.com/astral-sh/uv)", version()),
);
if let Some(local_object) = local_object {
request = request.header("If-None-Match", local_object.to_string());
}