Changeset 94990 in webkit


Ignore:
Timestamp:
Sep 12, 2011 4:43:08 PM (13 years ago)
Author:
eric@webkit.org
Message:

sheriffbot whois should be smarter
https://bugs.webkit.org/show_bug.cgi?id=67971

Reviewed by Adam Barth.

This makes sheriffbot whois basically grep the committers list
making it much easier to find a contributor by name.

Unfortunately the current unittests depend on the real committers.py
file, so as we add more eric's to the project, this unittest result will
change. I think that's OK for now. We'll fix it when it breaks.

  • Scripts/webkitpy/common/config/committers.py:
  • Scripts/webkitpy/tool/bot/irc_command.py:
  • Scripts/webkitpy/tool/bot/irc_command_unittest.py:
Location:
trunk/Tools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r94983 r94990  
     12011-09-12  Eric Seidel  <eric@webkit.org>
     2
     3        sheriffbot whois should be smarter
     4        https://bugs.webkit.org/show_bug.cgi?id=67971
     5
     6        Reviewed by Adam Barth.
     7
     8        This makes sheriffbot whois basically grep the committers list
     9        making it much easier to find a contributor by name.
     10
     11        Unfortunately the current unittests depend on the real committers.py
     12        file, so as we add more eric's to the project, this unittest result will
     13        change.  I think that's OK for now.  We'll fix it when it breaks.
     14
     15        * Scripts/webkitpy/common/config/committers.py:
     16        * Scripts/webkitpy/tool/bot/irc_command.py:
     17        * Scripts/webkitpy/tool/bot/irc_command_unittest.py:
     18
    1192011-09-12  Sheriff Bot  <webkit.review.bot@gmail.com>
    220
  • trunk/Tools/Scripts/webkitpy/common/config/committers.py

    r94923 r94990  
    5151    def __str__(self):
    5252        return '"%s" <%s>' % (self.full_name, self.emails[0])
     53
     54    def contains_string(self, string):
     55        if string in self.full_name:
     56            return True
     57        if self.irc_nickname and string in self.irc_nickname:
     58            return True
     59        for email in self.emails:
     60            if string in email:
     61                return True
     62        return False
    5363
    5464
     
    451461        return None
    452462
     463    def contributors_by_search_string(self, string):
     464        return filter(lambda contributor: contributor.contains_string(string), self.contributors())
     465
    453466    def contributor_by_email(self, email):
    454467        return self._email_to_contributor_map().get(email)
  • trunk/Tools/Scripts/webkitpy/tool/bot/irc_command.py

    r94036 r94990  
    173173
    174174class Whois(IRCCommand):
     175    def _nick_or_full_record(self, contributor):
     176        if contributor.irc_nickname:
     177            return contributor.irc_nickname
     178        return unicode(contributor)
     179
    175180    def execute(self, nick, args, tool, sheriff):
    176181        if len(args) != 1:
    177             return "%s: Usage: whois BUGZILLA_EMAIL" % nick
    178         email = args[0]
     182            return "%s: Usage: whois SEARCH_STRING" % nick
     183        search_string = args[0]
    179184        # FIXME: We should get the ContributorList off the tool somewhere.
    180         committer = CommitterList().contributor_by_email(email)
    181         if not committer:
    182             return "%s: Sorry, I don't know %s. Maybe you could introduce me?" % (nick, email)
    183         if not committer.irc_nickname:
    184             return "%s: %s hasn't told me their nick. Boo hoo :-(" % (nick, email)
    185         return "%s: %s is %s. Why do you ask?" % (nick, email, committer.irc_nickname)
     185        contributors = CommitterList().contributors_by_search_string(search_string)
     186        if not contributors:
     187            return "%s: Sorry, I don't know any contributors matching '%s'." % (nick, search_string)
     188        if len(contributors) > 5:
     189            return "More than 5 contributors match '%s', can you be more specific?"
     190        if len(contributors) == 1:
     191            contributor = contributors[0]
     192            if not contributor.irc_nickname:
     193                return "%s: %s hasn't told me their nick. Boo hoo :-(" % (nick, contributor)
     194            return "%s: %s is %s. Why do you ask?" % (nick, search_string, contributor.irc_nickname)
     195        contributor_nicks = map(self._nick_or_full_record, contributors)
     196        contributors_string = join_with_separators(contributor_nicks, only_two_separator=" or ", last_separator=', or ')
     197        return "%s: I'm not sure who you mean?  %s could be '%s'." % (nick, contributors_string, search_string)
    186198
    187199
  • trunk/Tools/Scripts/webkitpy/tool/bot/irc_command_unittest.py

    r94036 r94990  
    4242    def test_whois(self):
    4343        whois = Whois()
    44         self.assertEquals("tom: Usage: whois BUGZILLA_EMAIL",
     44        self.assertEquals("tom: Usage: whois SEARCH_STRING",
    4545                          whois.execute("tom", [], None, None))
    46         self.assertEquals("tom: Usage: whois BUGZILLA_EMAIL",
     46        self.assertEquals("tom: Usage: whois SEARCH_STRING",
    4747                          whois.execute("tom", ["Adam", "Barth"], None, None))
    48         self.assertEquals("tom: Sorry, I don't know unknown@example.com. Maybe you could introduce me?",
     48        self.assertEquals("tom: Sorry, I don't know any contributors matching 'unknown@example.com'.",
    4949                          whois.execute("tom", ["unknown@example.com"], None, None))
    5050        self.assertEquals("tom: tonyg@chromium.org is tonyg-cr. Why do you ask?",
    5151                          whois.execute("tom", ["tonyg@chromium.org"], None, None))
    52         self.assertEquals("tom: vicki@apple.com hasn't told me their nick. Boo hoo :-(",
     52        self.assertEquals('tom: "Vicki Murley" <vicki@apple.com> hasn\'t told me their nick. Boo hoo :-(',
    5353                          whois.execute("tom", ["vicki@apple.com"], None, None))
     54        self.assertEquals('tom: I\'m not sure who you mean?  ericu, "Eric Carlson" <eric.carlson@apple.com>, or eseidel could be \'eric\'.',
     55                          whois.execute("tom", ["eric"], None, None))
    5456
    5557    def test_create_bug(self):
Note: See TracChangeset for help on using the changeset viewer.