Don't copy directory and component experience on file copy (#814)

A developer shouldn't automatically gain a lot of experience
in a directory just because they moved a file from a directory
to another.
This commit is contained in:
calixteman 2019-07-31 16:26:00 +02:00 коммит произвёл Marco
Родитель 9711d9fc31
Коммит d644aa9725
1 изменённых файлов: 10 добавлений и 42 удалений

Просмотреть файл

@ -570,48 +570,16 @@ def calculate_experiences(commits, commits_to_ignore, first_pushdate, save=True)
assert day >= 0
# When a file is moved/copied, copy original experience values to the copied path.
if len(commit.file_copies) > 0:
for orig, copied in commit.file_copies.items():
orig_directories = get_directories(orig)
copied_directories = get_directories(copied)
for commit_type in ["", "backout"]:
for orig_directory, copied_directory in zip(
orig_directories, copied_directories
):
if orig_directory in experiences["directory"][commit_type]:
experiences["directory"][commit_type][
copied_directory
] = copy.deepcopy(
experiences["directory"][commit_type][orig_directory]
)
else:
print(
f"Experience missing for directory {orig_directory}, type '{commit_type}', on commit {commit.node}"
)
if orig in path_to_component and copied in path_to_component:
orig_component = path_to_component[orig]
copied_component = path_to_component[copied]
if orig_component in experiences["component"][commit_type]:
experiences["component"][commit_type][
copied_component
] = copy.deepcopy(
experiences["component"][commit_type][orig_component]
)
else:
print(
f"Experience missing for component {orig_component}, type '{commit_type}', on commit {commit.node}"
)
if orig in experiences["file"][commit_type]:
experiences["file"][commit_type][copied] = copy.deepcopy(
experiences["file"][commit_type][orig]
)
else:
print(
f"Experience missing for file {orig}, type '{commit_type}', on commit {commit.node}"
)
for orig, copied in commit.file_copies.items():
for commit_type in ["", "backout"]:
if orig in experiences["file"][commit_type]:
experiences["file"][commit_type][copied] = copy.deepcopy(
experiences["file"][commit_type][orig]
)
else:
print(
f"Experience missing for file {orig}, type '{commit_type}', on commit {commit.node}"
)
if commit not in commits_to_ignore:
update_experiences("author", day, [commit.author])