Skip to content

Commit

Permalink
Return early to reduce nesting
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSandro2000 committed Aug 16, 2024
1 parent 64c6be1 commit fdb9600
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,23 @@ fn find_values_yaml(workspace: String, base: &str, head: &str) -> Result<Vec<Rep
continue;
}

let new_image_refs = ImageRefs::parse(&repo, &new_file)?;

let old_file = diff_delta.old_file();
if old_file.exists() {
let old_image_refs = ImageRefs::parse(&repo, &old_file)?;

for (name, image) in &new_image_refs.container_images {
for source in &image.sources {
changes.push(RepoChangeset {
name: name.clone(),
remote: util::Remote::parse(&source.repo)?,
// TODO: iterate over sources
base_commit: old_image_refs.container_images[name].sources[0].commit.clone(),
head_commit: source.commit.clone(),
changes: Vec::new(),
});
}
if !old_file.exists() {
continue;
}

let new_image_refs = ImageRefs::parse(&repo, &new_file)?;
let old_image_refs = ImageRefs::parse(&repo, &old_file)?;
for (name, image) in &new_image_refs.container_images {
for source in &image.sources {
changes.push(RepoChangeset {
name: name.clone(),
remote: util::Remote::parse(&source.repo)?,
// TODO: iterate over sources
base_commit: old_image_refs.container_images[name].sources[0].commit.clone(),
head_commit: source.commit.clone(),
changes: Vec::new(),
});
}
}
}
Expand Down

0 comments on commit fdb9600

Please sign in to comment.