From 7e184848974952cd7c2f33d9b80ab246dbdbbe68 Mon Sep 17 00:00:00 2001 From: konstin Date: Tue, 1 Oct 2024 14:19:34 +0200 Subject: [PATCH] Add gitignore to dist directory The build artifacts in `dist` are not meant to be checked in, so we're adding a gitignore to this directory, like `.venv`. --- crates/uv/src/commands/build.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/uv/src/commands/build.rs b/crates/uv/src/commands/build.rs index 9e4e08e13c72e..e4a8ae04b606e 100644 --- a/crates/uv/src/commands/build.rs +++ b/crates/uv/src/commands/build.rs @@ -1,5 +1,7 @@ use std::borrow::Cow; -use std::fmt::Write; +use std::fmt::Write as _; +use std::io; +use std::io::Write as _; use std::path::{Path, PathBuf}; use anyhow::Result; @@ -483,6 +485,17 @@ async fn build_package( // Create the output directory. fs_err::tokio::create_dir_all(&output_dir).await?; + // Add a .gitignore. + match fs_err::OpenOptions::new() + .write(true) + .create_new(true) + .open(output_dir.join(".gitignore")) + { + Ok(mut file) => file.write_all(b"*")?, + Err(err) if err.kind() == io::ErrorKind::AlreadyExists => (), + Err(err) => return Err(err.into()), + } + // Determine the build plan. let plan = match &source.source { Source::File(_) => {