1 # Copyright (c) 2010 Google Inc. All rights reserved.
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are
7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer
11 # in the documentation and/or other materials provided with the
13 # * Neither the name of Google Inc. nor the names of its
14 # contributors may be used to endorse or promote products derived from
15 # this software without specific prior written permission.
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 # WebKit's python module for holding information on a commit
31 from webkitpy.common.config import urls
32 from webkitpy.common.config.committers import CommitterList
35 class CommitInfo(object):
36 def __init__(self, revision, committer_email, changelog_data, committer_list=CommitterList()):
37 self._revision = revision
38 self._committer_email = committer_email
39 self._changelog_data = changelog_data
42 self._committer = committer_list.committer_by_email(committer_email)
48 return self._committer # None if committer isn't in committers.py
50 def committer_email(self):
51 return self._committer_email
54 return self._changelog_data["bug_id"] # May be None
57 return self._changelog_data["author"] # May be None
59 def author_name(self):
60 return self._changelog_data["author_name"]
62 def author_email(self):
63 return self._changelog_data["author_email"]
66 return self._changelog_data["reviewer"] # May be None
68 def reviewer_text(self):
69 return self._changelog_data["reviewer_text"] # May be None
71 def changed_files(self):
72 return self._changelog_data["changed_files"]
76 "bug_id": self.bug_id(),
77 "author_name": self.author_name(),
78 "author_email": self.author_email(),
79 "reviewer_text": self.reviewer_text(),
80 "changed_files": self.changed_files(),
83 def responsible_parties(self):
84 responsible_parties = [
89 return set([party for party in responsible_parties if party]) # Filter out None
91 # FIXME: It is slightly lame that this "view" method is on this "model" class (in MVC terms)
92 def blame_string(self, bugs):
93 string = "r%s:\n" % self.revision()
94 string += " %s\n" % urls.view_revision_url(self.revision())
95 string += " Bug: %s (%s)\n" % (self.bug_id(), bugs.bug_url_for_bug_id(self.bug_id()))
96 author_line = "\"%s\" <%s>" % (self.author_name(), self.author_email())
97 string += " Author: %s\n" % (self.author() or author_line)
98 string += " Reviewer: %s\n" % (self.reviewer() or self.reviewer_text())
99 string += " Committer: %s" % self.committer()