#3434 Fix splitting the diff per file
Merged 6 years ago by pingou. Opened 6 years ago by pingou.

file modified
+5 -3
@@ -86,9 +86,11 @@ 

  

          if diff_view:

              if separated:

-                 for el in diff.patch.split('diff --git a/'):

-                     if el:

-                         patch.append('diff --git a/' + el)

+                 for el in diff.patch.split('\ndiff --git a/'):

+                     if el and not el.startswith('diff --git a/'):

+                         patch.append('\ndiff --git a/' + el)

+                     elif el:

+                         patch.append(el)

              else:

                  patch.append(diff.patch)

          else:

Basically, when rendering diffs, we split them by file so we can render
the changes made to each file separately.
However, if one of the file happens to contain a diff itself (for example
if that file is a patch), then we don't want to split that, it'll make a
mess.
So rather than splitting on "diff --git a/" we ensure we're spliting on new
lines starting with this by splitting on "\ndiff --git a/".

Fixes https://pagure.io/pagure/issue/3426

Signed-off-by: Pierre-Yves Chibon pingou@pingoured.fr

@pingou Tests for this functionality need to be fixed.

Indeed, thanks for pointing it out

rebased onto 2596638cadb6da90a50f212bddd4fb666ddf6b9f

6 years ago

Turns out the issue wasn't in the code but in the logic, so the logic has been adjusted :)

rebased onto ea9ae020abbcb03189c167350d4aff4834c3242b

6 years ago

Pretty please pagure-ci rebuild

I ran them locally and they pass, but there is a bug in 4.0.3 (fixed in 4.0.4) that doesn't trigger jenkins on new commits/rebases.

rebased onto ed25f0a

6 years ago

Pretty please pagure-ci rebuild

Pull-Request has been merged by pingou

6 years ago