Module: Commiti::ChangeGrouping

Defined in:
lib/services/git/commit/change_grouping.rb

Constant Summary collapse

NOISE_DIRECTORIES =
%w[lib spec test app src docs].freeze

Class Method Summary collapse

Class Method Details

.group(line_chunks) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/services/git/commit/change_grouping.rb', line 7

def self.group(line_chunks)
  paths = line_chunks.map { |chunk| chunk[:path].to_s.strip }.reject(&:empty?).uniq
  return [] if paths.empty?

  components = connected_components(paths)
  components.map.with_index(1) do |component, index|
    {
      id: index,
      files: component,
      chunks: line_chunks.select { |chunk| component.include?(chunk[:path]) }
    }
  end
end