Skip to content

Commit

Permalink
Fix bug in patch_series_unique_branch_names
Browse files Browse the repository at this point in the history
Fix bug in patch_series_unique_branch_names where it was unwraping a
value that wasn't safe to unwrap all the time.

So I switched the containing map to a filter_map and got rid of the
unwrap.

<!-- ps-id: a65f6d5d-6188-47bd-b5af-6a9a4b149acc -->
  • Loading branch information
drewdeponte committed Oct 19, 2023
1 parent 555a2b9 commit 12a1ff1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ pub fn patch_range_within_stack_bounds(
/// Get a vec of all the unique branch names associated with specified patch series
pub fn patch_series_unique_branch_names(
repo: &git2::Repository,
stack_patches: &Vec<ListPatch>,
stack_patches: &[ListPatch],
patch_info_collection: &HashMap<Uuid, state_computation::PatchGitInfo>,
start_patch_index: usize,
end_patch_index: Option<usize>,
Expand All @@ -473,9 +473,9 @@ pub fn patch_series_unique_branch_names(
let mut range_patch_branches: Vec<String> = indexes_iter
.clone()
.map(|i| stack_patches.get(i).unwrap())
.map(|lp| {
.filter_map(|lp| {
let commit = repo.find_commit(lp.oid).unwrap();
commit_ps_id(&commit).unwrap()
commit_ps_id(&commit)
})
.filter_map(|id| patch_info_collection.get(&id))
.flat_map(|pi| pi.branches.iter().map(|b| b.name.clone()))
Expand Down

0 comments on commit 12a1ff1

Please sign in to comment.