Skip to content

Commit 577c988

Browse files
committed
Add more trims
1 parent 91b5c27 commit 577c988

File tree

5 files changed

+7
-0
lines changed

5 files changed

+7
-0
lines changed

models/actions/run.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ func UpdateRun(ctx context.Context, run *ActionRun, cols ...string) error {
401401
if len(cols) > 0 {
402402
sess.Cols(cols...)
403403
}
404+
run.Title, _ = util.SplitStringAtByteN(run.Title, 255)
404405
affected, err := sess.Update(run)
405406
if err != nil {
406407
return err

models/actions/runner.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +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)
255256
var err error
256257
if len(cols) == 0 {
257258
_, err = e.ID(r.ID).AllCols().Update(r)
@@ -278,6 +279,7 @@ func CreateRunner(ctx context.Context, t *ActionRunner) error {
278279
// Remove OwnerID to avoid confusion; it's not worth returning an error here.
279280
t.OwnerID = 0
280281
}
282+
t.Name, _ = util.SplitStringAtByteN(t.Name, 255)
281283
return db.Insert(ctx, t)
282284
}
283285

models/actions/schedule.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
repo_model "code.gitea.io/gitea/models/repo"
1313
user_model "code.gitea.io/gitea/models/user"
1414
"code.gitea.io/gitea/modules/timeutil"
15+
"code.gitea.io/gitea/modules/util"
1516
webhook_module "code.gitea.io/gitea/modules/webhook"
1617
)
1718

@@ -67,6 +68,7 @@ func CreateScheduleTask(ctx context.Context, rows []*ActionSchedule) error {
6768

6869
// Loop through each schedule row
6970
for _, row := range rows {
71+
row.Title, _ = util.SplitStringAtByteN(row.Title, 255)
7072
// Create new schedule row
7173
if err = db.Insert(ctx, row); err != nil {
7274
return err

models/issues/issue_update.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ func ChangeIssueTitle(ctx context.Context, issue *Issue, doer *user_model.User,
139139
}
140140
defer committer.Close()
141141

142+
issue.Title, _ = util.SplitStringAtByteN(issue.Title, 255)
142143
if err = UpdateIssueCols(ctx, issue, "name"); err != nil {
143144
return fmt.Errorf("updateIssueCols: %w", err)
144145
}

models/project/project.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ func UpdateProject(ctx context.Context, p *Project) error {
311311
p.CardType = CardTypeTextOnly
312312
}
313313

314+
p.Title, _ = util.SplitStringAtByteN(p.Title, 255)
314315
_, err := db.GetEngine(ctx).ID(p.ID).Cols(
315316
"title",
316317
"description",

0 commit comments

Comments
 (0)