The changes module crashed on empty commit/revision lists (Fixes #68).

Once again introduced with aeb9ad6, this could happen whenever a
repository had no commits or if the history was being filtered with
--since and/or --until and no commits were being detected within that
interval.
This commit is contained in:
Adam Waldenberg 2015-09-29 22:09:05 +02:00
parent 6d89cdf8c8
commit e4827ee58e

View file

@ -185,12 +185,14 @@ class Changes:
emails_by_author = {}
def __init__(self, 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,
stdout=subprocess.PIPE).stdout
lines = git_log_hashes_r.readlines()
git_log_hashes_r.close()
if len(lines) > 0:
self.commits = [None] * (len(lines) // CHANGES_PER_THREAD + 1)
first_hash = ""
@ -209,12 +211,12 @@ class Changes:
for i in range(0, NUM_THREADS):
__thread_lock__.acquire()
if len(self.commits) > 0:
self.commits = [item for sublist in self.commits for item in sublist]
if interval.has_interval() and len(self.commits) > 0:
interval.set_ref(self.commits[-1].sha)
if len(self.commits) > 0:
self.first_commit_date = datetime.date(int(self.commits[0].date[0:4]), int(self.commits[0].date[5:7]),
int(self.commits[0].date[8:10]))
self.last_commit_date = datetime.date(int(self.commits[-1].date[0:4]), int(self.commits[-1].date[5:7]),