Module: FastCodeOwners::TeamFinder
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/fast_code_owners/team_finder.rb
Class Method Summary collapse
- .first_owned_file_for_backtrace(backtrace, excluded_teams: []) ⇒ Object
- .for_backtrace(backtrace, excluded_teams: []) ⇒ Object
- .for_class(klass) ⇒ Object
- .for_file(file_path) ⇒ Object
- .for_package(package) ⇒ Object
Class Method Details
.first_owned_file_for_backtrace(backtrace, excluded_teams: []) ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/fast_code_owners/team_finder.rb', line 54 def first_owned_file_for_backtrace(backtrace, excluded_teams: []) FilePathFinder.from_backtrace(backtrace).each do |file| team = for_file(file) if team && !excluded_teams.include?(team) return [team, file] end end nil end |
.for_backtrace(backtrace, excluded_teams: []) ⇒ Object
49 50 51 |
# File 'lib/fast_code_owners/team_finder.rb', line 49 def for_backtrace(backtrace, excluded_teams: []) first_owned_file_for_backtrace(backtrace, excluded_teams: excluded_teams)&.first end |
.for_class(klass) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/fast_code_owners/team_finder.rb', line 33 def for_class(klass) file_path = FilePathFinder.path_from_klass(klass) return nil if file_path.nil? for_file(file_path) end |
.for_file(file_path) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fast_code_owners/team_finder.rb', line 15 def for_file(file_path) return nil if file_path.start_with?('./') return FilePathTeamCache.get(file_path) if FilePathTeamCache.cached?(file_path) result = T.let(RustCodeOwners.for_file(file_path), T.nilable(T::Hash[Symbol, String])) return if result.nil? if result[:team_name].nil? FilePathTeamCache.set(file_path, nil) else FilePathTeamCache.set(file_path, T.let(find_team!(T.must(result[:team_name])), T.nilable(CodeTeams::Team))) end FilePathTeamCache.get(file_path) end |
.for_package(package) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/fast_code_owners/team_finder.rb', line 41 def for_package(package) owner_name = package.raw_hash['owner'] || package.['owner'] return nil if owner_name.nil? find_team!(owner_name) end |