From 6907045cd794593fb133af7c520996549510fb65 Mon Sep 17 00:00:00 2001 From: Tushar Mathur Date: Wed, 11 Dec 2024 15:11:39 -0800 Subject: [PATCH] fix: resolve conflict remanants --- crates/gh-workflow/src/generate.rs | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/crates/gh-workflow/src/generate.rs b/crates/gh-workflow/src/generate.rs index 4a03695..9402ff0 100644 --- a/crates/gh-workflow/src/generate.rs +++ b/crates/gh-workflow/src/generate.rs @@ -135,25 +135,8 @@ fn organize_job_dependency(mut workflow: Workflow) -> Workflow { workflow } -fn find_job<'a>( - dep_job: &Job, - new_jobs: &'a IndexMap, - workflow: &'a Workflow, -) -> Option<&'a str> { - let in_new_jobs: Option<&'a str> = - new_jobs - .iter() - .find_map(|(k, v)| if v == dep_job { Some(k.as_str()) } else { None }); - - let in_old_jobs: Option<&'a str> = workflow.jobs.as_ref().and_then(|jobs| { - jobs.0.iter().find_map(|(id, j)| { - if j == dep_job { - Some(id.as_str()) - } else { - None - } - }) - }); - - in_new_jobs.or(in_old_jobs) +/// Find a job in the new_jobs or old_jobs +fn find_value<'a, K, V: PartialEq>(job: &V, map: &'a IndexMap) -> Option<&'a K> { + map.iter() + .find_map(|(k, v)| if v == job { Some(k) } else { None }) }