diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 812fe83..7033e85 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,11 +1,17 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-03-19 16:59:49 UTC using RuboCop version 1.59.0. +# on 2024-03-19 17:56:35 UTC using RuboCop version 1.59.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. +# Offense count: 1 +# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches. +Lint/DuplicateBranch: + Exclude: + - 'lib/github/contributors.rb' + # Offense count: 7 # Configuration parameters: AllowComments, AllowEmptyLambdas. Lint/EmptyBlock: @@ -51,7 +57,7 @@ Lint/UselessAssignment: # Offense count: 1 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 122 + Max: 127 # Offense count: 4 # Configuration parameters: AllowedMethods, AllowedPatterns. diff --git a/README.md b/README.md index 933bc05..2dd1a0d 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,8 @@ Shows maintainer stats. ``` ./bin/project maintainers stats -As of 2023-05-17, 98 repos have 198 maintainers, including 17% (17/98) of repos with at least one of 15 external maintainers. +As of 2024-03-19, 113 repos have 231 maintainers, where 12% (29/231) are external. +A total of 22% (25/113) of repos have at least one of 29 external maintainers. ``` You can pass a date to find out stats for a given point in time. diff --git a/bin/commands/maintainers.rb b/bin/commands/maintainers.rb index c5034d6..2084cd0 100644 --- a/bin/commands/maintainers.rb +++ b/bin/commands/maintainers.rb @@ -4,10 +4,11 @@ module Bin class Commands desc 'Data about repo maintainers.' command 'maintainers' do |g| + g.flag %i[repo], multiple: true, desc: 'Search a specific repo within the org.' + g.desc 'Show MAINTAINERS.md stats.' g.command 'stats' do |c| c.flag %i[date], desc: 'Date at.', default_value: nil - g.flag %i[repo], multiple: true, desc: 'Search a specific repo within the org.' c.action do |_global_options, options, _args| dt = options[:date] ? Chronic.parse(options[:date]).to_date : nil repos = if options[:repo]&.any? @@ -16,7 +17,8 @@ class Commands GitHub::Organization.new(options.merge(org: options['org'] || 'opensearch-project')).repos end maintainers = repos.maintainers(dt) - puts "As of #{dt || Date.today}, #{repos.count} repos have #{maintainers.unique_count} maintainers, including #{repos.external_maintainers_percent}% (#{repos.external_maintained_size}/#{repos.count}) of repos with at least one of #{maintainers.external_unique_count} external maintainers." + puts "As of #{dt || Date.today}, #{repos.count} repos have #{maintainers.unique_count} maintainers, where #{maintainers.external_unique_percent}% (#{maintainers.external_unique_count}/#{maintainers.unique_count}) are external." + puts "A total of #{repos.external_maintainers_percent}% (#{repos.external_maintained_size}/#{repos.count}) of repos have at least one of #{maintainers.external_unique_count} external maintainers." puts "\n# Maintainers\n" puts "unique: #{maintainers.unique_count}" maintainers.each_pair do |bucket, logins| @@ -24,7 +26,7 @@ class Commands end puts "\n# External Maintainers\n" repos.maintained[:external]&.sort_by(&:name)&.each do |repo| - puts "#{repo.html_url}: #{repo.maintainers[:external]}" + puts "#{repo.html_url}: #{repo.maintainers[:external]} (#{repo.maintainers.external_unique_percent}%, #{repo.maintainers.external_unique_count}/#{repo.maintainers.unique_count})" end puts "\n# Student Maintainers\n" @@ -32,6 +34,11 @@ class Commands puts "#{repo.html_url}: #{repo.maintainers[:students]}" end + puts "\n# Contractor Maintainers\n" + repos.maintained[:contractors]&.sort_by(&:name)&.each do |repo| + puts "#{repo.html_url}: #{repo.maintainers[:contractors]}" + end + puts "\n# Unknown Maintainers\n" repos.maintained[:unknown]&.sort_by(&:name)&.each do |repo| puts "#{repo.html_url}: #{repo.maintainers[:unknown]}" diff --git a/lib/github/contributors.rb b/lib/github/contributors.rb index 82c9eb5..0af6aa3 100644 --- a/lib/github/contributors.rb +++ b/lib/github/contributors.rb @@ -23,7 +23,7 @@ def self.bucket(username) elsif GitHub::Data.contractors.include?(username.to_s) :contractors elsif GitHub::Data.students.include?(username.to_s) - :students + :external # :students elsif GitHub::Data.external_users.include?(username.to_s) :external elsif GitHub::Data.bots.include?(username.to_s) diff --git a/lib/github/maintainers.rb b/lib/github/maintainers.rb index f6e2388..b03a0f3 100644 --- a/lib/github/maintainers.rb +++ b/lib/github/maintainers.rb @@ -16,6 +16,12 @@ def buckets end end + def external_unique_percent + return 0 unless unique_count + + ((external_unique_count.to_f / unique_count) * 100).to_i + end + def unique_count buckets.values.map(&:size).sum end