Class: Bugzilla::Plugin::RedHat
- Defined in:
- lib/bugzilla/plugins/rhbugzilla.rb
Instance Attribute Summary
Attributes inherited from Template
Instance Method Summary collapse
-
#initialize ⇒ RedHat
constructor
A new instance of RedHat.
-
#parserhook(*args) ⇒ Object
def initialize.
-
#posthook(*args) ⇒ Object
def prehook.
-
#prehook(*args) ⇒ Object
def parserhook.
Methods inherited from Template
Constructor Details
#initialize ⇒ RedHat
Returns a new instance of RedHat.
31 32 33 34 35 |
# File 'lib/bugzilla/plugins/rhbugzilla.rb', line 31 def initialize super @hostname = 'bugzilla.redhat.com' end |
Instance Method Details
#parserhook(*args) ⇒ Object
def initialize
37 38 39 40 41 42 43 |
# File 'lib/bugzilla/plugins/rhbugzilla.rb', line 37 def parserhook(*args) parser, argv, opts, *etc = args parser.separator '' parser.separator 'RH Bugzilla specific options:' parser.on('--cc=EMAILS', 'filter out the result by Cc in bugs') { |v| opts[:query][:cc] ||= []; opts[:query][:cc].push(*v.split(',')) } parser.on('--filterversion=VERSION', 'filter out the result by the version in bugs') { |v| opts[:query][:version] ||= []; opts[:query][:version].push(*v.split(',')) } end |
#posthook(*args) ⇒ Object
def prehook
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/bugzilla/plugins/rhbugzilla.rb', line 159 def posthook(*args) cmd, opts, *etc = args case cmd when :search if opts.include?('bugs') opts['bugs'].each do |bug| if bug.include?('bug_status') bug['status'] = bug['bug_status'] bug.delete('bug_status') end if bug.include?('bug_id') bug['id'] = bug['bug_id'] bug.delete('bug_id') end if bug.include?('bug_severity') bug['severity'] = bug['bug_severity'] bug.delete('bug_severity') end if bug.include?('short_desc') bug['summary'] = bug['short_desc'] bug.delete('short_desc') end end end when :metrics metricsopts = etc[0] if opts.include?('bugs') opts['bugs'].each do |bug| if bug.include?('bug_status') bug['status'] = bug['bug_status'] bug.delete('bug_status') end if bug.include?('bug_id') bug['id'] = bug['bug_id'] bug.delete('bug_id') end if bug.include?('bug_severity') bug['severity'] = bug['bug_severity'] bug.delete('bug_severity') end if bug.include?('short_desc') bug['summary'] = bug['short_desc'] bug.delete('short_desc') end end end end end |
#prehook(*args) ⇒ Object
def parserhook
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/bugzilla/plugins/rhbugzilla.rb', line 45 def prehook(*args) cmd, opts, *etc = args case cmd when :search # This parameter is Red Hat Extension # See https://bugzilla.redhat.com/docs/en/html/api/Bugzilla/WebService/Bug.html#search opts[:query_format] = 'advanced' extra_field = 0 if opts.include?(:status) opts[:bug_status] = opts[:status] opts.delete(:status) end if opts.include?(:id) opts[:bug_id] = opts[:id] opts.delete(:id) end opts[:bug_severity] = opts[:severity] if opts.include?(:severity) if opts.include?(:summary) opts[:short_desc] = opts[:summary] opts.delete(:summary) end if opts.include?(:cc) # CC should be parsed "any words" by default opts[eval(':emailcc1')] = 1 opts[eval(':emailtype1')] = :anywordssubstr opts[eval(':email1')] = opts[:cc] opts.delete(:cc) end if opts.include?(:creation_time) opts[format('field0-%d-0', extra_field)] = :creation_ts opts[format('type0-%d-0', extra_field)] = :greaterthan opts[format('value0-%d-0', extra_field)] = opts[:creation_time] opts.delete(:creation_time) end when :metrics metricsopts = etc[0] extra_field = 0 if opts.include?(:status) opts[:bug_status] = opts[:status] opts.delete(:status) end if opts.include?(:id) opts[:bug_id] = opts[:id] opts.delete(:id) end opts[:bug_severity] = opts[:severity] if opts.include?(:severity) if opts.include?(:summary) opts[:short_desc] = opts[:summary] opts.delete(:summary) end if opts.include?(:cc) i = 1 opts[:cc].each do |e| opts[eval(":emailcc#{i}")] = 1 opts[eval(":emailtype#{i}")] = :substring opts[eval(":email#{i}")] = e end opts.delete(:cc) end if opts.include?(:creation_time) if opts[:creation_time].is_a?(Array) opts[format('field0-%d-0', extra_field)] = :creation_ts opts[format('type0-%d-0', extra_field)] = :greaterthan opts[format('value0-%d-0', extra_field)] = opts[:creation_time][0] extra_field += 1 opts[format('field0-%d-0', extra_field)] = :creation_ts opts[format('type0-%d-0', extra_field)] = :lessthan opts[format('value0-%d-0', extra_field)] = opts[:creation_time][1] extra_field += 1 else opts[format('field0-%d-0', extra_field)] = :creation_ts opts[format('type0-%d-0', extra_field)] = :greaterthan opts[format('value0-%d-0', extra_field)] = opts[:creation_time] extra_field += 1 end opts.delete(:creation_time) end if opts.include?(:last_change_time) if opts[:last_change_time].is_a?(Array) opts[:chfieldfrom] = opts[:last_change_time][0] opts[:chfieldto] = opts[:last_change_time][1] if opts[:bug_status] == 'CLOSED' opts[format('field0-%d-0', extra_field)] = :bug_status opts[format('type0-%d-0', extra_field)] = :changedto opts[format('value0-%d-0', extra_field)] = opts[:bug_status] extra_field += 1 end end opts.delete(:last_change_time) end if opts.include?(:metrics_closed_after) opts[format('field0-%d-0', extra_field)] = :bug_status opts[format('type0-%d-0', extra_field)] = :changedafter opts[format('value0-%d-0', extra_field)] = opts[:metrics_closed_after] extra_field += 1 opts.delete(:metrics_closed_after) end if opts.include?(:metrics_not_closed) opts[format('field0-%d-0', extra_field)] = :bug_status opts[format('type0-%d-0', extra_field)] = :notequals opts[format('value0-%d-0', extra_field)] = 'CLOSED' extra_field += 1 opts[format('field0-%d-0', extra_field)] = :creation_ts opts[format('type0-%d-0', extra_field)] = :lessthan opts[format('value0-%d-0', extra_field)] = opts[:metrics_not_closed] extra_field += 1 opts.delete(:metrics_not_closed) end end end |