Skip to content

Commit

Permalink
FilenameBear: Don't make diff if changes are same
Browse files Browse the repository at this point in the history
Don't make `Diff()` if the new name and the old name are same.

Closes #2578
  • Loading branch information
refeed committed Jul 4, 2018
1 parent b51144b commit c83e4f4
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions bears/general/FilenameBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,13 @@ def run(self, filename, file,
return

if messages:
diff = Diff(file, rename=os.path.join(head, new_name + extension))
message = ('\n'.join('- ' + mes for mes in messages)
if len(messages) > 1 else messages[0])
result_kwargs = dict(message=message, file=filename)

yield Result(
self,
message,
diff.affected_code(filename),
diffs={filename: diff})
if new_name != filename_without_extension:
diff = Diff(file,
rename=os.path.join(head, new_name + extension))
result_kwargs['diffs'] = {filename: diff}

yield Result.from_values(self, **result_kwargs)

0 comments on commit c83e4f4

Please sign in to comment.