Skip to content

Commit bdd5c10

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: [skip ci] Updated translations via Crowdin Improve Actions test (go-gitea#32883) Support org labels when adding labels by label names (go-gitea#32988) Add `show more` organizations icon in user's profile (go-gitea#32986) Improve "ellipsis string" (go-gitea#32989) Refactor "string truncate" (go-gitea#32984)
2 parents 0fb6f40 + 3c00e89 commit bdd5c10

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1087
-173
lines changed

custom/conf/app.example.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,9 @@ LEVEL = Info
13391339
;; Number of repos that are displayed on one page
13401340
;REPO_PAGING_NUM = 15
13411341

1342+
;; Number of orgs that are displayed on profile page
1343+
;ORG_PAGING_NUM = 15
1344+
13421345
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13431346
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13441347
;[ui.meta]

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/fixtures/label.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,14 @@
9696
num_issues: 0
9797
num_closed_issues: 0
9898
archived_unix: 0
99+
100+
-
101+
id: 10
102+
repo_id: 3
103+
org_id: 0
104+
name: repo3label1
105+
color: '#112233'
106+
exclusive: false
107+
num_issues: 0
108+
num_closed_issues: 0
109+
archived_unix: 0

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/label.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,17 @@ func GetLabelIDsInRepoByNames(ctx context.Context, repoID int64, labelNames []st
349349
Find(&labelIDs)
350350
}
351351

352+
// GetLabelIDsInOrgByNames returns a list of labelIDs by names in a given org.
353+
func GetLabelIDsInOrgByNames(ctx context.Context, orgID int64, labelNames []string) ([]int64, error) {
354+
labelIDs := make([]int64, 0, len(labelNames))
355+
return labelIDs, db.GetEngine(ctx).Table("label").
356+
Where("org_id = ?", orgID).
357+
In("name", labelNames).
358+
Asc("name").
359+
Cols("id").
360+
Find(&labelIDs)
361+
}
362+
352363
// BuildLabelNamesIssueIDsCondition returns a builder where get issue ids match label names
353364
func BuildLabelNamesIssueIDsCondition(labelNames []string) *builder.Builder {
354365
return builder.Select("issue_label.issue_id").

0 commit comments

Comments
 (0)