Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
elizabethengelman committed Mar 8, 2024
1 parent cf0a3ad commit a347e67
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions cmd/soroban-cli/src/commands/contract/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ fn append_contents(from: &Path, to: &Path) -> Result<(), Error> {
let mut to_content = String::new();
to_file.read_to_string(&mut to_content)?;

let delimiter = get_merged_file_delimiter(to)?;
let delimiter = get_merged_file_delimiter(to);
// if the to file already contains the delimiter, we don't need to append the contents again
if to_content.contains(&delimiter) {
return Ok(());
Expand All @@ -454,16 +454,16 @@ fn append_contents(from: &Path, to: &Path) -> Result<(), Error> {
Ok(())
}

fn get_merged_file_delimiter(file_path: &Path) -> Result<String, 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()
} else if file_path.to_string_lossy().contains("gitignore") {
"# The following is from the Frontend Template's .gitignore".to_string()
} else {
"".to_string()
String::new()
};

Ok(format!("\n\n---\n\n{comment}\n\n").to_string())
format!("\n\n---\n\n{comment}\n\n").to_string()
}

#[cfg(test)]
Expand Down Expand Up @@ -578,7 +578,6 @@ mod tests {
temp_dir.close().unwrap();
}


#[test]
fn test_init_from_within_an_existing_project() {
let temp_dir = tempfile::tempdir().unwrap();
Expand Down Expand Up @@ -616,15 +615,15 @@ mod tests {
let with_examples = vec![];
init(
project_dir.as_path(),
&"https://github.com/AhaLabs/soroban-astro-template".to_string(),
"https://github.com/AhaLabs/soroban-astro-template",
&with_examples,
)
.unwrap();

// call init again to make sure the README.md's contents are not duplicated
init(
project_dir.as_path(),
&"https://github.com/AhaLabs/soroban-astro-template".to_string(),
"https://github.com/AhaLabs/soroban-astro-template",
&with_examples,
)
.unwrap();
Expand Down Expand Up @@ -731,7 +730,6 @@ mod tests {

let readme_path = project_dir.join("README.md");
let readme_str = read_to_string(readme_path).unwrap();
println!("readme_str: {}", readme_str);
let readme_frontend_merge_delimiter =
"[//]: # \"The following is the Frontend Template's README.md\"";
let count = readme_str.matches(readme_frontend_merge_delimiter).count();
Expand Down

0 comments on commit a347e67

Please sign in to comment.