sheriff-bot should know who the gardeners/sheriffs are

https://bugs.webkit.org/show_bug.cgi?id=105698

Patch by Alan Cutter <alancutter@chromium.org> on 2013-01-01
Reviewed by Eric Seidel.

Added a "sheriffs" command to sheriffbot to fetch the current Chromium Webkit sheriffs.

* Scripts/webkitpy/tool/bot/irc_command.py:
(Current):
(Current._retrieve_webkit_sheriffs):
(Current.execute):
* Scripts/webkitpy/tool/bot/irc_command_unittest.py:
(IRCCommandTest.test_current):
* Scripts/webkitpy/tool/bot/testdata/webkit_sheriff_0.js: Added.
* Scripts/webkitpy/tool/bot/testdata/webkit_sheriff_1.js: Added.
* Scripts/webkitpy/tool/bot/testdata/webkit_sheriff_2.js: Added.
* Scripts/webkitpy/tool/bot/testdata/webkit_sheriff_malformed.js: Added.
* Scripts/webkitpy/tool/bot/testdata/webkit_sheriff_zero.js: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@138603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent acace98f
2013-01-01 Alan Cutter <alancutter@chromium.org>
sheriff-bot should know who the gardeners/sheriffs are
https://bugs.webkit.org/show_bug.cgi?id=105698
Reviewed by Eric Seidel.
Added a "sheriffs" command to sheriffbot to fetch the current Chromium Webkit sheriffs.
* Scripts/webkitpy/tool/bot/irc_command.py:
(Current):
(Current._retrieve_webkit_sheriffs):
(Current.execute):
* Scripts/webkitpy/tool/bot/irc_command_unittest.py:
(IRCCommandTest.test_current):
* Scripts/webkitpy/tool/bot/testdata/webkit_sheriff_0.js: Added.
* Scripts/webkitpy/tool/bot/testdata/webkit_sheriff_1.js: Added.
* Scripts/webkitpy/tool/bot/testdata/webkit_sheriff_2.js: Added.
* Scripts/webkitpy/tool/bot/testdata/webkit_sheriff_malformed.js: Added.
* Scripts/webkitpy/tool/bot/testdata/webkit_sheriff_zero.js: Added.
2012-12-31 Carlos Garcia Campos <cgarcia@igalia.com>
[GTK] Move ImageDiff to the Tools directory root
......
......@@ -56,6 +56,8 @@ direct_attachment_url = r"https?://bug-(?P<bug_id>\d+)-attachments.%s/attachment
buildbot_url = "http://build.webkit.org"
chromium_buildbot_url = "http://build.chromium.org/p/chromium.webkit"
chromium_webkit_sheriff_url = "http://build.chromium.org/p/chromium.webkit/sheriff_webkit.js"
omahaproxy_url = "http://omahaproxy.appspot.com/"
def parse_bug_id(string):
......
......@@ -33,6 +33,7 @@ import re
from webkitpy.common.config import irc as config_irc
from webkitpy.common.config import urls
from webkitpy.common.config.committers import CommitterList
from webkitpy.common.net.web import Web
from webkitpy.common.system.executive import ScriptError
from webkitpy.tool.bot.queueengine import TerminateQueue
from webkitpy.tool.grammar import join_with_separators
......@@ -140,6 +141,41 @@ class Rollout(IRCCommand):
_post_error_and_check_for_bug_url(tool, nicks_string, e)
class Sheriffs(IRCCommand):
def _retrieve_webkit_sheriffs(self, url):
try:
sheriff_js = Web().get_binary(url, True)
except:
return None
if sheriff_js == None:
return None
match = re.search(r"document.write\('(.*)'\)", sheriff_js)
try:
return match.group(1)
except:
return None
def execute(self, nick, args, tool, sheriff):
if not args:
url = urls.chromium_webkit_sheriff_url
else:
url = args[0]
sheriffs = self._retrieve_webkit_sheriffs(url)
if sheriffs == None:
return "%s: Failed to parse URL: %s" % (nick, url)
sheriff_name = "Chromium Webkit sheriff"
sheriff_count = len(sheriffs.split())
if sheriff_count == 0:
return "%s: There are no %ss currently assigned." % (nick, sheriff_name)
if sheriff_count == 1:
return "%s: The current %s is: %s" % (nick, sheriff_name, sheriffs)
return "%s: The current %ss are: %s" % (nick, sheriff_name, sheriffs)
class RollChromiumDEPS(IRCCommand):
def _parse_args(self, args):
if not args:
......@@ -237,6 +273,7 @@ visible_commands = {
"hi": Hi,
"restart": Restart,
"rollout": Rollout,
"sheriffs": Sheriffs,
"whois": Whois,
"create-bug": CreateBug,
"roll-chromium-deps": RollChromiumDEPS,
......
......@@ -26,6 +26,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import os
import unittest
from webkitpy.common.system.outputcapture import OutputCapture
......@@ -58,6 +59,23 @@ class IRCCommandTest(unittest.TestCase):
self.assertEqual('tom: More than 5 contributors match \'david\', could you be more specific?',
whois.execute("tom", ["david"], None, None))
@staticmethod
def _sheriff_test_data_url(suffix):
return "file://" + os.path.abspath("./webkitpy/tool/bot/testdata/webkit_sheriff_%s.js" % suffix)
def test_sheriffs(self):
sheriffs = Sheriffs()
self.assertEqual("tom: There are no Chromium Webkit sheriffs currently assigned.",
sheriffs.execute("tom", [self._sheriff_test_data_url("0")], None, None))
self.assertEqual("tom: The current Chromium Webkit sheriff is: test_user",
sheriffs.execute("tom", [self._sheriff_test_data_url("1")], None, None))
self.assertEqual("tom: The current Chromium Webkit sheriffs are: test_user_1, test_user_2",
sheriffs.execute("tom", [self._sheriff_test_data_url("2")], None, None))
self.assertEqual("tom: Failed to parse URL: " + self._sheriff_test_data_url("malformed"),
sheriffs.execute("tom", [self._sheriff_test_data_url("malformed")], None, None))
self.assertEqual("tom: Failed to parse URL: http://invalid/",
sheriffs.execute("tom", ["http://invalid/"], None, None))
def test_create_bug(self):
create_bug = CreateBug()
self.assertEqual("tom: Usage: create-bug BUG_TITLE",
......
document.write('test_user_1, test_user_2');
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment