[DRE-commits] [pkg-ruby-extras] 01/01: Import find-inactive-contributors

zeha at debian.org zeha at debian.org
Wed Jun 29 20:04:53 UTC 2016


This is an automated email from the git hooks/post-receive script.

zeha pushed a commit to branch master
in repository pkg-ruby-extras.

commit 50ed1dcac4d26d0007e2f4ec3f9acfdd1aa02bda
Author: Christian Hofstaedtler <christian at hofstaedtler.name>
Date:   Wed Jun 29 22:04:48 2016 +0200

    Import find-inactive-contributors
---
 find-inactive-contributors | 90 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 90 insertions(+)

diff --git a/find-inactive-contributors b/find-inactive-contributors
new file mode 100755
index 0000000..16b4982
--- /dev/null
+++ b/find-inactive-contributors
@@ -0,0 +1,90 @@
+#!/usr/bin/env ruby
+
+# find possibly inactive contributors in pkg-ruby-extras team, by
+# looking at the file ownership for git object files.
+# requires all possible contributors to be part of the unix group
+# named GROUP.
+#
+# NOTE: MUST be run on alioth.debian.org.
+
+require 'json'
+require 'etc'
+require 'time'
+
+GROUP = 'pkg-ruby-extras'
+ROOT = "/srv/git.debian.org/git/#{GROUP}"
+DATAFILE = 'findinactive.data'
+TIME_ZERO = Time.at(0)
+DAYS_INACTIVE = 365 * 2
+
+def walk_git(dirname, newest)
+  puts "Walking #{dirname}"
+  Dir.glob("#{dirname}/objects/*").each do |objdir|
+    Dir.foreach(objdir) do |filename|
+      next if filename.start_with?('.')
+      path = "#{objdir}/#{filename}"
+      stat = File.stat(path)
+      newest[stat.uid] = stat.mtime if stat.mtime > newest[stat.uid]
+#      puts "#{path} #{stat.uid} #{stat.mtime}"
+#      puts "#{newest.inspect}"
+    end
+  end
+end
+
+def build_uid_map
+  uid_map = Hash.new
+  all_users = Etc.getgrnam(GROUP).mem
+  all_users.each do |username|
+    u = Etc.getpwnam(username).uid
+    uid_map[u] = username
+  end
+  uid_map
+end
+
+def build_data
+  data = {
+    :users => build_uid_map,
+    :newest => Hash.new(TIME_ZERO),
+  }
+  repos = Dir.glob(ROOT + '/*.git')
+  #repos = [repos[0]]  # limit work for now
+  repos.each do |r| walk_git(r, data[:newest]) end
+  puts "newest => #{data[:newest].inspect}"
+  File.write(DATAFILE, JSON.generate(data))
+end
+
+def print_info
+  puts "NOTE: Data generated by looking at owner and timestamp of git object files."
+  puts "NOTE: As such, it is likely incomplete."
+  data_json = JSON.parse(File.read(DATAFILE))
+  data = {
+    :users => data_json["users"],
+    :newest => data_json["newest"],
+  }
+  puts "email;last_contribution_date"
+  contribs = []
+  data[:users].each do |uid, username|
+    contrib_date = data[:newest][uid]
+    if contrib_date.nil? or contrib_date == TIME_ZERO then
+      puts "#{username}@users.alioth.debian.org;never"
+    else
+      contribs << [Time.parse(contrib_date), username]
+    end
+  end
+  contribs.sort_by! { |c| c[0] }
+  cutoff = (Date.today - DAYS_INACTIVE).to_time
+  contribs.each do |contrib_date, username|
+    if contrib_date < cutoff then
+      puts "#{username}@users.alioth.debian.org;#{contrib_date}"
+    end
+  end
+end
+
+case ARGV[0]
+when 'build'
+  build_data
+when 'info'
+  print_info
+else
+  puts "usage: findinactive.rb build|info"
+end

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/pkg-ruby-extras.git



More information about the Pkg-ruby-extras-commits mailing list