Changeset 148372 in webkit


Ignore:
Timestamp:
Apr 13, 2013 5:46:21 PM (11 years ago)
Author:
rniwa@webkit.org
Message:

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.

Location:
trunk/Tools
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r148368 r148372  
     12013-04-13  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        webkitbot should provide full name, email address, and IRC nicknames on whois
     4        https://bugs.webkit.org/show_bug.cgi?id=114494
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        A response like the one below is useless. Improve it:
     9        webkitbot: rniwa: zdobersek is zdobersek (zandobersek@gmail.com). Why do you ask?
     10
     11        We now report full name, email address, committer/reviewer status, and IRC nickname.
     12
     13        Also teach webkitbot how to respond to ping.
     14
     15        * Scripts/webkitpy/tool/bot/irc_command.py:
     16        (PingPong): Moved
     17        (PingPong.execute):
     18        (Whois._full_record_and_nick): Renamed and rewritten.
     19        (Whois.execute):
     20
     21        * Scripts/webkitpy/tool/bot/irc_command_unittest.py:
     22        (IRCCommandTest.test_whois): Updated test cases as needed.
     23
     24        * Scripts/webkitpy/tool/bot/ircbot_unittest.py:
     25        (IRCBotTest.test_help): Added ping.
     26
     27        * Scripts/webkitpy/tool/commands/newcommitbot.py:
     28        (NewCommitBot): Teached WKR how to respond to hi.
     29
    1302013-04-13  Anders Carlsson  <andersca@apple.com>
    231
  • trunk/Tools/Scripts/webkitpy/tool/bot/irc_command.py

    r148185 r148372  
    122122
    123123
     124class PingPong(IRCCommand):
     125    usage_string = "ping"
     126    help_string = "Responds with pong."
     127
     128    def execute(self, nick, args, tool, sheriff):
     129        return nick + ": pong"
     130
     131
    124132class Restart(IRCCommand):
    125133    usage_string = "restart"
     
    248256    help_string = "Searches known contributors and returns any matches with irc, email and full name. Wild card * permitted."
    249257
    250     def _nick_or_full_record(self, contributor):
     258    def _full_record_and_nick(self, contributor):
     259        result = ''
     260
    251261        if contributor.irc_nicknames:
    252             return ', '.join(contributor.irc_nicknames)
    253         return unicode(contributor)
     262            result += ' (:%s)' % ', :'.join(contributor.irc_nicknames)
     263
     264        if contributor.can_review:
     265            result += ' (r)'
     266        elif contributor.can_commit:
     267            result += ' (c)'
     268
     269        return unicode(contributor) + result
    254270
    255271    def execute(self, nick, args, tool, sheriff):
     
    259275        # FIXME: We should get the ContributorList off the tool somewhere.
    260276        contributors = CommitterList().contributors_by_search_string(search_string)
     277        search_string = unicode(search_string)
    261278        if not contributors:
    262279            return "%s: Sorry, I don't know any contributors matching '%s'." % (nick, search_string)
     
    267284            if not contributor.irc_nicknames:
    268285                return "%s: %s hasn't told me their nick. Boo hoo :-(" % (nick, contributor)
    269             if contributor.emails and search_string.lower() not in map(lambda email: email.lower(), contributor.emails):
    270                 formattedEmails = ', '.join(contributor.emails)
    271                 return "%s: %s is %s (%s). Why do you ask?" % (nick, search_string, self._nick_or_full_record(contributor), formattedEmails)
    272             else:
    273                 return "%s: %s is %s. Why do you ask?" % (nick, search_string, self._nick_or_full_record(contributor))
    274         contributor_nicks = map(self._nick_or_full_record, contributors)
     286            return "%s: %s is %s. Why do you ask?" % (nick, search_string, self._full_record_and_nick(contributor))
     287        contributor_nicks = map(self._full_record_and_nick, contributors)
    275288        contributors_string = join_with_separators(contributor_nicks, only_two_separator=" or ", last_separator=', or ')
    276289        return "%s: I'm not sure who you mean?  %s could be '%s'." % (nick, contributors_string, search_string)
     
    282295    "help": Help,
    283296    "hi": Hi,
     297    "ping": PingPong,
    284298    "restart": Restart,
    285299    "roll-chromium-deps": RollChromiumDEPS,
  • trunk/Tools/Scripts/webkitpy/tool/bot/irc_command_unittest.py

    r148185 r148372  
    4343        self.assertEqual("tom: Usage: whois SEARCH_STRING",
    4444                          whois.execute("tom", [], None, None))
    45         self.assertEqual("tom: Adam Barth is abarth (abarth@webkit.org). Why do you ask?",
     45        self.assertEqual('tom: Adam Barth is "Adam Barth" <abarth@webkit.org> (:abarth) (r). Why do you ask?',
    4646                          whois.execute("tom", ["Adam", "Barth"], None, None))
    4747        self.assertEqual("tom: Sorry, I don't know any contributors matching 'unknown@example.com'.",
    4848                          whois.execute("tom", ["unknown@example.com"], None, None))
    49         self.assertEqual("tom: tonyg@chromium.org is tonyg-cr. Why do you ask?",
     49        self.assertEqual('tom: tonyg@chromium.org is "Tony Gentilcore" <tonyg@chromium.org> (:tonyg-cr) (r). Why do you ask?',
    5050                          whois.execute("tom", ["tonyg@chromium.org"], None, None))
    51         self.assertEqual("tom: TonyG@Chromium.org is tonyg-cr. Why do you ask?",
     51        self.assertEqual('tom: TonyG@Chromium.org is "Tony Gentilcore" <tonyg@chromium.org> (:tonyg-cr) (r). Why do you ask?',
    5252                          whois.execute("tom", ["TonyG@Chromium.org"], None, None))
    53         self.assertEqual("tom: rniwa is rniwa (rniwa@webkit.org). Why do you ask?",
     53        self.assertEqual('tom: rniwa is "Ryosuke Niwa" <rniwa@webkit.org> (:rniwa) (r). Why do you ask?',
    5454                          whois.execute("tom", ["rniwa"], None, None))
    55         self.assertEqual("tom: lopez is xan (xan.lopez@gmail.com, xan@gnome.org, xan@webkit.org, xlopez@igalia.com). Why do you ask?",
     55        self.assertEqual('tom: lopez is "Xan Lopez" <xan.lopez@gmail.com> (:xan) (r). Why do you ask?',
    5656                          whois.execute("tom", ["lopez"], None, None))
     57        self.assertEqual(u'tom: Osztrogon\u00e1c is "Csaba Osztrogon\u00e1c" <ossy@webkit.org> (:ossy) (r). Why do you ask?',
     58                          whois.execute("tom", [u'Osztrogon\u00e1c'], None, None))
    5759        self.assertEqual('tom: "Vicki Murley" <vicki@apple.com> hasn\'t told me their nick. Boo hoo :-(',
    5860                          whois.execute("tom", ["vicki@apple.com"], None, None))
    59         self.assertEqual('tom: I\'m not sure who you mean?  gavinp or gbarra could be \'Gavin\'.',
     61        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\'.',
    6062                          whois.execute("tom", ["Gavin"], None, None))
    6163        self.assertEqual('tom: More than 5 contributors match \'david\', could you be more specific?',
  • trunk/Tools/Scripts/webkitpy/tool/bot/ircbot_unittest.py

    r148185 r148372  
    8989
    9090    def test_help(self):
    91         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'
     91        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'
    9292        OutputCapture().assert_outputs(self, run, args=["help"], expected_logs=expected_logs)
    9393        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'
  • trunk/Tools/Scripts/webkitpy/tool/commands/newcommitbot.py

    r148055 r148372  
    3636from webkitpy.tool.bot.irc_command import Help
    3737from webkitpy.tool.bot.irc_command import Hi
     38from webkitpy.tool.bot.irc_command import PingPong
    3839from webkitpy.tool.bot.irc_command import Restart
    3940from webkitpy.tool.bot.ircbot import IRCBot
     
    4445
    4546
    46 class PingPong(IRCCommand):
    47     def execute(self, nick, args, tool, sheriff):
    48         return nick + ": pong"
    49 
    50 
    5147class NewCommitBot(AbstractQueue, StepSequenceErrorHandler):
    5248    name = "new-commit-bot"
     
    5450
    5551    _commands = {
     52        "hi": Hi,
    5653        "ping": PingPong,
    5754        "restart": Restart,
Note: See TracChangeset for help on using the changeset viewer.