]> source.dussan.org Git - gitea.git/commitdiff
Fix bug in commit verification introduced in #13673 (#14040)
authorzeripath <art27@cantab.net>
Thu, 17 Dec 2020 20:42:33 +0000 (20:42 +0000)
committerGitHub <noreply@github.com>
Thu, 17 Dec 2020 20:42:33 +0000 (21:42 +0100)
There is a slight bug in the commit_reader introduced in #13673 whereby
commit messages which have a final unterminated line miss their final line.

This PR fixes this.

Signed-off-by: Andrew Thornton <art27@cantab.net>
modules/git/commit_reader.go

index 4eb861040e62fb7b299abcf53e7d08ee8702784a..a4d15b6bada732d26f0f547e95d8f1fbe8134ea3 100644 (file)
@@ -36,6 +36,10 @@ readLoop:
                line, err := bufReader.ReadBytes('\n')
                if err != nil {
                        if err == io.EOF {
+                               if message {
+                                       _, _ = messageSB.Write(line)
+                               }
+                               _, _ = payloadSB.Write(line)
                                break readLoop
                        }
                        return nil, err
@@ -86,10 +90,10 @@ readLoop:
                        }
                } else {
                        _, _ = messageSB.Write(line)
+                       _, _ = payloadSB.Write(line)
                }
        }
        commit.CommitMessage = messageSB.String()
-       _, _ = payloadSB.WriteString(commit.CommitMessage)
        commit.Signature = &CommitGPGSignature{
                Signature: signatureSB.String(),
                Payload:   payloadSB.String(),