Skip to content

Instantly share code, notes, and snippets.

Created September 24, 2014 04:16
Show Gist options
  • Save anonymous/a6b10d78e32fc32ccb5d to your computer and use it in GitHub Desktop.
Save anonymous/a6b10d78e32fc32ccb5d to your computer and use it in GitHub Desktop.
List what patches you have to review in gerrit
#!/usr/bin/env ruby
require 'net/ssh'
require 'json'
users = %w(user)
host = localhost
Net::SSH.start(host, ENV['USER'] , port: 29418) do |ssh|
result = ssh.exec!('gerrit ls-projects --type code --format json')
data = JSON.parse(result)
projects = data.keys
projects.each do |project|
puts "For the #{project} project"
users.each do |user|
result = ssh.exec!("gerrit query --format=JSON -- -owner:#{user} status:open -reviewer:#{user} project:#{project} -is:draft")
data = JSON.parse("[#{result.lines.to_a.join(',')}]")
count = data[-1]['rowCount']
puts " #{user} has #{count} patchs to review" if count > 0
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment