-
-
Save jonico/f002e0ae5cb37ad2019242b02b7b15fb to your computer and use it in GitHub Desktop.
ghe-console -y <<'ENDSCRIPT' | |
ActiveRecord::Base.connected_to(role: :reading) do | |
puts "Version 0.2.0" | |
emails = Set.new | |
start_time = 90.days.ago.beginning_of_day | |
Repository.where(active: true).find_each do |repo| | |
Push | |
.where(repository: repo) | |
.where("created_at >= ?", start_time) | |
.find_each do |push| | |
push.commits_pushed.each do |commit| | |
commit.author_emails.each do |email| | |
emails << email unless UserEmail.belongs_to_a_bot?(email) | |
end | |
end | |
end | |
end | |
users = Set.new | |
emails.each_slice(1000) do |batch| | |
emails_to_users_hash = User.find_by_emails(batch) | |
active_users = emails_to_users_hash.values.select do |user| | |
!(user.disabled? || user.suspended?) | |
end | |
users.merge(active_users) | |
end | |
puts "Committers in the past 90d: #{users.size}" | |
end | |
ENDSCRIPT |
@stoe: have you tested your change? For some reason, the above script did not work any more once I used shortlog
@stoe: I would love to have a solution where the output is just the e-mail address (neither name nor count), so that we can deduplicate based on e-mail later - could you do that for me ❤️ ?
I can look into it, @jonico
@stoe: I changed the logic to get closer to the actual GHAS license check in GitHub Enterprise Server
I changed the logic to get closer to the actual GHAS license check in GitHub Enterprise Server
ghe-console
script looks promising, but Ruby-fu is not strong enough to really say if this works.
What could be cool is to wrap that into the way we use in out toolbox: https://github.com/github/services-toolbox/tree/master/scripts/ghes-v2
This script is now outdated - we've made improvements (and continue to do so) as customer issues have come up
I've been keeping this comment up to date as we've made changes
Edit: I have permissions to edit so I updated it too
I also just created a script from this one that gets the committers from specific orgs based off of organization_id. I would love to do it based off of org name but couldn't figure out how.
[REDACTED] - please don't use
https://github.com/github/code-scanning/issues/2537 is trying to solve that, Simon is working on it now
Trying to be really careful how code is distributed - seeing lots of stale / adapted versions of this script around and ideally there's one source of truth so we can keep it updated and consistent and fix issues for all customers
@cbraynor great! let me know when its done and then I can put the official ones to use in the SE repo (or a link to the official ones)!
good
Count all the unique committers in the last 90 days on GitHub Enterprise Server, I could count them on the fingers of one hand
@jonico, what's your thought on changing L6 to
git --git-dir=#{path} shortlog -sne --all --since "90 days ago" >> /tmp/committers
Example from this Gist:
https://git-scm.com/docs/git-shortlog