Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show percent of external maintainers, include students. #78

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 10 additions & 3 deletions bin/commands/maintainers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -16,22 +17,28 @@ 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|
puts "#{bucket}: #{logins.size} (#{logins.map(&:to_s).join(', ')})"
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"
repos.maintained[:students]&.sort_by(&:name)&.each do |repo|
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]}"
Expand Down
2 changes: 1 addition & 1 deletion lib/github/contributors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
elsif GitHub::Data.contractors.include?(username.to_s)
:contractors
elsif GitHub::Data.students.include?(username.to_s)
:students
:external # :students

Check warning on line 26 in lib/github/contributors.rb

View check run for this annotation

Codecov / codecov/patch

lib/github/contributors.rb#L26

Added line #L26 was not covered by tests
elsif GitHub::Data.external_users.include?(username.to_s)
:external
elsif GitHub::Data.bots.include?(username.to_s)
Expand Down
6 changes: 6 additions & 0 deletions lib/github/maintainers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
end
end

def external_unique_percent
return 0 unless unique_count

Check warning on line 20 in lib/github/maintainers.rb

View check run for this annotation

Codecov / codecov/patch

lib/github/maintainers.rb#L20

Added line #L20 was not covered by tests

((external_unique_count.to_f / unique_count) * 100).to_i

Check warning on line 22 in lib/github/maintainers.rb

View check run for this annotation

Codecov / codecov/patch

lib/github/maintainers.rb#L22

Added line #L22 was not covered by tests
end

def unique_count
buckets.values.map(&:size).sum
end
Expand Down
Loading