diff options
author | Alexey Terentyev <axifnx@gmail.com> | 2018-06-06 16:32:54 +0300 |
---|---|---|
committer | 无闻 <u@gogs.io> | 2018-06-06 21:32:54 +0800 |
commit | 4c844081f3f635f454e1040a568dc03f1a427f58 (patch) | |
tree | 353917fc0c08e76b192106fc9eb723b315f8361b | |
parent | 91441c3fb29d8ead645d8fffa4658d749d5b3fc3 (diff) |
routes/repo: added deletion of an empty line at the end of file (#5261) (#5270)
* Added deletion of an empty line at the end of file (#5261)
Signed-off-by: Alexey Terentyev <axifnx@gmail.com>
* Fix after feedback
Signed-off-by: Alexey Terentyev <axifnx@gmail.com>
-rw-r--r-- | routes/repo/view.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/routes/repo/view.go b/routes/repo/view.go index f34ed677..7c15af8f 100644 --- a/routes/repo/view.go +++ b/routes/repo/view.go @@ -185,6 +185,10 @@ func renderFile(c *context.Context, entry *git.TreeEntry, treeLink, rawLink stri var output bytes.Buffer lines := strings.Split(fileContent, "\n") + // Remove blank line at the end of file + if len(lines) > 0 && len(lines[len(lines)-1])==0 { + lines = lines[:len(lines)-1] + } for index, line := range lines { output.WriteString(fmt.Sprintf(`<li class="L%d" rel="L%d">%s</li>`, index+1, index+1, gotemplate.HTMLEscapeString(strings.TrimRight(line, "\r"))) + "\n") } |