Author | Jakob Wakeling <[email protected]> |
Date | 2023-12-25 08:16:12 |
Commit | 43a7c2cb71f267e0ea76a78bb81696c5b3c06953 |
Parent | 28a8f1350e700754422e9fb338cd5021b529d9a8 |
Fix enabled next button on empty repository log
Diffstat
M | res/repo/log.html | | | 2 | +- |
M | src/repo/log.go | | | 10 | ++++++++-- |
2 files changed, 9 insertions, 3 deletions
diff --git a/res/repo/log.html b/res/repo/log.html index 24ea16c..e5331f0 100644 --- a/res/repo/log.html +++ b/res/repo/log.html @@ -40,7 +40,7 @@ <span>[prev]</span> {{end}} <span>{{.Page}}</span> - {{if .NextOffset}} + {{if gt .NextOffset 0}} <a href="/{{$.Name}}/log?o={{.NextOffset}}">[next]</a> {{else}} <span>[next]</span> diff --git a/src/repo/log.go b/src/repo/log.go index 45b38f4..4c14f4a 100644 --- a/src/repo/log.go +++ b/src/repo/log.go @@ -76,6 +76,7 @@ func HandleLog(w http.ResponseWriter, r *http.Request) { ref, err := gr.Head() if errors.Is(err, plumbing.ErrReferenceNotFound) { + data.NextOffset = 0 goto execute } else if err != nil { log.Println("[/repo/log]", err.Error()) @@ -100,7 +101,12 @@ func HandleLog(w http.ResponseWriter, r *http.Request) { return } else { for i := int64(0); i < offset; i += 1 { - if _, err := iter.Next(); err != nil && !errors.Is(err, io.EOF) { + if _, err := iter.Next(); err != nil { + if errors.Is(err, io.EOF) { + data.NextOffset = 0 + goto execute + } + log.Println("[/repo/log]", err.Error()) goit.HttpError(w, http.StatusInternalServerError) return @@ -111,7 +117,7 @@ func HandleLog(w http.ResponseWriter, r *http.Request) { c, err := iter.Next() if errors.Is(err, io.EOF) { data.NextOffset = 0 - break + goto execute } else if err != nil { log.Println("[/repo/log]", err.Error()) goit.HttpError(w, http.StatusInternalServerError)