Class: Codeowners::ContributorFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/codeowners/contributor_finder.rb

Defined Under Namespace

Classes: Contributor, ContributorStats

Constant Summary collapse

DEFAULT_MAX_COMMITS =
50

Instance Method Summary collapse

Constructor Details

#initialize(definitions_file: DefinitionsFile.new, max_commits: DEFAULT_MAX_COMMITS) ⇒ ContributorFinder

Returns a new instance of ContributorFinder.



16
17
18
19
20
# File 'lib/codeowners/contributor_finder.rb', line 16

def initialize(definitions_file: DefinitionsFile.new, max_commits: DEFAULT_MAX_COMMITS)
  @definitions_file = definitions_file
  @max_commits = max_commits
  @email_to_username_cache = {}
end

Instance Method Details

#find_contributors(feature:) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/codeowners/contributor_finder.rb', line 22

def find_contributors(feature:)
  file_paths = collect_feature_files(feature)

  return [] if file_paths.empty?

  contributors = analyse_git_history(file_paths)
  contributors.sort_by(&:lines_changed).reverse
end