Skip to content

Commit 79ff8ee

Browse files
committed
fix
1 parent 594edad commit 79ff8ee

File tree

26 files changed

+199
-140
lines changed

26 files changed

+199
-140
lines changed

models/actions/run.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ func InsertRun(ctx context.Context, run *ActionRun, jobs []*jobparser.SingleWork
275275
return err
276276
}
277277
run.Index = index
278-
run.Title, _ = util.SplitStringAtByteN(run.Title, 255)
278+
run.Title = util.EllipsisDisplayString(run.Title, 255)
279279

280280
if err := db.Insert(ctx, run); err != nil {
281281
return err
@@ -308,7 +308,7 @@ func InsertRun(ctx context.Context, run *ActionRun, jobs []*jobparser.SingleWork
308308
} else {
309309
hasWaiting = true
310310
}
311-
job.Name, _ = util.SplitStringAtByteN(job.Name, 255)
311+
job.Name = util.EllipsisDisplayString(job.Name, 255)
312312
runJobs = append(runJobs, &ActionRunJob{
313313
RunID: run.ID,
314314
RepoID: run.RepoID,
@@ -402,7 +402,7 @@ func UpdateRun(ctx context.Context, run *ActionRun, cols ...string) error {
402402
if len(cols) > 0 {
403403
sess.Cols(cols...)
404404
}
405-
run.Title, _ = util.SplitStringAtByteN(run.Title, 255)
405+
run.Title = util.EllipsisDisplayString(run.Title, 255)
406406
affected, err := sess.Update(run)
407407
if err != nil {
408408
return err

models/actions/runner.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ func GetRunnerByID(ctx context.Context, id int64) (*ActionRunner, error) {
252252
// UpdateRunner updates runner's information.
253253
func UpdateRunner(ctx context.Context, r *ActionRunner, cols ...string) error {
254254
e := db.GetEngine(ctx)
255-
r.Name, _ = util.SplitStringAtByteN(r.Name, 255)
255+
r.Name = util.EllipsisDisplayString(r.Name, 255)
256256
var err error
257257
if len(cols) == 0 {
258258
_, err = e.ID(r.ID).AllCols().Update(r)
@@ -279,7 +279,7 @@ func CreateRunner(ctx context.Context, t *ActionRunner) error {
279279
// Remove OwnerID to avoid confusion; it's not worth returning an error here.
280280
t.OwnerID = 0
281281
}
282-
t.Name, _ = util.SplitStringAtByteN(t.Name, 255)
282+
t.Name = util.EllipsisDisplayString(t.Name, 255)
283283
return db.Insert(ctx, t)
284284
}
285285

models/actions/runner_token.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"code.gitea.io/gitea/models/db"
1111
repo_model "code.gitea.io/gitea/models/repo"
1212
user_model "code.gitea.io/gitea/models/user"
13-
"code.gitea.io/gitea/modules/base"
1413
"code.gitea.io/gitea/modules/timeutil"
1514
"code.gitea.io/gitea/modules/util"
1615
)
@@ -52,7 +51,7 @@ func GetRunnerToken(ctx context.Context, token string) (*ActionRunnerToken, erro
5251
if err != nil {
5352
return nil, err
5453
} else if !has {
55-
return nil, fmt.Errorf(`runner token "%s...": %w`, base.TruncateString(token, 3), util.ErrNotExist)
54+
return nil, fmt.Errorf(`runner token "%s...": %w`, util.TruncateRunes(token, 3), util.ErrNotExist)
5655
}
5756
return &runnerToken, nil
5857
}

models/actions/schedule.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func CreateScheduleTask(ctx context.Context, rows []*ActionSchedule) error {
6868

6969
// Loop through each schedule row
7070
for _, row := range rows {
71-
row.Title, _ = util.SplitStringAtByteN(row.Title, 255)
71+
row.Title = util.EllipsisDisplayString(row.Title, 255)
7272
// Create new schedule row
7373
if err = db.Insert(ctx, row); err != nil {
7474
return err

models/actions/task.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
298298
if len(workflowJob.Steps) > 0 {
299299
steps := make([]*ActionTaskStep, len(workflowJob.Steps))
300300
for i, v := range workflowJob.Steps {
301-
name, _ := util.SplitStringAtByteN(v.String(), 255)
301+
name := util.EllipsisDisplayString(v.String(), 255)
302302
steps[i] = &ActionTaskStep{
303303
Name: name,
304304
TaskID: task.ID,

models/activities/action.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ import (
2020
repo_model "code.gitea.io/gitea/models/repo"
2121
"code.gitea.io/gitea/models/unit"
2222
user_model "code.gitea.io/gitea/models/user"
23-
"code.gitea.io/gitea/modules/base"
2423
"code.gitea.io/gitea/modules/git"
2524
"code.gitea.io/gitea/modules/log"
2625
"code.gitea.io/gitea/modules/setting"
2726
"code.gitea.io/gitea/modules/structs"
2827
"code.gitea.io/gitea/modules/timeutil"
28+
"code.gitea.io/gitea/modules/util"
2929

3030
"xorm.io/builder"
3131
"xorm.io/xorm/schemas"
@@ -226,7 +226,7 @@ func (a *Action) GetActUserName(ctx context.Context) string {
226226
// ShortActUserName gets the action's user name trimmed to max 20
227227
// chars.
228228
func (a *Action) ShortActUserName(ctx context.Context) string {
229-
return base.EllipsisString(a.GetActUserName(ctx), 20)
229+
return util.EllipsisDisplayString(a.GetActUserName(ctx), 20)
230230
}
231231

232232
// GetActDisplayName gets the action's display name based on DEFAULT_SHOW_FULL_NAME, or falls back to the username if it is blank.
@@ -260,7 +260,7 @@ func (a *Action) GetRepoUserName(ctx context.Context) string {
260260
// ShortRepoUserName returns the name of the action repository owner
261261
// trimmed to max 20 chars.
262262
func (a *Action) ShortRepoUserName(ctx context.Context) string {
263-
return base.EllipsisString(a.GetRepoUserName(ctx), 20)
263+
return util.EllipsisDisplayString(a.GetRepoUserName(ctx), 20)
264264
}
265265

266266
// GetRepoName returns the name of the action repository.
@@ -275,7 +275,7 @@ func (a *Action) GetRepoName(ctx context.Context) string {
275275
// ShortRepoName returns the name of the action repository
276276
// trimmed to max 33 chars.
277277
func (a *Action) ShortRepoName(ctx context.Context) string {
278-
return base.EllipsisString(a.GetRepoName(ctx), 33)
278+
return util.EllipsisDisplayString(a.GetRepoName(ctx), 33)
279279
}
280280

281281
// GetRepoPath returns the virtual path to the action repository.

models/issues/issue_update.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func ChangeIssueTitle(ctx context.Context, issue *Issue, doer *user_model.User,
177177
}
178178
defer committer.Close()
179179

180-
issue.Title, _ = util.SplitStringAtByteN(issue.Title, 255)
180+
issue.Title = util.EllipsisDisplayString(issue.Title, 255)
181181
if err = UpdateIssueCols(ctx, issue, "name"); err != nil {
182182
return fmt.Errorf("updateIssueCols: %w", err)
183183
}
@@ -440,7 +440,7 @@ func NewIssue(ctx context.Context, repo *repo_model.Repository, issue *Issue, la
440440
}
441441

442442
issue.Index = idx
443-
issue.Title, _ = util.SplitStringAtByteN(issue.Title, 255)
443+
issue.Title = util.EllipsisDisplayString(issue.Title, 255)
444444

445445
if err = NewIssueWithIndex(ctx, issue.Poster, NewIssueOptions{
446446
Repo: repo,

models/issues/pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ func NewPullRequest(ctx context.Context, repo *repo_model.Repository, issue *Iss
572572
}
573573

574574
issue.Index = idx
575-
issue.Title, _ = util.SplitStringAtByteN(issue.Title, 255)
575+
issue.Title = util.EllipsisDisplayString(issue.Title, 255)
576576

577577
if err = NewIssueWithIndex(ctx, issue.Poster, NewIssueOptions{
578578
Repo: repo,

models/project/project.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ func NewProject(ctx context.Context, p *Project) error {
256256
return util.NewInvalidArgumentErrorf("project type is not valid")
257257
}
258258

259-
p.Title, _ = util.SplitStringAtByteN(p.Title, 255)
259+
p.Title = util.EllipsisDisplayString(p.Title, 255)
260260

261261
return db.WithTx(ctx, func(ctx context.Context) error {
262262
if err := db.Insert(ctx, p); err != nil {
@@ -311,7 +311,7 @@ func UpdateProject(ctx context.Context, p *Project) error {
311311
p.CardType = CardTypeTextOnly
312312
}
313313

314-
p.Title, _ = util.SplitStringAtByteN(p.Title, 255)
314+
p.Title = util.EllipsisDisplayString(p.Title, 255)
315315
_, err := db.GetEngine(ctx).ID(p.ID).Cols(
316316
"title",
317317
"description",

models/repo/release.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func IsReleaseExist(ctx context.Context, repoID int64, tagName string) (bool, er
156156

157157
// UpdateRelease updates all columns of a release
158158
func UpdateRelease(ctx context.Context, rel *Release) error {
159-
rel.Title, _ = util.SplitStringAtByteN(rel.Title, 255)
159+
rel.Title = util.EllipsisDisplayString(rel.Title, 255)
160160
_, err := db.GetEngine(ctx).ID(rel.ID).AllCols().Update(rel)
161161
return err
162162
}

0 commit comments

Comments
 (0)