Skip to content

Commit

Permalink
Add gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb authored and charliermarsh committed May 27, 2024
1 parent 353fb24 commit 8f2c59b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
14 changes: 13 additions & 1 deletion crates/uv-interpreter/src/managed/find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use core::fmt;
use fs_err as fs;
use std::collections::BTreeSet;
use std::ffi::OsStr;
use std::io;
use std::io::{self, Write};
use std::path::{Path, PathBuf};
use std::str::FromStr;

Expand Down Expand Up @@ -37,6 +37,7 @@ impl InstalledToolchains {
}
}

/// Create a temporary installed toolchain directory.
pub fn temp() -> Result<Self, io::Error> {
Self::from_path(StateStore::temp()?.bucket(StateBucket::Toolchains))
}
Expand All @@ -50,6 +51,17 @@ impl InstalledToolchains {
// Create the cache directory, if it doesn't exist.
fs::create_dir_all(root)?;

// Add a .gitignore.
match fs::OpenOptions::new()
.write(true)
.create_new(true)
.open(root.join(".gitignore"))
{
Ok(mut file) => file.write_all(b"*")?,
Err(err) if err.kind() == io::ErrorKind::AlreadyExists => (),
Err(err) => return Err(err),
}

Ok(self)
}

Expand Down
13 changes: 12 additions & 1 deletion crates/uv-state/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::{
io::{self},
io::{self, Write},
path::{Path, PathBuf},
sync::Arc,
};
Expand Down Expand Up @@ -52,6 +52,17 @@ impl StateStore {
// Create the state store directory, if it doesn't exist.
fs::create_dir_all(root)?;

// Add a .gitignore.
match fs::OpenOptions::new()
.write(true)
.create_new(true)
.open(root.join(".gitignore"))
{
Ok(mut file) => file.write_all(b"*")?,
Err(err) if err.kind() == io::ErrorKind::AlreadyExists => (),
Err(err) => return Err(err),
}

Ok(Self {
root: fs::canonicalize(root)?,
..self
Expand Down

0 comments on commit 8f2c59b

Please sign in to comment.