|
52 | 52 |
|
53 | 53 | SERIES_DELAY_INTERVAL = 10 |
54 | 54 |
|
| 55 | +# @see https://git-scm.com/docs/git-diff#_generating_patches_with_p |
| 56 | +EXTENDED_HEADER_LINES = ( |
| 57 | + 'old mode ', 'new mode ', |
| 58 | + 'deleted file mode ', 'new file mode ', |
| 59 | + 'copy from ', 'copy to ', |
| 60 | + 'rename from ', 'rename to ', |
| 61 | + 'similarity index ', 'dissimilarity index ', |
| 62 | + 'new file mode ', 'index ') |
| 63 | + |
55 | 64 | logger = logging.getLogger(__name__) |
56 | 65 |
|
57 | 66 |
|
@@ -789,17 +798,7 @@ def parse_patch(content): |
789 | 798 | buf += line |
790 | 799 | if line.startswith('--- '): |
791 | 800 | state = 2 |
792 | | - |
793 | | - # extended header lines |
794 | | - # @see https://git-scm.com/docs/git-diff#_generating_patches_with_p |
795 | | - if line.startswith(('old mode ', 'new mode ', |
796 | | - 'deleted file mode ', |
797 | | - 'new file mode ', |
798 | | - 'copy from ', 'copy to ', |
799 | | - 'rename from ', 'rename to ', |
800 | | - 'similarity index ', |
801 | | - 'dissimilarity index ', |
802 | | - 'new file mode ', 'index ')): |
| 801 | + if line.startswith(EXTENDED_HEADER_LINES): |
803 | 802 | state = 6 |
804 | 803 | elif state == 2: |
805 | 804 | if line.startswith('+++ '): |
@@ -860,16 +859,7 @@ def fn(x): |
860 | 859 | else: |
861 | 860 | state = 5 |
862 | 861 | elif state == 6: |
863 | | - # extended header lines |
864 | | - # @see https://git-scm.com/docs/git-diff#_generating_patches_with_p |
865 | | - if line.startswith(('old mode ', 'new mode ', |
866 | | - 'deleted file mode ', |
867 | | - 'new file mode ', |
868 | | - 'copy from ', 'copy to ', |
869 | | - 'rename from ', 'rename to ', |
870 | | - 'similarity index ', |
871 | | - 'dissimilarity index ', |
872 | | - 'new file mode ', 'index ')): |
| 862 | + if line.startswith(EXTENDED_HEADER_LINES): |
873 | 863 | patchbuf += buf + line |
874 | 864 | buf = '' |
875 | 865 | elif line.startswith('--- '): |
|
0 commit comments