Gentoo Archives: gentoo-commits

From: "Robin H. Johnson" <robbat2@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/rbot-bugzilla:master commit in: /
Date: Tue, 28 Feb 2012 06:31:00
Message-Id: 1330410629.4c864f9a89d3ea597aefb505e4887ae9f536e9a7.robbat2@gentoo
1 commit: 4c864f9a89d3ea597aefb505e4887ae9f536e9a7
2 Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
3 AuthorDate: Tue Feb 28 06:29:55 2012 +0000
4 Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
5 CommitDate: Tue Feb 28 06:30:29 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/rbot-bugzilla.git;a=commit;h=4c864f9a
7
8 Support 'bug X comment Y' and 'bug X#cY' as commands and detection in text.
9
10 ---
11 bugzilla.rb | 68 +++++++++++++++++++++++++++++++++++++---------------------
12 1 files changed, 43 insertions(+), 25 deletions(-)
13
14 diff --git a/bugzilla.rb b/bugzilla.rb
15 index d428ddb..13f19fe 100644
16 --- a/bugzilla.rb
17 +++ b/bugzilla.rb
18 @@ -389,7 +389,7 @@ class BugzillaPlugin < Plugin
19 'STATUS' => status,
20 'REPORTER' => reporter,
21 'ASSIGNEE' => assignee,
22 - 'URL' => showbugurl.gsub('@BUGNO@', bugno).gsub('@COMMENT@', comment),
23 + 'URL' => showbugurl.gsub('@BUGNO@', bugno).gsub('@COMMENT@', comment.length > 0 ? '#c'+comment : '' ),
24 }
25 output = template.dup
26 mapping.each { |k,v|
27 @@ -533,10 +533,11 @@ class BugzillaPlugin < Plugin
28 def listen(m)
29 return if m.address?
30 return unless lurk?(m)
31 - return if m.message !~ /\bbug(?:[[:space:]]*)?#?([0-9]+)(#c[0-9]+)?/i
32 + return if m.message !~ /\bbug(?:[[:space:]]*)?#?([0-9]+)(?:(?:#c| comment #?)([0-9]+))?/i
33 bugno = $1
34 comment = $2 || ""
35 bugno.gsub!(/^#/,'')
36 + comment.gsub!(/^#c?/,'')
37 zilla = get_zilla(m)
38 m.reply zilla.summary(bugno, comment)
39 end
40 @@ -560,14 +561,19 @@ class BugzillaPlugin < Plugin
41 # Answer to a bug information request, long form.
42 def buglong(m, params)
43 begin
44 - if params[:number].chomp("#") =~ /#?([0-9]+)(#c[0-9]+)?/i
45 - bugno = $1
46 - comment = $2 || ""
47 - bugno.gsub!(/^#/,'')
48 - else
49 - m.reply "Wrong parameters - invalid bugnumber, see 'help bug' for help."
50 - return
51 - end
52 + comment = ""
53 + if params[:garbage] == 'comment' and params[:comment] =~ /^(?:#|#c)?([0-9]+)$/
54 + comment = $1
55 + end
56 + if params[:number].chomp("#") =~ /#?([0-9]+)(?:(?:#c|comment #?)([0-9]+))?/i
57 + bugno = $1
58 + comment = $2 if $2
59 + bugno.gsub!(/^#/,'')
60 + else
61 + m.reply "Wrong parameters - invalid bugnumber, see 'help bug' for help."
62 + return
63 + end
64 + comment.gsub!(/^#c?/,'')
65
66 if params[:zilla] and bugno
67 check_zilla(params[:zilla])
68 @@ -585,17 +591,23 @@ class BugzillaPlugin < Plugin
69 # Answer to a bug information request, short form.
70 def bug(m, params)
71 begin
72 - if params[:number].chomp("#") =~ /#?([0-9]+)(#c[0-9]+)?/i
73 - bugno = $1
74 - comment = $2 ? $2 : ""
75 - bugno.gsub!(/^#/,'')
76 - else
77 - m.reply "Wrong parameters - invalid bugnumber, see 'help bug' for help."
78 - return
79 - end
80 + comment = ""
81 + if params[:garbage] == 'comment' and params[:comment] =~ /^(?:#|#c)?([0-9]+)$/
82 + comment = $1
83 + end
84 + if params[:number].chomp("#") =~ /#?([0-9]+)(?:(?:#c|comment #?)([0-9]+))?/i
85 + bugno = $1
86 + comment = $2 if $2
87 + bugno.gsub!(/^#/,'')
88 + else
89 + m.reply "Wrong parameters - invalid bugnumber, see 'help bug' for help."
90 + return
91 + end
92 + comment.gsub!(/^#c?/,'')
93 +
94 zilla = get_zilla(m)
95
96 - if not zilla
97 + if not zilla
98 m.reply "Wrong parameters - unknown zilla, see 'help bug' for help."
99 end
100 m.reply zilla.summary(bugno, comment)
101 @@ -1035,19 +1047,25 @@ plugin = BugzillaPlugin.new
102 plugin.default_auth( 'modify', false )
103 plugin.default_auth( 'view', true )
104
105 -plugin.map 'bug :number',
106 +plugin.map 'bug :number :garbage :comment',
107 :requirements => {
108 :number => /^[^ ]+$/,
109 + :garbage => /^[^ ]+$/,
110 + :comment => /^[^ ]+$/,
111 },
112 + :defaults => { :garbage => "", :comment => "" },
113 :action => 'bug',
114 :thread => 'yes',
115 :auth_path => 'view'
116
117 -plugin.map 'bugl :zilla :number',
118 +plugin.map 'bugl :zilla :number :garbage :comment',
119 :requirements => {
120 :number => /^[^ ]+$/,
121 - :zilla => /^[^ ]+$/
122 + :zilla => /^[^ ]+$/,
123 + :garbage => /^[^ ]+$/,
124 + :comment => /^[^ ]+$/,
125 },
126 + :defaults => { :garbage => "", :comment => "" },
127 :action => 'buglong',
128 :thread => 'yes',
129 :auth_path => 'view'
130 @@ -1082,7 +1100,7 @@ plugin.map 'zilla instance add :zilla :baseurl',
131 :action => 'instance_add',
132 :requirements => {
133 :zilla => /^[^ ]+$/,
134 - :baseurl => /^https?:\/\/.*/
135 + :baseurl => /^https?:\/\/.*/,
136 },
137 :auth_path => 'modify'
138
139 @@ -1090,7 +1108,7 @@ plugin.map 'zilla instance set :zilla :setting :value',
140 :action => 'instance_set',
141 :requirements => {
142 :zilla => /^[^\. ]+$/,
143 - :setting => OPTIONS_INPUT_1
144 + :setting => OPTIONS_INPUT_1,
145 },
146 :auth_path => 'modify'
147
148 @@ -1109,7 +1127,7 @@ plugin.map 'zilla instance show :zilla :full',
149 :action => 'instance_show',
150 :requirements => {
151 :zilla => /^[^ ]+$/,
152 - :full => /^full|registry$/
153 + :full => /^full|registry$/,
154 },
155 :defaults => { :full => "registry" },
156 :auth_path => 'view'