Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
mod.change_type == ModificationType.DELETE:
path = mod.old_path
deleted_lines = self.parse_diff(mod.diff)['deleted']
try:
blame = self._get_blame(commit.hash, path,
hashes_to_ignore_path)
for num_line, line in deleted_lines:
if not self._useless_line(line.strip()):
buggy_commit = blame[num_line - 1].split(' ')[
0].replace('^', '')
# Skip unblamable lines.
if buggy_commit.startswith("*"):
continue
if mod.change_type == ModificationType.RENAME:
path = mod.new_path
commits.setdefault(path, set()).add(
self.get_commit(buggy_commit).hash)
except GitCommandError:
logger.debug(
"Could not found file %s in commit %s. Probably a double "
"rename!", mod.filename, commit.hash)
return commits
:return: int number of commits made to the file
"""
filepath = str(Path(filepath))
count = 0
for commit in RepositoryMining(path_to_repo, from_commit=from_commit,
to_commit=to_commit,
reversed_order=True).traverse_commits():
for modified_file in commit.modifications:
if filepath in (modified_file.new_path,
modified_file.old_path):
count += 1
if modified_file.change_type == ModificationType.RENAME:
filepath = str(Path(modified_file.old_path))
break
return count