Skip to main content

assign_hunk_groups

Function assign_hunk_groups 

Source
pub fn assign_hunk_groups(
    commit_diffs: &[CommitDiff],
    commit_oid: &str,
) -> Option<(usize, HashMap<String, Vec<usize>>)>
Expand description

Compute the fragmap-based hunk group assignment for commit commit_oid.

Uses the same SPG clustering and deduplication as build_fragmap with deduplicate = true. Each hunk of commit_oid in commit_diffs is assigned to the deduplicated fragmap cluster (column) it belongs to.

Returns Some((group_count, assignment)) where:

  • group_count = number of distinct groups after deduplication
  • assignment[path][h] = 0-based group index for hunk h of file path in the commit being split (indexed the same way as the 0-context full diff produced by [GitRepo::commit_diff_for_fragmap])

Returns None if commit_oid is not found in commit_diffs.