1
0
forked from VimPlug/jedi

Refactoring diffs now show relative paths

This commit is contained in:
Dave Halter
2020-02-27 23:23:24 +01:00
parent 0ef8053919
commit 4451d2fec7
3 changed files with 78 additions and 78 deletions

View File

@@ -1,4 +1,4 @@
from os.path import dirname, basename, join
from os.path import dirname, basename, join, relpath
import os
import re
import difflib
@@ -26,8 +26,8 @@ class ChangedFile(object):
new_lines = split_lines(self.get_new_code(), keepends=True)
diff = difflib.unified_diff(
old_lines, new_lines,
fromfile=self._from_path,
tofile=self._to_path
fromfile=relpath(self._from_path),
tofile=relpath(self._to_path),
)
# Apparently there's a space at the end of the diff - for whatever
# reason.
@@ -90,7 +90,7 @@ class Refactoring(object):
def get_diff(self):
text = ''
for from_, to in self.get_renames():
text += 'rename from %s\nrename to %s\n' % (from_, to)
text += 'rename from %s\nrename to %s\n' % (relpath(from_), relpath(to))
return text + ''.join(f.get_diff() for f in self.get_changed_files().values())