def __init__(self, hard):
		self.commits = []
		git_log_r = subprocess.Popen("git log --pretty=\"%cd|%H|%aN|%s\" --stat=100000,8192 --no-merges -w " +
		                             interval.get_since() + interval.get_until() +
		                             "{0} --date=short".format("-C -C -M" if hard else ""),
		                             shell=True, bufsize=1, stdout=subprocess.PIPE).stdout
		commit = None
		found_valid_extension = False
		lines = git_log_r.readlines()

		for i in lines:
			i = codecs.getdecoder("unicode_escape")(i.strip())[0]
			i = i.encode("latin-1", "replace")
			i = i.decode("utf-8", "replace")

			if Commit.is_commit_line(i) or i == lines[-1]:
				if found_valid_extension:
					self.commits.append(commit)

				found_valid_extension = False
				commit = Commit(i)

			if FileDiff.is_filediff_line(i) and not filtering.set_filtered(FileDiff.get_filename(i)):
				extensions.add_located(FileDiff.get_extension(i))

				if FileDiff.is_valid_extension(i):
					found_valid_extension = True
					filediff = FileDiff(i)
					commit.add_filediff(filediff)

		if interval.has_interval() and len(self.commits) > 0:
			interval.set_ref(self.commits[0].sha)
Exemplo n.º 2
0
	def run(self):
		git_blame_r = subprocess.Popen(self.blame_string, shell=True, bufsize=1, stdout=subprocess.PIPE).stdout
		is_inside_comment = False

		for j in git_blame_r.readlines():
			j = j.decode("utf-8", "replace")
			if Blame.is_blame_line(j):
				content = Blame.get_content(j)
				(comments, is_inside_comment) = comment.handle_comment_block(is_inside_comment, self.extension, content)

				if Blame.is_prior(j) and interval.get_since():
					continue

				email = Blame.get_author_email(j)
				author = self.changes.get_latest_author_by_email(email)
				__blame_lock__.acquire() # Global lock used to protect calls from here...

				if not filtering.set_filtered(author, "author") and not filtering.set_filtered(email, "email"):
					if self.blames.get((author, self.filename), None) == None:
						self.blames[(author, self.filename)] = BlameEntry()

					self.blames[(author, self.filename)].comments += comments
					self.blames[(author, self.filename)].rows += 1

				__blame_lock__.release() # ...to here.

		git_blame_r.close()
		__thread_lock__.release() # Lock controlling the number of threads running
Exemplo n.º 3
0
	def __init__(self, hard):
		self.blames = {}
		ls_tree_r = subprocess.Popen("git ls-tree --name-only -r " + interval.get_ref(), shell=True, bufsize=1,
		                             stdout=subprocess.PIPE).stdout
		lines = ls_tree_r.readlines()

		for i, row in enumerate(lines):
			row = row.strip().decode("unicode_escape", "ignore")
			row = row.encode("latin-1", "replace")
			row = row.decode("utf-8", "replace").strip("\"").strip("'").strip()

			if FileDiff.is_valid_extension(row) and not filtering.set_filtered(FileDiff.get_filename(row)):
				if not missing.add(row):
					blame_string = "git blame -w {0} ".format("-C -C -M" if hard else "") + \
					               interval.get_since() + interval.get_ref() + " -- \"" + row + "\""
					thread = BlameThread(blame_string, FileDiff.get_extension(row), self.blames, row.strip())
					thread.daemon = True
					thread.start()

					if hard:
						Blame.output_progress(i, len(lines))

		# Make sure all threads have completed.
		for i in range(0, NUM_THREADS):
			__thread_lock__.acquire()
Exemplo n.º 4
0
    def __init__(self, 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()

        for i, row in enumerate(lines):
            row = row.strip().decode("unicode_escape", "ignore")
            row = row.encode("latin-1", "replace")
            row = row.decode("utf-8", "replace").strip("\"").strip("'").strip()

            if FileDiff.is_valid_extension(row) and not filtering.set_filtered(
                    FileDiff.get_filename(row)):
                blame_command = filter(None, ["git", "blame", "--line-porcelain", "-w"] + \
                  (["-C", "-C", "-M"] if hard else []) +
                                [interval.get_since(), interval.get_ref(), "--", row])
                thread = BlameThread(useweeks, changes, blame_command,
                                     FileDiff.get_extension(row), self.blames,
                                     row.strip())
                thread.daemon = True
                thread.start()

                if hard:
                    Blame.output_progress(i, len(lines))

        # Make sure all threads have completed.
        for i in range(0, NUM_THREADS):
            __thread_lock__.acquire()
Exemplo n.º 5
0
    def __handle_blamechunk_content__(self, content):
        author = None
        (comments, self.is_inside_comment) = comment.handle_comment_block(
            self.is_inside_comment, self.extension, content)

        if self.blamechunk_is_prior and interval.get_since():
            return
        try:
            author = self.changes.get_latest_author_by_email(
                self.blamechunk_email)
        except KeyError:
            return

        if not filtering.set_filtered(author, "author") and not \
               filtering.set_filtered(self.blamechunk_email, "email") and not \
               filtering.set_filtered(self.blamechunk_revision, "revision"):

            __blame_lock__.acquire(
            )  # Global lock used to protect calls from here...

            if self.blames.get((author, self.filename), None) == None:
                self.blames[(author, self.filename)] = BlameEntry()

            self.blames[(author, self.filename)].comments += comments
            self.blames[(author, self.filename)].rows += 1

            if (self.blamechunk_time -
                    self.changes.first_commit_date).days > 0:
                self.blames[(author, self.filename)].skew += (
                    (self.changes.last_commit_date - self.blamechunk_time).days
                    / (7.0 if self.useweeks else AVG_DAYS_PER_MONTH))

            __blame_lock__.release()  # ...to here.
Exemplo n.º 6
0
    def run(self):
        git_log_r = subprocess.Popen(
            filter(None, [
                "git", "log", "--reverse", "--pretty=%cd|%H|%aN|%aE",
                "--stat=100000,8192", "--no-merges", "-w",
                interval.get_since(),
                interval.get_until(), "--date=short"
            ] + (["-C", "-C", "-M"] if self.hard else []) +
                   [self.first_hash + self.second_hash]),
            bufsize=1,
            stdout=subprocess.PIPE).stdout
        lines = git_log_r.readlines()
        git_log_r.close()

        commit = None
        found_valid_extension = False
        is_filtered = False
        commits = []

        __changes_lock__.acquire(
        )  # Global lock used to protect calls from here...

        for i in lines:
            j = i.strip().decode("unicode_escape", "ignore")
            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.changes.emails_by_author[author] = email
                self.changes.authors_by_email[email] = author

            if Commit.is_commit_line(j) or i is lines[-1]:
                if found_valid_extension:
                    commits.append(commit)

                found_valid_extension = False
                is_filtered = False
                commit = Commit(j)

                if Commit.is_commit_line(j) and \
                   (filtering.set_filtered(commit.author, "author") or \
                   filtering.set_filtered(commit.email, "email") or \
                   filtering.set_filtered(commit.sha, "revision") or \
                   filtering.set_filtered(commit.sha, "message")):
                    is_filtered = True

            if FileDiff.is_filediff_line(j) and not \
               filtering.set_filtered(FileDiff.get_filename(j)) and not is_filtered:
                extensions.add_located(FileDiff.get_extension(j))

                if FileDiff.is_valid_extension(j):
                    found_valid_extension = True
                    filediff = FileDiff(j)
                    commit.add_filediff(filediff)

        self.changes.commits[self.offset // CHANGES_PER_THREAD] = commits
        __changes_lock__.release()  # ...to here.
        __thread_lock__.release(
        )  # Lock controlling the number of threads running
Exemplo n.º 7
0
	def __init__(self, hard):
		self.blames = {}
		ls_tree_r = subprocess.Popen("git ls-tree --name-only -r " + interval.get_ref(), shell=True, bufsize=1,
		                             stdout=subprocess.PIPE).stdout
		lines = ls_tree_r.readlines()

		for i, row in enumerate(lines):
			row = codecs.getdecoder("unicode_escape")(row.strip())[0]
			row = row.encode("latin-1", "replace")
			row = row.decode("utf-8", "replace").strip("\"").strip("'").strip()

			if FileDiff.is_valid_extension(row) and not filtering.set_filtered(FileDiff.get_filename(row)):
				if not missing.add(row):
					blame_string = "git blame -w {0} ".format("-C -C -M" if hard else "") + \
					               interval.get_since() + interval.get_ref() + " -- \"" + row + "\""
					thread = BlameThread(blame_string, FileDiff.get_extension(row), self.blames, row.strip())
					thread.daemon = True
					thread.start()

					if hard:
						Blame.output_progress(i, len(lines))

		# Make sure all threads have completed.
		for i in range(0, NUM_THREADS):
			__thread_lock__.acquire()
Exemplo n.º 8
0
	def __handle_blamechunk_content__(self, content):
		author = None
		(comments, self.is_inside_comment) = comment.handle_comment_block(self.is_inside_comment, self.extension, content)

		if self.blamechunk_is_prior and interval.get_since():
			return
		try:
			author = self.changes.get_latest_author_by_email(self.blamechunk_email)
		except KeyError:
			return

		if not filtering.set_filtered(author, "author") and not \
		       filtering.set_filtered(self.blamechunk_email, "email") and not \
		       filtering.set_filtered(self.blamechunk_revision, "revision"):

			__blame_lock__.acquire() # Global lock used to protect calls from here...

			if self.blames.get((author, self.filename), None) == None:
				self.blames[(author, self.filename)] = BlameEntry()

			self.blames[(author, self.filename)].comments += comments
			self.blames[(author, self.filename)].rows += 1

			if (self.blamechunk_time - self.changes.first_commit_date).days > 0:
				self.blames[(author, self.filename)].skew += ((self.changes.last_commit_date - self.blamechunk_time).days /
				                                             (7.0 if self.useweeks else AVG_DAYS_PER_MONTH))

			__blame_lock__.release() # ...to here.
Exemplo n.º 9
0
	def __init__(self, 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()

		for i, row in enumerate(lines):
			row = row.strip().decode("unicode_escape", "ignore")
			row = row.encode("latin-1", "replace")
			row = row.decode("utf-8", "replace").strip("\"").strip("'").strip()

			if FileDiff.is_valid_extension(row) and not filtering.set_filtered(FileDiff.get_filename(row)):
				blame_command = filter(None, ["git", "blame", "--line-porcelain", "-w"] + \
						(["-C", "-C", "-M"] if hard else []) +
				                [interval.get_since(), interval.get_ref(), "--", row])
				thread = BlameThread(useweeks, changes, blame_command, FileDiff.get_extension(row), self.blames, row.strip())
				thread.daemon = True
				thread.start()

				if hard:
					Blame.output_progress(i, len(lines))

		# Make sure all threads have completed.
		for i in range(0, NUM_THREADS):
			__thread_lock__.acquire()
Exemplo n.º 10
0
def eligible_for_inspection(commit):
    since_date_time = interval.get_since()
    if since_date_time:
        since_date_time = since_date_time.split("=")
        since_date_time = since_date_time[1]
        since_date_time = since_date_time.replace("\"", "")
    else:
        since_date_time = (datetime.now() - timedelta(days=7)).strftime("%Y-%m-%d")
    return get_commit_date(commit) > since_date_time
Exemplo n.º 11
0
	def run(self):
		git_log_r = subprocess.Popen(filter(None, ["git", "log", "--reverse", "--pretty=%cd|%H|%aN|%aE",
		                             "--stat=100000,8192", "--no-merges", "-w", interval.get_since(),
		                             interval.get_until(), "--date=short"] + (["-C", "-C", "-M"] if self.hard else []) +
		                             [self.first_hash + self.second_hash]), bufsize=1, stdout=subprocess.PIPE).stdout
		lines = git_log_r.readlines()
		git_log_r.close()

		commit = None
		found_valid_extension = False
		is_filtered = False
		commits = []

		__changes_lock__.acquire() # Global lock used to protect calls from here...

		for i in lines:
			j = i.strip().decode("unicode_escape", "ignore")
			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.changes.emails_by_author[author] = email
				self.changes.authors_by_email[email] = author

			if Commit.is_commit_line(j) or i is lines[-1]:
				if found_valid_extension:
					commits.append(commit)

				found_valid_extension = False
				is_filtered = False
				commit = Commit(j)

				if Commit.is_commit_line(j) and \
				   (filtering.set_filtered(commit.author, "author") or \
				   filtering.set_filtered(commit.email, "email") or \
				   filtering.set_filtered(commit.sha, "revision") or \
				   filtering.set_filtered(commit.sha, "message")):
					is_filtered = True

			if FileDiff.is_filediff_line(j) and not \
			   filtering.set_filtered(FileDiff.get_filename(j)) and not is_filtered:
				extensions.add_located(FileDiff.get_extension(j))

				if FileDiff.is_valid_extension(j):
					found_valid_extension = True
					filediff = FileDiff(j)
					commit.add_filediff(filediff)

		self.changes.commits[self.offset // CHANGES_PER_THREAD] = commits
		__changes_lock__.release() # ...to here.
		__thread_lock__.release() # Lock controlling the number of threads running
Exemplo n.º 12
0
    def __init__(self, hard):
        self.commits = []
        git_log_r = subprocess.Popen(
            "git log --reverse --pretty=\"%cd|%H|%aN|%aE\" --stat=100000,8192 --no-merges -w "
            + interval.get_since() + interval.get_until() +
            "{0} --date=short".format("-C -C -M" if hard else ""),
            shell=True,
            bufsize=1,
            stdout=subprocess.PIPE).stdout
        commit = None
        found_valid_extension = False
        lines = git_log_r.readlines()

        for i in lines:
            j = i.strip().decode("unicode_escape", "ignore")
            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.emails_by_author[author] = email
                self.authors_by_email[email] = author

            if Commit.is_commit_line(j) or i is lines[-1]:
                if found_valid_extension:
                    self.commits.append(commit)

                found_valid_extension = False
                commit = Commit(j)

            if FileDiff.is_filediff_line(j) and not filtering.set_filtered(FileDiff.get_filename(j)) and not \
               filtering.set_filtered(commit.author, "author") and not filtering.set_filtered(commit.email, "email") and not \
               filtering.set_filtered(commit.sha, "revision"):
                extensions.add_located(FileDiff.get_extension(j))

                if FileDiff.is_valid_extension(j):
                    found_valid_extension = True
                    filediff = FileDiff(j)
                    commit.add_filediff(filediff)

        if interval.has_interval() and len(self.commits) > 0:
            interval.set_ref(self.commits[0].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]),
                int(self.commits[-1].date[8:10]))
Exemplo n.º 13
0
    def run(self):
        git_blame_r = subprocess.Popen(self.blame_string,
                                       shell=True,
                                       bufsize=1,
                                       stdout=subprocess.PIPE).stdout
        is_inside_comment = False

        for j in git_blame_r.readlines():
            j = j.decode("utf-8", "replace")
            if Blame.is_blame_line(j):
                content = Blame.get_content(j)
                (comments, is_inside_comment) = comment.handle_comment_block(
                    is_inside_comment, self.extension, content)

                if Blame.is_prior(j) and interval.get_since():
                    continue

                email = Blame.get_author_email(j)
                try:
                    author = self.changes.get_latest_author_by_email(email)
                except KeyError:
                    continue

                __blame_lock__.acquire(
                )  # Global lock used to protect calls from here...

                if not filtering.set_filtered(
                        author, "author") and not filtering.set_filtered(
                            email, "email"):
                    if self.blames.get((author, self.filename), None) == None:
                        self.blames[(author, self.filename)] = BlameEntry()

                    self.blames[(author, self.filename)].comments += comments
                    self.blames[(author, self.filename)].rows += 1

                    time = Blame.get_time(j)
                    time = datetime.date(int(time[0:4]), int(time[5:7]),
                                         int(time[8:10]))

                    if (time - self.changes.first_commit_date).days > 0:
                        self.blames[(author, self.filename)].skew += (
                            (self.changes.last_commit_date - time).days /
                            (7.0 if self.useweeks else AVG_DAYS_PER_MONTH))

                __blame_lock__.release()  # ...to here.

        git_blame_r.close()
        __thread_lock__.release(
        )  # Lock controlling the number of threads running
Exemplo n.º 14
0
    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 = ""

            for i, entry in enumerate(lines):
                if i % CHANGES_PER_THREAD == CHANGES_PER_THREAD - 1:
                    entry = entry.decode("utf-8", "replace").strip()
                    second_hash = entry
                    ChangesThread.create(hard, self, first_hash, second_hash,
                                         i)
                    first_hash = entry + ".."
            else:
                entry = entry.decode("utf-8", "replace").strip()
                second_hash = entry
                ChangesThread.create(hard, self, first_hash, second_hash, i)

        # Make sure all threads have completed.
        for i in range(0, NUM_THREADS):
            __thread_lock__.acquire()

        self.commits = [item for sublist in self.commits for item in sublist]

        if len(self.commits) > 0:
            if interval.has_interval() and len(self.commits) > 0:
                interval.set_ref(self.commits[-1].sha)

            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]),
                int(self.commits[-1].date[8:10]))
Exemplo n.º 15
0
	def __init__(self, hard):
		self.commits = []
		git_log_r = subprocess.Popen("git log --reverse --pretty=\"%cd|%H|%aN|%aE\" --stat=100000,8192 --no-merges -w " +
		                             interval.get_since() + interval.get_until() +
		                             "{0} --date=short".format("-C -C -M" if hard else ""),
		                             shell=True, bufsize=1, stdout=subprocess.PIPE).stdout
		commit = None
		found_valid_extension = False
		lines = git_log_r.readlines()

		for i in lines:
			j = i.strip().decode("unicode_escape", "ignore")
			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.emails_by_author[author] = email
				self.authors_by_email[email] = author

			if Commit.is_commit_line(j) or i is lines[-1]:
				if found_valid_extension:
					self.commits.append(commit)

				found_valid_extension = False
				commit = Commit(j)

			if FileDiff.is_filediff_line(j) and not filtering.set_filtered(FileDiff.get_filename(j)) and not \
			   filtering.set_filtered(commit.author, "author") and not filtering.set_filtered(commit.email, "email") and not \
			   filtering.set_filtered(commit.sha, "revision"):
				extensions.add_located(FileDiff.get_extension(j))

				if FileDiff.is_valid_extension(j):
					found_valid_extension = True
					filediff = FileDiff(j)
					commit.add_filediff(filediff)

		if interval.has_interval() and len(self.commits) > 0:
			interval.set_ref(self.commits[0].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]),
			                                       int(self.commits[-1].date[8:10]))
Exemplo n.º 16
0
    def run(self):
        git_blame_r = subprocess.Popen(self.blame_string, shell=True, bufsize=1, stdout=subprocess.PIPE).stdout
        is_inside_comment = False

        for j in git_blame_r.readlines():
            j = j.decode("utf-8", "replace")
            if Blame.is_blame_line(j):
                content = Blame.get_content(j)
                (comments, is_inside_comment) = comment.handle_comment_block(is_inside_comment, self.extension, content)

                if Blame.is_prior(j) and interval.get_since():
                    continue

                email = Blame.get_author_email(j)
                try:
                    author = self.changes.get_latest_author_by_email(email)
                except KeyError:
                    continue

                __blame_lock__.acquire()  # Global lock used to protect calls from here...

                if not filtering.set_filtered(author, "author") and not filtering.set_filtered(email, "email"):
                    if self.blames.get((author, self.filename), None) == None:
                        self.blames[(author, self.filename)] = BlameEntry()

                    self.blames[(author, self.filename)].comments += comments
                    self.blames[(author, self.filename)].rows += 1

                    time = Blame.get_time(j)
                    time = datetime.date(int(time[0:4]), int(time[5:7]), int(time[8:10]))

                    if (time - self.changes.first_commit_date).days > 0:
                        self.blames[(author, self.filename)].skew += (self.changes.last_commit_date - time).days / (
                            7.0 if self.useweeks else AVG_DAYS_PER_MONTH
                        )

                __blame_lock__.release()  # ...to here.

        git_blame_r.close()
        __thread_lock__.release()  # Lock controlling the number of threads running
Exemplo n.º 17
0
	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 = ""

			for i, entry in enumerate(lines):
				if i % CHANGES_PER_THREAD == CHANGES_PER_THREAD - 1:
					entry = entry.decode("utf-8", "replace").strip()
					second_hash = entry
					ChangesThread.create(hard, self, first_hash, second_hash, i)
					first_hash = entry + ".."
			else:
				entry = entry.decode("utf-8", "replace").strip()
				second_hash = entry
				ChangesThread.create(hard, self, first_hash, second_hash, i)

		# Make sure all threads have completed.
		for i in range(0, NUM_THREADS):
			__thread_lock__.acquire()

		self.commits = [item for sublist in self.commits for item in sublist]

		if len(self.commits) > 0:
			if interval.has_interval() and len(self.commits) > 0:
				interval.set_ref(self.commits[-1].sha)

			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]),
			                                      int(self.commits[-1].date[8:10]))
Exemplo n.º 18
0
    def run(self):
        git_blame_r = subprocess.Popen(self.blame_string,
                                       shell=True,
                                       bufsize=1,
                                       stdout=subprocess.PIPE).stdout
        is_inside_comment = False

        for j in git_blame_r.readlines():
            j = j.decode("utf-8", "replace")
            if Blame.is_blame_line(j):
                content = Blame.get_content(j)
                (comments, is_inside_comment) = comment.handle_comment_block(
                    is_inside_comment, self.extension, content)

                if Blame.is_prior(j) and interval.get_since():
                    continue

                email = Blame.get_author_email(j)
                author = self.changes.get_latest_author_by_email(email)
                __blame_lock__.acquire(
                )  # Global lock used to protect calls from here...

                if not filtering.set_filtered(
                        author, "author") and not filtering.set_filtered(
                            email, "email"):
                    if self.blames.get((author, self.filename), None) == None:
                        self.blames[(author, self.filename)] = BlameEntry()

                    self.blames[(author, self.filename)].comments += comments
                    self.blames[(author, self.filename)].rows += 1

                __blame_lock__.release()  # ...to here.

        git_blame_r.close()
        __thread_lock__.release(
        )  # Lock controlling the number of threads running
Exemplo n.º 19
0
    def __init__(self, hard):
        self.commits = []
        git_log_r = subprocess.Popen(
            "git log --pretty=\"%cd|%H|%aN|%s\" --stat=100000,8192 --no-merges -w "
            + interval.get_since() + interval.get_until() +
            "{0} --date=short".format("-C -C -M" if hard else ""),
            shell=True,
            bufsize=1,
            stdout=subprocess.PIPE).stdout
        commit = None
        found_valid_extension = False
        lines = git_log_r.readlines()

        for i in lines:
            i = codecs.getdecoder("unicode_escape")(i.strip())[0]
            i = i.encode("latin-1", "replace")
            i = i.decode("utf-8", "replace")

            if Commit.is_commit_line(i) or i == lines[-1]:
                if found_valid_extension:
                    self.commits.append(commit)

                found_valid_extension = False
                commit = Commit(i)

            if FileDiff.is_filediff_line(i) and not filtering.set_filtered(
                    FileDiff.get_filename(i)):
                extensions.add_located(FileDiff.get_extension(i))

                if FileDiff.is_valid_extension(i):
                    found_valid_extension = True
                    filediff = FileDiff(i)
                    commit.add_filediff(filediff)

        if interval.has_interval() and len(self.commits) > 0:
            interval.set_ref(self.commits[0].sha)