class Bellows::Gerrit
Public Class Methods
comment(revision, message, verify_vote=0)
click to toggle source
# File lib/bellows/gerrit.rb, line 36 def self.comment(revision, message, verify_vote=0) Gerrit.run_cmd(%{review --verified #{verify_vote} -m \"'#{message}'\" #{revision}}) end
reviews(project, status="open", branch="master") { |data| ... }
click to toggle source
# File lib/bellows/gerrit.rb, line 16 def self.reviews(project, status="open", branch="master") # Assume projects without a slash are 'openstack' org projects #if not x =~ /.*\/.*/ then # project = "openstack/#{project}" #end reviews = [] out=Gerrit.run_cmd(%{query status:#{status} project:#{project} branch:#{branch} limit:500 --current-patch-set --format JSON}) out.each_line do |line| data = JSON.parse(line) if data['project'] and data['project'] == "#{project}" and data['branch'] and data['branch'] == branch if block_given? yield data else reviews << data end end end reviews end
run_cmd(command)
click to toggle source
# File lib/bellows/gerrit.rb, line 7 def self.run_cmd(command) return %x{ssh review gerrit #{command}} end
stream_events(type=nil) { |data| ... }
click to toggle source
# File lib/bellows/gerrit.rb, line 40 def self.stream_events(type=nil) PTY.spawn stream_events_cmd do |read, write, pid| loop do begin data = JSON.parse(read.gets) if type.nil? or data['type'] == type then yield data end rescue break end end end end
stream_events_cmd()
click to toggle source
defined here so we can easily stub out for testing
# File lib/bellows/gerrit.rb, line 12 def self.stream_events_cmd return "ssh review gerrit stream-events" end