Skip to content
Permalink
Browse files
webkitbot should provide full name, email address, and IRC nicknames …
…on whois

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

Reviewed by Benjamin Poulain.

A response like the one below is useless. Improve it:
webkitbot: rniwa: zdobersek is zdobersek (zandobersek@gmail.com). Why do you ask?

We now report full name, email address, committer/reviewer status, and IRC nickname.

Also teach webkitbot how to respond to ping.

* Scripts/webkitpy/tool/bot/irc_command.py:
(PingPong): Moved
(PingPong.execute):
(Whois._full_record_and_nick): Renamed and rewritten.
(Whois.execute):

* Scripts/webkitpy/tool/bot/irc_command_unittest.py:
(IRCCommandTest.test_whois): Updated test cases as needed.

* Scripts/webkitpy/tool/bot/ircbot_unittest.py:
(IRCBotTest.test_help): Added ping.

* Scripts/webkitpy/tool/commands/newcommitbot.py:
(NewCommitBot): Teached WKR how to respond to hi.


Canonical link: https://commits.webkit.org/132952@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@148372 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
rniwa committed Apr 14, 2013
1 parent 4e160f4 commit 4fbc731b735451f26bab72d2599c53e8b9451d02
@@ -1,3 +1,32 @@
2013-04-13 Ryosuke Niwa <rniwa@webkit.org>

webkitbot should provide full name, email address, and IRC nicknames on whois
https://bugs.webkit.org/show_bug.cgi?id=114494

Reviewed by Benjamin Poulain.

A response like the one below is useless. Improve it:
webkitbot: rniwa: zdobersek is zdobersek (zandobersek@gmail.com). Why do you ask?

We now report full name, email address, committer/reviewer status, and IRC nickname.

Also teach webkitbot how to respond to ping.

* Scripts/webkitpy/tool/bot/irc_command.py:
(PingPong): Moved
(PingPong.execute):
(Whois._full_record_and_nick): Renamed and rewritten.
(Whois.execute):

* Scripts/webkitpy/tool/bot/irc_command_unittest.py:
(IRCCommandTest.test_whois): Updated test cases as needed.

* Scripts/webkitpy/tool/bot/ircbot_unittest.py:
(IRCBotTest.test_help): Added ping.

* Scripts/webkitpy/tool/commands/newcommitbot.py:
(NewCommitBot): Teached WKR how to respond to hi.

2013-04-13 Anders Carlsson <andersca@apple.com>

Add form delegate method that's invoked right before sending a submit event to a form element
@@ -121,6 +121,14 @@ def execute(self, nick, args, tool, sheriff):
return random.choice(quips)


class PingPong(IRCCommand):
usage_string = "ping"
help_string = "Responds with pong."

def execute(self, nick, args, tool, sheriff):
return nick + ": pong"


class Restart(IRCCommand):
usage_string = "restart"
help_string = "Restarts sherrifbot. Will update its WebKit checkout, and re-join the channel momentarily."
@@ -247,17 +255,26 @@ class Whois(IRCCommand):
usage_string = "whois SEARCH_STRING"
help_string = "Searches known contributors and returns any matches with irc, email and full name. Wild card * permitted."

def _nick_or_full_record(self, contributor):
def _full_record_and_nick(self, contributor):
result = ''

if contributor.irc_nicknames:
return ', '.join(contributor.irc_nicknames)
return unicode(contributor)
result += ' (:%s)' % ', :'.join(contributor.irc_nicknames)

if contributor.can_review:
result += ' (r)'
elif contributor.can_commit:
result += ' (c)'

return unicode(contributor) + result

def execute(self, nick, args, tool, sheriff):
if not args:
return self.usage(nick)
search_string = " ".join(args)
# FIXME: We should get the ContributorList off the tool somewhere.
contributors = CommitterList().contributors_by_search_string(search_string)
search_string = unicode(search_string)
if not contributors:
return "%s: Sorry, I don't know any contributors matching '%s'." % (nick, search_string)
if len(contributors) > 5:
@@ -266,12 +283,8 @@ def execute(self, nick, args, tool, sheriff):
contributor = contributors[0]
if not contributor.irc_nicknames:
return "%s: %s hasn't told me their nick. Boo hoo :-(" % (nick, contributor)
if contributor.emails and search_string.lower() not in map(lambda email: email.lower(), contributor.emails):
formattedEmails = ', '.join(contributor.emails)
return "%s: %s is %s (%s). Why do you ask?" % (nick, search_string, self._nick_or_full_record(contributor), formattedEmails)
else:
return "%s: %s is %s. Why do you ask?" % (nick, search_string, self._nick_or_full_record(contributor))
contributor_nicks = map(self._nick_or_full_record, contributors)
return "%s: %s is %s. Why do you ask?" % (nick, search_string, self._full_record_and_nick(contributor))
contributor_nicks = map(self._full_record_and_nick, contributors)
contributors_string = join_with_separators(contributor_nicks, only_two_separator=" or ", last_separator=', or ')
return "%s: I'm not sure who you mean? %s could be '%s'." % (nick, contributors_string, search_string)

@@ -281,6 +294,7 @@ def execute(self, nick, args, tool, sheriff):
"create-bug": CreateBug,
"help": Help,
"hi": Hi,
"ping": PingPong,
"restart": Restart,
"roll-chromium-deps": RollChromiumDEPS,
"rollout": Rollout,
@@ -42,21 +42,23 @@ def test_whois(self):
whois = Whois()
self.assertEqual("tom: Usage: whois SEARCH_STRING",
whois.execute("tom", [], None, None))
self.assertEqual("tom: Adam Barth is abarth (abarth@webkit.org). Why do you ask?",
self.assertEqual('tom: Adam Barth is "Adam Barth" <abarth@webkit.org> (:abarth) (r). Why do you ask?',
whois.execute("tom", ["Adam", "Barth"], None, None))
self.assertEqual("tom: Sorry, I don't know any contributors matching 'unknown@example.com'.",
whois.execute("tom", ["unknown@example.com"], None, None))
self.assertEqual("tom: tonyg@chromium.org is tonyg-cr. Why do you ask?",
self.assertEqual('tom: tonyg@chromium.org is "Tony Gentilcore" <tonyg@chromium.org> (:tonyg-cr) (r). Why do you ask?',
whois.execute("tom", ["tonyg@chromium.org"], None, None))
self.assertEqual("tom: TonyG@Chromium.org is tonyg-cr. Why do you ask?",
self.assertEqual('tom: TonyG@Chromium.org is "Tony Gentilcore" <tonyg@chromium.org> (:tonyg-cr) (r). Why do you ask?',
whois.execute("tom", ["TonyG@Chromium.org"], None, None))
self.assertEqual("tom: rniwa is rniwa (rniwa@webkit.org). Why do you ask?",
self.assertEqual('tom: rniwa is "Ryosuke Niwa" <rniwa@webkit.org> (:rniwa) (r). Why do you ask?',
whois.execute("tom", ["rniwa"], None, None))
self.assertEqual("tom: lopez is xan (xan.lopez@gmail.com, xan@gnome.org, xan@webkit.org, xlopez@igalia.com). Why do you ask?",
self.assertEqual('tom: lopez is "Xan Lopez" <xan.lopez@gmail.com> (:xan) (r). Why do you ask?',
whois.execute("tom", ["lopez"], None, None))
self.assertEqual(u'tom: Osztrogon\u00e1c is "Csaba Osztrogon\u00e1c" <ossy@webkit.org> (:ossy) (r). Why do you ask?',
whois.execute("tom", [u'Osztrogon\u00e1c'], None, None))
self.assertEqual('tom: "Vicki Murley" <vicki@apple.com> hasn\'t told me their nick. Boo hoo :-(',
whois.execute("tom", ["vicki@apple.com"], None, None))
self.assertEqual('tom: I\'m not sure who you mean? gavinp or gbarra could be \'Gavin\'.',
self.assertEqual('tom: I\'m not sure who you mean? "Gavin Peters" <gavinp@chromium.org> (:gavinp) (c) or "Gavin Barraclough" <barraclough@apple.com> (:gbarra) (r) could be \'Gavin\'.',
whois.execute("tom", ["Gavin"], None, None))
self.assertEqual('tom: More than 5 contributors match \'david\', could you be more specific?',
whois.execute("tom", ["david"], None, None))
@@ -88,7 +88,7 @@ def test_hi(self):
OutputCapture().assert_outputs(self, run, args=["hi"], expected_logs=expected_logs)

def test_help(self):
expected_logs = 'MOCK: irc.post: mock_nick: Available commands: create-bug, help, hi, restart, roll-chromium-deps, rollout, whois\nMOCK: irc.post: mock_nick: Type "mock-sheriff-bot: help COMMAND" for help on my individual commands.\n'
expected_logs = 'MOCK: irc.post: mock_nick: Available commands: create-bug, help, hi, ping, restart, roll-chromium-deps, rollout, whois\nMOCK: irc.post: mock_nick: Type "mock-sheriff-bot: help COMMAND" for help on my individual commands.\n'
OutputCapture().assert_outputs(self, run, args=["help"], expected_logs=expected_logs)
expected_logs = 'MOCK: irc.post: mock_nick: Usage: hi\nMOCK: irc.post: mock_nick: Retrieves a random quip from Bugzilla.\nMOCK: irc.post: mock_nick: Aliases: hello\n'
OutputCapture().assert_outputs(self, run, args=["help hi"], expected_logs=expected_logs)
@@ -35,6 +35,7 @@
from webkitpy.tool.bot.irc_command import IRCCommand
from webkitpy.tool.bot.irc_command import Help
from webkitpy.tool.bot.irc_command import Hi
from webkitpy.tool.bot.irc_command import PingPong
from webkitpy.tool.bot.irc_command import Restart
from webkitpy.tool.bot.ircbot import IRCBot
from webkitpy.tool.commands.queues import AbstractQueue
@@ -43,16 +44,12 @@
_log = logging.getLogger(__name__)


class PingPong(IRCCommand):
def execute(self, nick, args, tool, sheriff):
return nick + ": pong"


class NewCommitBot(AbstractQueue, StepSequenceErrorHandler):
name = "new-commit-bot"
watchers = AbstractQueue.watchers + ["rniwa@webkit.org"]

_commands = {
"hi": Hi,
"ping": PingPong,
"restart": Restart,
}

0 comments on commit 4fbc731

Please sign in to comment.