Progress output now includes repository name (#24).

The name of the repository is only printed when multiple repositories
are specified. Otherwise, gitinspector falls back to the previous
behavior
This commit is contained in:
Adam Waldenberg 2015-11-02 18:22:56 +01:00
parent 7dda8d34b5
commit 9ada057d81
3 changed files with 15 additions and 6 deletions

View file

@ -121,13 +121,17 @@ class BlameThread(threading.Thread):
PROGRESS_TEXT = N_("Checking how many rows belong to each author (2 of 2): {0:.0f}%")
class Blame(object):
def __init__(self, hard, useweeks, changes):
def __init__(self, repo, hard, useweeks, changes):
self.blames = {}
ls_tree_r = subprocess.Popen(["git", "ls-tree", "--name-only", "-r", interval.get_ref()], bufsize=1,
stdout=subprocess.PIPE).stdout
lines = ls_tree_r.readlines()
ls_tree_r.close()
progress_text = _(PROGRESS_TEXT)
if repo != None:
progress_text = "[%s] " % repo.name + progress_text
for i, row in enumerate(lines):
row = row.strip().decode("unicode_escape", "ignore")
row = row.encode("latin-1", "replace")
@ -142,7 +146,7 @@ class Blame(object):
thread.start()
if format.is_interactive_format():
terminal.output_progress(_(PROGRESS_TEXT), i, len(lines))
terminal.output_progress(progress_text, i, len(lines))
# Make sure all threads have completed.
for i in range(0, NUM_THREADS):

View file

@ -181,7 +181,7 @@ class Changes(object):
authors_by_email = {}
emails_by_author = {}
def __init__(self, hard):
def __init__(self, repo, hard):
self.commits = []
git_log_hashes_r = subprocess.Popen(filter(None, ["git", "rev-list", "--reverse", "--no-merges",
interval.get_since(), interval.get_until(), "HEAD"]), bufsize=1,
@ -190,6 +190,10 @@ class Changes(object):
git_log_hashes_r.close()
if len(lines) > 0:
progress_text = _(PROGRESS_TEXT)
if repo != None:
progress_text = "[%s] " % repo.name + progress_text
self.commits = [None] * (len(lines) // CHANGES_PER_THREAD + 1)
first_hash = ""
@ -201,7 +205,7 @@ class Changes(object):
first_hash = entry + ".."
if format.is_interactive_format():
terminal.output_progress(_(PROGRESS_TEXT), i, len(lines))
terminal.output_progress(progress_text, i, len(lines))
else:
entry = entry.decode("utf-8", "replace").strip()
second_hash = entry

View file

@ -66,8 +66,9 @@ class Runner(object):
for repo in repos:
os.chdir(repo.location)
changes = Changes(self.hard)
summed_blames = Blame(self.hard, self.useweeks, changes) + summed_blames
repo = repo if len(repos) > 1 else None
changes = Changes(repo, self.hard)
summed_blames = Blame(repo, self.hard, self.useweeks, changes) + summed_blames
summed_changes = changes + summed_changes
if self.include_metrics: