Ejemplo n.º 1
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()
Ejemplo n.º 2
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()
Ejemplo n.º 3
0
    def __init__(self):
        self.eloc = {}
        self.cyclomatic_complexity = {}
        self.cyclomatic_complexity_density = {}

        ls_tree_r = subprocess.Popen("git ls-tree --name-only -r " + interval.get_ref(), shell=True, bufsize=1,
                                     stdout=subprocess.PIPE).stdout

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

            if FileDiff.is_valid_extension(i) and not filtering.set_filtered(FileDiff.get_filename(i)):
                file_r = subprocess.Popen("git show " + interval.get_ref() + ":" + i.strip(), shell=True, bufsize=1,
                                          stdout=subprocess.PIPE).stdout.readlines()

                extension = FileDiff.get_extension(i)
                lines = MetricsLogic.get_eloc(file_r, extension)
                cc = MetricsLogic.get_cyclomatic_complexity(file_r, extension)

                if __metric_eloc__.get(extension, None) != None and __metric_eloc__[extension] < lines:
                    self.eloc[i.strip()] = lines

                if METRIC_CYCLOMATIC_COMPLEXITY_THRESHOLD < cc:
                    self.cyclomatic_complexity[i.strip()] = cc

                if lines > 0 and METRIC_CYCLOMATIC_COMPLEXITY_DENSITY_THRESHOLD < cc / float(lines):
                    self.cyclomatic_complexity_density[i.strip()] = cc / float(lines)
Ejemplo n.º 4
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()
Ejemplo n.º 5
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()
Ejemplo n.º 6
0
	def __init__(self):
		self.eloc = {}
		self.cyclomatic_complexity = {}
		self.cyclomatic_complexity_density = {}

		ls_tree_r = subprocess.Popen("git ls-tree --name-only -r " + interval.get_ref(), shell=True, bufsize=1,
		                             stdout=subprocess.PIPE).stdout

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

			if FileDiff.is_valid_extension(i) and not filtering.set_filtered(FileDiff.get_filename(i)):
				file_r = subprocess.Popen("git show " + interval.get_ref() + ":\"{0}\"".format(i.strip()),
				                          shell=True, bufsize=1, stdout=subprocess.PIPE).stdout.readlines()

				extension = FileDiff.get_extension(i)
				lines = MetricsLogic.get_eloc(file_r, extension)
				cycc = MetricsLogic.get_cyclomatic_complexity(file_r, extension)

				if __metric_eloc__.get(extension, None) != None and __metric_eloc__[extension] < lines:
					self.eloc[i.strip()] = lines

				if METRIC_CYCLOMATIC_COMPLEXITY_THRESHOLD < cycc:
					self.cyclomatic_complexity[i.strip()] = cycc

				if lines > 0 and METRIC_CYCLOMATIC_COMPLEXITY_DENSITY_THRESHOLD < cycc / float(lines):
					self.cyclomatic_complexity_density[i.strip()] = cycc / float(lines)
Ejemplo n.º 7
0
    def __init__(self):
        self.eloc = {}
        ls_tree_r = subprocess.Popen(
            "git ls-tree --name-only -r " + interval.get_ref(), shell=True, bufsize=1, stdout=subprocess.PIPE
        ).stdout

        for i in ls_tree_r.readlines():
            i = i.strip().decode("unicode_escape", "ignore")
            i = i.encode("latin-1", "replace")
            i = i.decode("utf-8", "replace").strip('"').strip("'").strip()

            if FileDiff.is_valid_extension(i) and not filtering.set_filtered(FileDiff.get_filename(i)):
                file_r = subprocess.Popen(
                    "git show " + interval.get_ref() + ":" + i.strip(), shell=True, bufsize=1, stdout=subprocess.PIPE
                ).stdout

                extension = FileDiff.get_extension(i)
                lines = MetricsLogic.get_eloc(file_r, extension)

                if __metric_eloc__.get(extension, None) != None and __metric_eloc__[extension] < lines:
                    self.eloc[i.strip()] = lines
Ejemplo n.º 8
0
    def __init__(self):
        self.eloc = {}
        ls_tree_r = subprocess.Popen("git ls-tree --name-only -r " +
                                     interval.get_ref(),
                                     shell=True,
                                     bufsize=1,
                                     stdout=subprocess.PIPE).stdout

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

            if FileDiff.is_valid_extension(i) and not filtering.set_filtered(
                    FileDiff.get_filename(i)):
                if not missing.add(i):
                    file_r = open(i.strip(), "rb")
                    extension = FileDiff.get_extension(i)
                    lines = MetricsLogic.get_eloc(file_r, extension)

                    if __metric_eloc__.get(
                            extension, None
                    ) != None and __metric_eloc__[extension] < lines:
                        self.eloc[i.strip()] = lines