From 5f26ebc3899310d4a5c1aa2710c980dfd37e0919 Mon Sep 17 00:00:00 2001 From: Alexey Terentyev Date: Sun, 27 May 2018 02:52:23 +0300 Subject: [PATCH] Added deletion of an empty line at the end of the file (#4050) Signed-off-by: Alexey Terentyev --- routers/repo/view.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/routers/repo/view.go b/routers/repo/view.go index ca2ece648f41c..d2efe30096733 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -223,6 +223,10 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st var output bytes.Buffer lines := strings.Split(fileContent, "\n") + //Remove blank line at the end of file + if len(lines) > 0 && lines[len(lines)-1] == "" { + lines = lines[:len(lines)-1] + } for index, line := range lines { line = gotemplate.HTMLEscapeString(line) if index != len(lines)-1 {