From eff2499be7202e8328c451fc41a630ab62d08ebd Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 17 Apr 2021 20:46:30 +0800 Subject: [PATCH] Fix bug on commit graph (#15517) (#15530) --- modules/gitgraph/graph_models.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/gitgraph/graph_models.go b/modules/gitgraph/graph_models.go index 2ae38188a..ec47f0ad8 100644 --- a/modules/gitgraph/graph_models.go +++ b/modules/gitgraph/graph_models.go @@ -7,6 +7,7 @@ package gitgraph import ( "bytes" "fmt" + "strings" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/git" @@ -216,10 +217,10 @@ func newRefsFromRefNames(refNames []byte) []git.Reference { continue } refName := string(refNameBytes) - if refName[0:5] == "tag: " { - refName = refName[5:] - } else if refName[0:8] == "HEAD -> " { - refName = refName[8:] + if strings.HasPrefix(refName, "tag: ") { + refName = strings.TrimPrefix(refName, "tag: ") + } else if strings.HasPrefix(refName, "HEAD -> ") { + refName = strings.TrimPrefix(refName, "HEAD -> ") } refs = append(refs, git.Reference{ Name: refName,