diff --git a/gitinspector/changes.py b/gitinspector/changes.py index 6fbd5c8..408d5a7 100644 --- a/gitinspector/changes.py +++ b/gitinspector/changes.py @@ -211,6 +211,9 @@ class Changes(object): self.last_commit_date = datetime.date(int(self.commits[-1].date[0:4]), int(self.commits[-1].date[5:7]), int(self.commits[-1].date[8:10])) + def __add__(self, other): + pass # TODO + def get_commits(self): return self.commits @@ -249,13 +252,3 @@ class Changes(object): def get_latest_email_by_author(self, name): return self.emails_by_author[name] - -__changes__ = None - -def get(hard): - global __changes__ - if __changes__ == None: - __changes__ = Changes(hard) - - return __changes__ - diff --git a/gitinspector/gitinspector.py b/gitinspector/gitinspector.py index f2b1b47..00e4a20 100644 --- a/gitinspector/gitinspector.py +++ b/gitinspector/gitinspector.py @@ -23,7 +23,8 @@ import atexit import getopt import os import sys -from . import (basedir, changes, clone, config, extensions, filtering, format, help, interval, +from .changes import Changes +from . import (basedir, clone, config, extensions, filtering, format, help, interval, localization, optval, terminal, version) from .output import outputable from .output.blameoutput import BlameOutput @@ -62,19 +63,21 @@ class Runner(object): absolute_path = basedir.get_basedir_git() os.chdir(absolute_path) format.output_header() - outputable.output(ChangesOutput(self.hard)) - if changes.get(self.hard).get_commits(): - outputable.output(BlameOutput(changes.get(self.hard), self.hard, self.useweeks)) + changes = Changes(self.hard) + outputable.output(ChangesOutput(changes)) + + if changes.get_commits(): + outputable.output(BlameOutput(changes, self.hard, self.useweeks)) if self.timeline: - outputable.output(TimelineOutput(changes.get(self.hard), self.useweeks)) + outputable.output(TimelineOutput(changes, self.useweeks)) if self.include_metrics: outputable.output(MetricsOutput()) if self.responsibilities: - outputable.output(ResponsibilitiesOutput(self.hard, self.useweeks)) + outputable.output(ResponsibilitiesOutput(changes, self.hard, self.useweeks)) outputable.output(FilteringOutput()) diff --git a/gitinspector/output/changesoutput.py b/gitinspector/output/changesoutput.py index f8a7c2c..50f87cc 100644 --- a/gitinspector/output/changesoutput.py +++ b/gitinspector/output/changesoutput.py @@ -22,15 +22,15 @@ from __future__ import unicode_literals import json import textwrap from ..localization import N_ -from .. import changes, format, gravatar, terminal +from .. import format, gravatar, terminal from .outputable import Outputable HISTORICAL_INFO_TEXT = N_("The following historical commit information, by author, was found in the repository") NO_COMMITED_FILES_TEXT = N_("No commited files with the specified extensions were found") class ChangesOutput(Outputable): - def __init__(self, hard): - self.changes = changes.get(hard) + def __init__(self, changes): + self.changes = changes Outputable.__init__(self) def output_html(self): diff --git a/gitinspector/output/responsibilitiesoutput.py b/gitinspector/output/responsibilitiesoutput.py index 217844e..ba5e74e 100644 --- a/gitinspector/output/responsibilitiesoutput.py +++ b/gitinspector/output/responsibilitiesoutput.py @@ -21,7 +21,7 @@ from __future__ import print_function from __future__ import unicode_literals import textwrap from ..localization import N_ -from .. import blame, changes, format, gravatar, terminal +from .. import blame, format, gravatar, terminal from .. import responsibilities as resp from .outputable import Outputable @@ -31,17 +31,18 @@ RESPONSIBILITIES_INFO_TEXT = N_("The following responsibilities, by author, were MOSTLY_RESPONSIBLE_FOR_TEXT = N_("is mostly responsible for") class ResponsibilitiesOutput(Outputable): - def __init__(self, hard, useweeks): + def __init__(self, changes, hard, useweeks): + self.changes = changes self.hard = hard self.useweeks = useweeks Outputable.__init__(self) - self.changes = changes.get(hard) def output_text(self): print("\n" + textwrap.fill(_(RESPONSIBILITIES_INFO_TEXT) + ":", width=terminal.get_size()[0])) for i in sorted(set(i[0] for i in blame.get(self.hard, self.useweeks, self.changes).blames)): - responsibilities = sorted(((i[1], i[0]) for i in resp.Responsibilities.get(self.hard, self.useweeks, i)), reverse=True) + responsibilities = sorted(((i[1], i[0]) for i in resp.Responsibilities.get(self.changes, + self.hard, self.useweeks, i)), reverse=True) if responsibilities: print("\n" + i, _(MOSTLY_RESPONSIBLE_FOR_TEXT) + ":") @@ -60,7 +61,8 @@ class ResponsibilitiesOutput(Outputable): resp_xml += "
" + _(RESPONSIBILITIES_INFO_TEXT) + ".
" for i in sorted(set(i[0] for i in blame.get(self.hard, self.useweeks, self.changes).blames)): - responsibilities = sorted(((i[1], i[0]) for i in resp.Responsibilities.get(self.hard, self.useweeks, i)), reverse=True) + responsibilities = sorted(((i[1], i[0]) for i in resp.Responsibilities.get(self.changes, + self.hard, self.useweeks, i)), reverse=True) if responsibilities: resp_xml += "