diff --git a/gitinspector/changes.py b/gitinspector/changes.py index 02cda98..8f87e33 100644 --- a/gitinspector/changes.py +++ b/gitinspector/changes.py @@ -80,6 +80,13 @@ class Commit: def get_filediffs(self): return self.filediffs + @staticmethod + def get_author_and_email(string): + commit_line = string.split("|") + + if commit_line.__len__() == 4: + return (commit_line[2].strip(), commit_line[3].strip()) + @staticmethod def is_commit_line(string): return string.split("|").__len__() == 4 @@ -93,6 +100,7 @@ class AuthorInfo: class Changes: authors = {} authors_dateinfo = {} + authors_email = {} def __init__(self, hard): self.commits = [] @@ -109,6 +117,10 @@ class Changes: j = j.encode("latin-1", "replace") j = j.decode("utf-8", "replace") + if Commit.is_commit_line(j): + (author, email) = Commit.get_author_and_email(j) + self.authors_email[author] = email + if Commit.is_commit_line(j) or i is lines[-1]: if found_valid_extension: self.commits.append(commit) @@ -130,8 +142,7 @@ class Changes: def get_commits(self): return self.commits - @staticmethod - def __modify_authorinfo__(authors, key, commit): + def __modify_authorinfo__(self, authors, key, commit): if authors.get(key, None) == None: authors[key] = AuthorInfo() @@ -142,28 +153,22 @@ class Changes: authors[key].insertions += j.insertions authors[key].deletions += j.deletions - authors[key].email = commit.email - def get_authorinfo_list(self): if not self.authors: for i in self.commits: - Changes.__modify_authorinfo__(self.authors, i.author, i) + self.__modify_authorinfo__(self.authors, i.author, i) return self.authors def get_authordateinfo_list(self): if not self.authors_dateinfo: for i in self.commits: - Changes.__modify_authorinfo__(self.authors_dateinfo, (i.date, i.author), i) - self.authors_dateinfo[(i.date, i.author)].email = self.get_authorinfo_list()[i.author].email + self.__modify_authorinfo__(self.authors_dateinfo, (i.date, i.author), i) return self.authors_dateinfo def get_author_email(self, name): - if not self.authors: - self.get_authorinfo_list() - - return self.authors.get(name).email + return self.authors_email[name] __changes__ = None @@ -179,11 +184,11 @@ NO_COMMITED_FILES_TEXT = N_("No commited files with the specified extensions wer class ChangesOutput(Outputable): def __init__(self, hard): - self.hard = hard + self.changes = get(hard) Outputable.__init__(self) def output_html(self): - authorinfo_list = get(self.hard).get_authorinfo_list() + authorinfo_list = self.changes.get_authorinfo_list() total_changes = 0.0 changes_xml = "