Class: CodeOwnership::Private::OwnerAssigner

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/code_ownership/private/owner_assigner.rb

Class Method Summary collapse

Class Method Details

.assign_owners(globs_to_owning_team_map) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/code_ownership/private/owner_assigner.rb', line 10

def self.assign_owners(globs_to_owning_team_map)
  globs_to_owning_team_map.each_with_object({}) do |(glob, owner), mapping|
    # addresses the case where a directory name includes regex characters
    # such as `app/services/[test]/some_other_file.ts`
    mapping[glob] = owner if File.exist?(glob)
    Dir.glob(glob).each do |file|
      mapping[file] ||= owner
    end
  end
end