Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add specific directories to .gitignore #2880

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
davidmelendez marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Forge

#### Added
davidmelendez marked this conversation as resolved.
Show resolved Hide resolved

- `snforge new` now adds the `snfoundry_trace`, `coverage`, and `profile` directories to `.gitignore`.

## [0.37.0] - 2025-02-03

### Forge
Expand Down
3 changes: 3 additions & 0 deletions crates/forge/src/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ fn extend_gitignore(path: &Path) -> Result<()> {
.append(true)
.open(path.join(".gitignore"))?;
writeln!(file, ".snfoundry_cache/")?;
writeln!(file, "snfoundry_trace/")?;
writeln!(file, "coverage/")?;
writeln!(file, "profile/")?;
}
Ok(())
}
Expand Down
29 changes: 29 additions & 0 deletions crates/forge/tests/e2e/running.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1163,3 +1163,32 @@ fn call_nonexistent_selector() {
"},
);
}

#[test]
fn create_new_project_and_check_gitignore() {
let temp = tempdir_with_tool_versions().unwrap();
let project_path = temp.join("project");

runner(&temp)
.args(["new", "--name", "test_name"])
.arg(&project_path)
.assert()
.success();

let gitignore_path = project_path.join(".gitignore");
assert!(gitignore_path.exists(), ".gitignore file should exist");

let gitignore_content = fs::read_to_string(gitignore_path).unwrap();

let expected_gitignore_content = indoc! {
r"
target
.snfoundry_cache/
snfoundry_trace/
coverage/
profile/
"
};

assert_eq!(gitignore_content, expected_gitignore_content);
}
Loading