Skip to content

Commit

Permalink
Generate a .gitignore with buck2 init --git
Browse files Browse the repository at this point in the history
This creates a gitignore that will ignore the default output directory.

Fixes facebook#140
  • Loading branch information
steveklabnik committed Apr 11, 2023
1 parent 5fc648f commit b3e1be4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/buck2_client/src/commands/init.rs
Expand Up @@ -210,6 +210,17 @@ fn set_up_prelude(path: &Path, git: bool) -> anyhow::Result<()> {
Ok(())
}

fn set_up_gitignore(path: &Path) -> anyhow::Result<()> {
let mut gitignore = std::fs::File::create(path.join(".gitignore"))?;

writeln!(
gitignore,
"buck-out",
)?;

Ok(())
}

fn set_up_project(path: &Path, git: bool, prelude: bool) -> anyhow::Result<()> {
if git {
if !Command::new("git")
Expand All @@ -220,6 +231,8 @@ fn set_up_project(path: &Path, git: bool, prelude: bool) -> anyhow::Result<()> {
{
return Err(anyhow::anyhow!("Failure when running `git init`."));
};

set_up_gitignore(path)?;
}

if prelude {
Expand Down

0 comments on commit b3e1be4

Please sign in to comment.