Skip to content

Commit

Permalink
Make get_modules recursive
Browse files Browse the repository at this point in the history
  • Loading branch information
gmpinder committed Jan 30, 2024
1 parent f6d513d commit 9b892fc
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/commands/bug_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ fn generate_github_issue(
) -> anyhow::Result<String> {
let recipe = recipe
.as_ref()
.map_or_else(|| "No recipe provided".into(), |r| print_full_recipe(r));
.map_or_else(Default::default, |r| print_full_recipe(r));

let github_template = GithubIssueTemplate::builder()
.bb_version(shadow::PKG_VERSION)
Expand Down Expand Up @@ -411,16 +411,21 @@ fn get_module_from_file(file_name: &str) -> ModuleExt {
)
}

fn print_full_recipe(recipe: &Recipe) -> String {
let mut module_list: Vec<Module> = vec![];
fn get_modules(modules: &[Module]) -> Vec<Module> {
modules
.iter()
.flat_map(|module| {
if let Some(file_name) = &module.from_file {
get_modules(&get_module_from_file(file_name).modules)
} else {
vec![module.clone()]
}
})
.collect()
}

recipe.modules_ext.modules.iter().for_each(|module| {
if let Some(file_name) = &module.from_file {
module_list.extend(get_module_from_file(file_name).modules);
} else {
module_list.push(module.clone());
}
});
fn print_full_recipe(recipe: &Recipe) -> String {
let module_list: Vec<Module> = get_modules(&recipe.modules_ext.modules);

let recipe = Recipe::builder()
.name(recipe.name.as_ref())
Expand Down

0 comments on commit 9b892fc

Please sign in to comment.