From e0941fdcf1cd7dee7030ab372e74716981248f14 Mon Sep 17 00:00:00 2001 From: Adam Waldenberg Date: Fri, 30 Oct 2015 23:46:13 +0100 Subject: [PATCH] The gitinspector.py entry module now considers all repositories. While they are considered, they are not yet being merged. Statistics are only calculated for the last repository passed. This is being done in preparation of completing issue #24. --- gitinspector/config.py | 5 +++-- gitinspector/gitinspector.py | 25 +++++++++++++------------ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/gitinspector/config.py b/gitinspector/config.py index a42d1d9..4eaf15c 100644 --- a/gitinspector/config.py +++ b/gitinspector/config.py @@ -23,13 +23,14 @@ import subprocess from . import extensions, filtering, format, interval, optval class GitConfig(object): - def __init__(self, run, global_only=False): + def __init__(self, run, repo, global_only=False): self.run = run + self.repo = repo self.global_only = global_only def __read_git_config__(self, variable): previous_directory = os.getcwd() - os.chdir(self.run.repo) + os.chdir(self.repo) setting = subprocess.Popen(filter(None, ["git", "config", "--global" if self.global_only else "", "inspector." + variable]), bufsize=1, stdout=subprocess.PIPE).stdout os.chdir(previous_directory) diff --git a/gitinspector/gitinspector.py b/gitinspector/gitinspector.py index cae0120..6a93c61 100644 --- a/gitinspector/gitinspector.py +++ b/gitinspector/gitinspector.py @@ -1,4 +1,4 @@ -# coding: utf-8 + # coding: utf-8 # # Copyright © 2012-2015 Ejwa Software. All rights reserved. # @@ -44,13 +44,12 @@ class Runner(object): self.include_metrics = False self.list_file_types = False self.localize_output = False - self.repo = "." self.responsibilities = False self.grading = False self.timeline = False self.useweeks = False - def output(self): + def process(self, repos): localization.check_compatibility(version.__version__) if not self.localize_output: @@ -60,9 +59,11 @@ class Runner(object): terminal.set_stdout_encoding() previous_directory = os.getcwd() - os.chdir(self.repo) - absolute_path = basedir.get_basedir_git() - os.chdir(absolute_path) + for repo in repos: + os.chdir(previous_directory) + os.chdir(repo) + absolute_path = basedir.get_basedir_git() + os.chdir(absolute_path) format.output_header(absolute_path) changes = Changes(self.hard) @@ -98,20 +99,20 @@ def main(): terminal.set_stdin_encoding() argv = terminal.convert_command_line_to_utf8() run = Runner() + repos = [] try: opts, args = optval.gnu_getopt(argv[1:], "f:F:hHlLmrTwx:", ["exclude=", "file-types=", "format=", "hard:true", "help", "list-file-types:true", "localize-output:true", "metrics:true", "responsibilities:true", "since=", "grading:true", "timeline:true", "until=", "version", "weeks:true"]) - if len(args) > 0: - run.repo = args[-1] - #Try to clone the repo or return the same directory and bail out. - run.repo = clone.create(run.repo) + #Try to clone the repos or return the same directory and bail out. + for repo in args: + repos.append(clone.create(repo)) #We need the repo above to be set before we read the git config. - GitConfig(run, len(args) > 1).read() + GitConfig(run, repos[-1] if len(repos) > 0 else ".", len(repos) > 1).read() clear_x_on_next_pass = True for o, a in opts: @@ -174,7 +175,7 @@ def main(): filtering.add(a) __check_python_version__() - run.output() + run.process(["."] if repos == [] else repos) except (filtering.InvalidRegExpError, format.InvalidFormatError, optval.InvalidOptionArgument, getopt.error) as exception: print(sys.argv[0], "\b:", exception.msg, file=sys.stderr)