Q7CHNDXNVJCBL2DK7LYZ6KSRFN4KO6TXKEP3GIWDJHB6JPSE3FUQC
/// Create and populate an initial `.ignore` file for the repository.
/// The default elements are defined in the constant [`DEFAULT_IGNORE`].
fn init_dot_ignore(base_path: std::path::PathBuf) -> Result<(), anyhow::Error> {
use std::io::Write;
let dot_ignore_path = {
let mut base = base_path.clone();
base.push(".ignore");
base
};
let mut dot_ignore = std::fs::OpenOptions::new()
.read(true)
.write(true)
.create(true)
.open(dot_ignore_path)?;
for default_ignore in DEFAULT_IGNORE {
dot_ignore.write(default_ignore)?;
dot_ignore.write(b"\n")?;
}
Ok(())
}