mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-27 10:26:29 +00:00
Redact Git credentials from pyproject.toml (#6074)
## Summary We retain them if you use `--raw-sources`, but otherwise they're removed. We still respect them in the subsequent `uv.lock` via an in-process store. Closes #6056.
This commit is contained in:
parent
92263108cc
commit
8fac63d4ce
10 changed files with 301 additions and 23 deletions
21
crates/uv-git/src/credentials.rs
Normal file
21
crates/uv-git/src/credentials.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
use std::collections::HashMap;
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
use cache_key::RepositoryUrl;
|
||||
use uv_auth::Credentials;
|
||||
|
||||
/// A store for Git credentials.
|
||||
#[derive(Debug, Default)]
|
||||
pub struct GitStore(RwLock<HashMap<RepositoryUrl, Arc<Credentials>>>);
|
||||
|
||||
impl GitStore {
|
||||
/// Insert [`Credentials`] for the given URL into the store.
|
||||
pub fn insert(&self, url: RepositoryUrl, credentials: Credentials) -> Option<Arc<Credentials>> {
|
||||
self.0.write().unwrap().insert(url, Arc::new(credentials))
|
||||
}
|
||||
|
||||
/// Get the [`Credentials`] for the given URL, if they exist.
|
||||
pub fn get(&self, url: &RepositoryUrl) -> Option<Arc<Credentials>> {
|
||||
self.0.read().unwrap().get(url).cloned()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue