diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-04-17 17:27:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-17 10:27:25 +0100 |
commit | a3c4c57b7cc6c11b3a80622326b31a67bd1cc4d3 (patch) | |
tree | 760a51f88c2336073fe636e6a3e3869a559bcd82 /modules/gitgraph | |
parent | eee30d5586eb5501d6191bbb2280a9cab473bafb (diff) | |
download | gitea-a3c4c57b7cc6c11b3a80622326b31a67bd1cc4d3.tar.gz gitea-a3c4c57b7cc6c11b3a80622326b31a67bd1cc4d3.zip |
Fix bug on commit graph (#15517)
Diffstat (limited to 'modules/gitgraph')
-rw-r--r-- | modules/gitgraph/graph_models.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/modules/gitgraph/graph_models.go b/modules/gitgraph/graph_models.go index 2ae38188a6..ec47f0ad84 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, |