| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e836e5c commit 1faf84f
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,8 @@ Changelog | |||
| 5 | 5 | 2.0.4 - Fixes | |
| 6 | 6 | ============= | |
| 7 | 7 | ||
| 8 | + * Fix: non-ASCII paths are now properly decoded and returned in | ||
| 9 | + ``.diff()`` output | ||
| 8 | 10 | * Fix: `RemoteProgress` will now strip the ', ' prefix or suffix from messages. | |
| 9 | 11 | * API: Remote.[fetch|push|pull](...) methods now allow the ``progress`` argument to | |
| 10 | 12 | be a callable. This saves you from creating a custom type with usually just one | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,12 +15,23 @@ | |||
| 15 | 15 | PY3 | |
| 16 | 16 | ) | |
| 17 | 17 | ||
| 18 | - | ||
| 19 | 18 | __all__ = ('Diffable', 'DiffIndex', 'Diff', 'NULL_TREE') | |
| 20 | 19 | ||
| 21 | 20 | # Special object to compare against the empty tree in diffs | |
| 22 | 21 | NULL_TREE = object() | |
| 23 | 22 | ||
| 23 | + _octal_byte_re = re.compile(b'\\\\([0-9]{3})') | ||
| 24 | + | ||
| 25 | + | ||
| 26 | + def _octal_repl(matchobj): | ||
| 27 | + value = matchobj.group(1) | ||
| 28 | + value = int(value, 8) | ||
| 29 | + if PY3: | ||
| 30 | + value = bytes(bytearray((value,))) | ||
| 31 | + else: | ||
| 32 | + value = chr(value) | ||
| 33 | + return value | ||
| 34 | + | ||
| 24 | 35 | ||
| 25 | 36 | def decode_path(path, has_ab_prefix=True): | |
| 26 | 37 | if path == b'/dev/null': | |
@@ -32,6 +43,8 @@ def decode_path(path, has_ab_prefix=True): | |||
| 32 | 43 | .replace(b'\\"', b'"') | |
| 33 | 44 | .replace(b'\\\\', b'\\')) | |
| 34 | 45 | ||
| 46 | + path = _octal_byte_re.sub(_octal_repl, path) | ||
| 47 | + | ||
| 35 | 48 | if has_ab_prefix: | |
| 36 | 49 | assert path.startswith(b'a/') or path.startswith(b'b/') | |
| 37 | 50 | path = path[2:] | |
@@ -337,7 +350,7 @@ def renamed(self): | |||
| 337 | 350 | :note: This property is deprecated, please use ``renamed_file`` instead. | |
| 338 | 351 | """ | |
| 339 | 352 | return self.renamed_file | |
| 340 | - | ||
| 353 | + | ||
| 341 | 354 | @property | |
| 342 | 355 | def renamed_file(self): | |
| 343 | 356 | """:returns: True if the blob of our diff has been renamed | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -61,6 +61,13 @@ index 0000000000000000000000000000000000000000..eaf5f7510320b6a327fb308379de2f94 | |||
| 61 | 61 | +++ "b/path/¯\\_(ツ)_|¯" | |
| 62 | 62 | @@ -0,0 +1 @@ | |
| 63 | 63 | +dummy content | |
| 64 | + diff --git "a/path/\360\237\222\251.txt" "b/path/\360\237\222\251.txt" | ||
| 65 | + new file mode 100644 | ||
| 66 | + index 0000000000000000000000000000000000000000..eaf5f7510320b6a327fb308379de2f94d8859a54 | ||
| 67 | + --- /dev/null | ||
| 68 | + +++ "b/path/\360\237\222\251.txt" | ||
| 69 | + @@ -0,0 +1 @@ | ||
| 70 | + +dummy content | ||
| 64 | 71 | diff --git a/a/with spaces b/b/with some spaces | |
| 65 | 72 | similarity index 100% | |
| 66 | 73 | rename from a/with spaces | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -161,16 +161,17 @@ def test_diff_unsafe_paths(self): | |||
| 161 | 161 | self.assertEqual(res[6].b_path, u'path/with spaces') | |
| 162 | 162 | self.assertEqual(res[7].b_path, u'path/with-question-mark?') | |
| 163 | 163 | self.assertEqual(res[8].b_path, u'path/¯\\_(ツ)_|¯') | |
| 164 | + self.assertEqual(res[9].b_path, u'path/💩.txt') | ||
| 164 | 165 | ||
| 165 | 166 | # The "Moves" | |
| 166 | 167 | # NOTE: The path prefixes a/ and b/ here are legit! We're actually | |
| 167 | 168 | # verifying that it's not "a/a/" that shows up, see the fixture data. | |
| 168 | - self.assertEqual(res[9].a_path, u'a/with spaces') # NOTE: path a/ here legit! | ||
| 169 | - self.assertEqual(res[9].b_path, u'b/with some spaces') # NOTE: path b/ here legit! | ||
| 170 | - self.assertEqual(res[10].a_path, u'a/ending in a space ') | ||
| 171 | - self.assertEqual(res[10].b_path, u'b/ending with space ') | ||
| 172 | - self.assertEqual(res[11].a_path, u'a/"with-quotes"') | ||
| 173 | - self.assertEqual(res[11].b_path, u'b/"with even more quotes"') | ||
| 169 | + self.assertEqual(res[10].a_path, u'a/with spaces') # NOTE: path a/ here legit! | ||
| 170 | + self.assertEqual(res[10].b_path, u'b/with some spaces') # NOTE: path b/ here legit! | ||
| 171 | + self.assertEqual(res[11].a_path, u'a/ending in a space ') | ||
| 172 | + self.assertEqual(res[11].b_path, u'b/ending with space ') | ||
| 173 | + self.assertEqual(res[12].a_path, u'a/"with-quotes"') | ||
| 174 | + self.assertEqual(res[12].b_path, u'b/"with even more quotes"') | ||
| 174 | 175 | ||
| 175 | 176 | def test_diff_patch_format(self): | |
| 176 | 177 | # test all of the 'old' format diffs for completness - it should at least | |
| Back | FazBrowse Home | New Git URL |
0 commit comments