Currently only the roles of 'author' and 'signer' and handler, but now there's also 'reviewer' and 'acker'. Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx> --- contrib/related/git-related | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/contrib/related/git-related b/contrib/related/git-related index e8603be..cf6818e 100755 --- a/contrib/related/git-related +++ b/contrib/related/git-related @@ -27,6 +27,12 @@ rescue OptionParser::InvalidOption => e $rev_args += e.args end +KNOWN_ROLES = { + 'Signed-off' => :signer, + 'Reviewed' => :reviewer, + 'Acked' => :acker, +} + class Commit attr_reader :id, :roles @@ -38,25 +44,28 @@ class Commit def parse(data) author = msg = nil - roles = {} + # hash of arrays + roles = Hash.new { |hash, key| hash[key] = [] } data.each_line do |line| if not msg case line when /^author ([^<>]+) <(\S+)> (.+)$/ author = $1, $2 - roles[author] = :author + roles[author] << :author when /^$/ msg = true end else - if line =~ /^(Signed-off|Reviewed|Acked)-by: ([^<>]+) <(\S+?)>$/ + role_regex = KNOWN_ROLES.keys.join('|') + if line =~ /^(#{role_regex})-by: ([^<>]+) <(\S+?)>$/ person = $2, $3 - roles[person] = :signer if person != author + role = KNOWN_ROLES[$1] + roles[person] << role if person != author end end end - @roles = roles.map do |person, role| - [person, role] + @roles = roles.map do |person, roles| + [person, roles] end end @@ -195,9 +204,11 @@ end persons = Hash.new { |hash, key| hash[key] = {} } commits.items.values.each do |commit| - commit.roles.each do |person, role| - persons[person][role] ||= 0 - persons[person][role] += 1 + commit.roles.each do |person, roles| + roles.each do |role| + persons[person][role] ||= 0 + persons[person][role] += 1 + end end end -- 1.8.2.1 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html