1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Refactor "string truncate" (#32984)

This commit is contained in:
wxiaoguang
2024-12-26 11:56:03 +08:00
committed by GitHub
parent 594edad213
commit 9bfa9f450d
26 changed files with 199 additions and 140 deletions

View File

@@ -69,7 +69,7 @@ func (s *Service) Register(
labels := req.Msg.Labels
// create new runner
name, _ := util.SplitStringAtByteN(req.Msg.Name, 255)
name := util.EllipsisDisplayString(req.Msg.Name, 255)
runner := &actions_model.ActionRunner{
UUID: gouuid.New().String(),
Name: name,

View File

@@ -664,7 +664,7 @@ func PrepareCompareDiff(
}
if len(title) > 255 {
var trailer string
title, trailer = util.SplitStringAtByteN(title, 255)
title, trailer = util.EllipsisDisplayStringX(title, 255)
if len(trailer) > 0 {
if ctx.Data["content"] != nil {
ctx.Data["content"] = fmt.Sprintf("%s\n\n%s", trailer, ctx.Data["content"])