mirror of
https://github.com/thomiceli/opengist.git
synced 2025-01-03 16:22:40 +00:00
Truncate diff
This commit is contained in:
parent
bd64922554
commit
b505f7147e
2 changed files with 12 additions and 1 deletions
|
@ -58,6 +58,7 @@ func parseLog(out io.Reader) []*Commit {
|
|||
var currentCommit *Commit
|
||||
var currentFile *File
|
||||
var isContent bool
|
||||
var bytesRead = 0
|
||||
|
||||
for scanner.Scan() {
|
||||
// new commit found
|
||||
|
@ -103,6 +104,7 @@ func parseLog(out io.Reader) []*Commit {
|
|||
|
||||
// create a new file
|
||||
isContent = false
|
||||
bytesRead = 0
|
||||
currentFile = &File{}
|
||||
filenameRegex := regexp.MustCompile(`^diff --git a/(.+) b/(.+)$`)
|
||||
matches := filenameRegex.FindStringSubmatch(string(line))
|
||||
|
@ -131,6 +133,13 @@ func parseLog(out io.Reader) []*Commit {
|
|||
|
||||
if isContent {
|
||||
currentFile.Content += string(line) + "\n"
|
||||
|
||||
bytesRead += len(line)
|
||||
if bytesRead > 2<<18 {
|
||||
currentFile.Truncated = true
|
||||
currentFile.Content = ""
|
||||
isContent = false
|
||||
}
|
||||
}
|
||||
|
||||
scanner.Scan()
|
||||
|
|
4
templates/pages/revisions.html
vendored
4
templates/pages/revisions.html
vendored
|
@ -39,7 +39,9 @@
|
|||
</p>
|
||||
</div>
|
||||
<div class="code overflow-auto">
|
||||
{{ if and (eq $file.Content "") (ne $file.OldFilename "") }}
|
||||
{{ if $file.Truncated }}
|
||||
<p class="m-2 ml-4 text-xs">Diff truncated because its too large to be shown</p>
|
||||
{{ else if and (eq $file.Content "") (ne $file.OldFilename "") }}
|
||||
<p class="m-2 ml-4 text-xs">File renamed without changes</p>
|
||||
{{ else if eq $file.Content "" }}
|
||||
<p class="m-2 ml-4 text-xs">Empty file</p>
|
||||
|
|
Loading…
Reference in a new issue