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

fix(init): don't gitignore triple-dash #1289

Merged
merged 1 commit into from
Apr 26, 2024
Merged
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
9 changes: 4 additions & 5 deletions cmd/soroban-cli/src/commands/contract/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,14 +422,14 @@ fn append_contents(from: &Path, to: &Path) -> Result<(), Error> {

fn get_merged_file_delimiter(file_path: &Path) -> String {
let comment = if file_path.to_string_lossy().contains("README.md") {
"[//]: # \"The following is the Frontend Template's README.md\"".to_string()
"---\n<!-- The following is the Frontend Template's README.md -->".to_string()
} else if file_path.to_string_lossy().contains("gitignore") {
"# The following is from the Frontend Template's .gitignore".to_string()
} else {
String::new()
};

format!("\n\n---\n\n{comment}\n\n").to_string()
format!("\n\n{comment}\n\n").to_string()
chadoh marked this conversation as resolved.
Show resolved Hide resolved
}

#[cfg(test)]
Expand Down Expand Up @@ -691,13 +691,12 @@ mod tests {
let readme_path = project_dir.join("README.md");
let readme_str = read_to_string(readme_path).unwrap();
assert!(readme_str.contains("Soroban Frontend in Astro"));
let expected = "[//]: # \"The following is the Frontend Template's README.md\"";
let expected = "The following is the Frontend Template's README.md";
assert!(readme_str.contains(expected));

let readme_path = project_dir.join("README.md");
let readme_str = read_to_string(readme_path).unwrap();
let readme_frontend_merge_delimiter =
"[//]: # \"The following is the Frontend Template's README.md\"";
let readme_frontend_merge_delimiter = "The following is the Frontend Template's README.md";
let count = readme_str.matches(readme_frontend_merge_delimiter).count();
// making sure it is in there just once so that it isn't duplicated if `contract init` is run again
assert!(count == 1);
Expand Down
Loading