Skip to content

Commit 2383151

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Enhance routers for the Actions runner operations (go-gitea#33549) [skip ci] Updated translations via Crowdin Run yamllint with strict mode, fix issue (go-gitea#33551) Enhance routers for the Actions variable operations (go-gitea#33547) enhancement: add additional command hints for PowerShell & CMD (go-gitea#33548) Feature: Support workflow event dispatch via API (go-gitea#33545) Optimize the dashboard (go-gitea#32990) Rework suggestion backend (go-gitea#33538) Revert "Feature: Support workflow event dispatch via API (go-gitea#32059)" (go-gitea#33541)
2 parents a32db18 + e9b98ae commit 2383151

Some content is hidden

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

64 files changed

+1327
-699
lines changed

.github/workflows/cron-licenses.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: cron-licenses
22

33
on:
4-
#schedule:
5-
# - cron: "7 0 * * 1" # every Monday at 00:07 UTC
4+
# schedule:
5+
# - cron: "7 0 * * 1" # every Monday at 00:07 UTC
66
workflow_dispatch:
77

88
jobs:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ lint-templates: .venv node_modules ## lint template files
393393

394394
.PHONY: lint-yaml
395395
lint-yaml: .venv ## lint yaml files
396-
@poetry run yamllint .
396+
@poetry run yamllint -s .
397397

398398
.PHONY: watch
399399
watch: ## watch everything and continuously rebuild

models/actions/runner.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ func init() {
167167

168168
type FindRunnerOptions struct {
169169
db.ListOptions
170+
IDs []int64
170171
RepoID int64
171172
OwnerID int64 // it will be ignored if RepoID is set
172173
Sort string
@@ -178,6 +179,14 @@ type FindRunnerOptions struct {
178179
func (opts FindRunnerOptions) ToConds() builder.Cond {
179180
cond := builder.NewCond()
180181

182+
if len(opts.IDs) > 0 {
183+
if len(opts.IDs) == 1 {
184+
cond = cond.And(builder.Eq{"id": opts.IDs[0]})
185+
} else {
186+
cond = cond.And(builder.In("id", opts.IDs))
187+
}
188+
}
189+
181190
if opts.RepoID > 0 {
182191
c := builder.NewCond().And(builder.Eq{"repo_id": opts.RepoID})
183192
if opts.WithAvailable {

models/actions/variable.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,23 @@ func InsertVariable(ctx context.Context, ownerID, repoID int64, name, data strin
5858

5959
type FindVariablesOpts struct {
6060
db.ListOptions
61+
IDs []int64
6162
RepoID int64
6263
OwnerID int64 // it will be ignored if RepoID is set
6364
Name string
6465
}
6566

6667
func (opts FindVariablesOpts) ToConds() builder.Cond {
6768
cond := builder.NewCond()
69+
70+
if len(opts.IDs) > 0 {
71+
if len(opts.IDs) == 1 {
72+
cond = cond.And(builder.Eq{"id": opts.IDs[0]})
73+
} else {
74+
cond = cond.And(builder.In("id", opts.IDs))
75+
}
76+
}
77+
6878
// Since we now support instance-level variables,
6979
// there is no need to check for null values for `owner_id` and `repo_id`
7080
cond = cond.And(builder.Eq{"repo_id": opts.RepoID})
@@ -85,12 +95,12 @@ func FindVariables(ctx context.Context, opts FindVariablesOpts) ([]*ActionVariab
8595
return db.Find[ActionVariable](ctx, opts)
8696
}
8797

88-
func UpdateVariable(ctx context.Context, variable *ActionVariable) (bool, error) {
89-
count, err := db.GetEngine(ctx).ID(variable.ID).Cols("name", "data").
90-
Update(&ActionVariable{
91-
Name: variable.Name,
92-
Data: variable.Data,
93-
})
98+
func UpdateVariableCols(ctx context.Context, variable *ActionVariable, cols ...string) (bool, error) {
99+
variable.Name = strings.ToUpper(variable.Name)
100+
count, err := db.GetEngine(ctx).
101+
ID(variable.ID).
102+
Cols(cols...).
103+
Update(variable)
94104
return count != 0, err
95105
}
96106

models/issues/issue.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
user_model "code.gitea.io/gitea/models/user"
1818
"code.gitea.io/gitea/modules/container"
1919
"code.gitea.io/gitea/modules/log"
20+
"code.gitea.io/gitea/modules/optional"
2021
"code.gitea.io/gitea/modules/setting"
2122
api "code.gitea.io/gitea/modules/structs"
2223
"code.gitea.io/gitea/modules/timeutil"
@@ -501,6 +502,45 @@ func GetIssueByIndex(ctx context.Context, repoID, index int64) (*Issue, error) {
501502
return issue, nil
502503
}
503504

505+
func isPullToCond(isPull optional.Option[bool]) builder.Cond {
506+
if isPull.Has() {
507+
return builder.Eq{"is_pull": isPull.Value()}
508+
}
509+
return builder.NewCond()
510+
}
511+
512+
func FindLatestUpdatedIssues(ctx context.Context, repoID int64, isPull optional.Option[bool], pageSize int) (IssueList, error) {
513+
issues := make([]*Issue, 0, pageSize)
514+
err := db.GetEngine(ctx).Where("repo_id = ?", repoID).
515+
And(isPullToCond(isPull)).
516+
OrderBy("updated_unix DESC").
517+
Limit(pageSize).
518+
Find(&issues)
519+
return issues, err
520+
}
521+
522+
func FindIssuesSuggestionByKeyword(ctx context.Context, repoID int64, keyword string, isPull optional.Option[bool], excludedID int64, pageSize int) (IssueList, error) {
523+
cond := builder.NewCond()
524+
if excludedID > 0 {
525+
cond = cond.And(builder.Neq{"`id`": excludedID})
526+
}
527+
528+
// It seems that GitHub searches both title and content (maybe sorting by the search engine's ranking system?)
529+
// The first PR (https://github.com/go-gitea/gitea/pull/32327) uses "search indexer" to search "name(title) + content"
530+
// But it seems that searching "content" (especially LIKE by DB engine) generates worse (unusable) results.
531+
// So now (https://github.com/go-gitea/gitea/pull/33538) it only searches "name(title)", leave the improvements to the future.
532+
cond = cond.And(db.BuildCaseInsensitiveLike("`name`", keyword))
533+
534+
issues := make([]*Issue, 0, pageSize)
535+
err := db.GetEngine(ctx).Where("repo_id = ?", repoID).
536+
And(isPullToCond(isPull)).
537+
And(cond).
538+
OrderBy("updated_unix DESC, `index` DESC").
539+
Limit(pageSize).
540+
Find(&issues)
541+
return issues, err
542+
}
543+
504544
// GetIssueWithAttrsByIndex returns issue by index in a repository.
505545
func GetIssueWithAttrsByIndex(ctx context.Context, repoID, index int64) (*Issue, error) {
506546
issue, err := GetIssueByIndex(ctx, repoID, index)

modules/structs/repo_actions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type CreateActionWorkflowDispatch struct {
4040
// example: refs/heads/main
4141
Ref string `json:"ref" binding:"Required"`
4242
// required: false
43-
Inputs map[string]any `json:"inputs,omitempty"`
43+
Inputs map[string]string `json:"inputs,omitempty"`
4444
}
4545

4646
// ActionWorkflow represents a ActionWorkflow

modules/util/error.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@ func (w SilentWrap) Unwrap() error {
3636
return w.Err
3737
}
3838

39+
type LocaleWrap struct {
40+
err error
41+
TrKey string
42+
TrArgs []any
43+
}
44+
45+
// Error returns the message
46+
func (w LocaleWrap) Error() string {
47+
return w.err.Error()
48+
}
49+
50+
// Unwrap returns the underlying error
51+
func (w LocaleWrap) Unwrap() error {
52+
return w.err
53+
}
54+
3955
// NewSilentWrapErrorf returns an error that formats as the given text but unwraps as the provided error
4056
func NewSilentWrapErrorf(unwrap error, message string, args ...any) error {
4157
if len(args) == 0 {
@@ -63,3 +79,16 @@ func NewAlreadyExistErrorf(message string, args ...any) error {
6379
func NewNotExistErrorf(message string, args ...any) error {
6480
return NewSilentWrapErrorf(ErrNotExist, message, args...)
6581
}
82+
83+
// ErrWrapLocale wraps an err with a translation key and arguments
84+
func ErrWrapLocale(err error, trKey string, trArgs ...any) error {
85+
return LocaleWrap{err: err, TrKey: trKey, TrArgs: trArgs}
86+
}
87+
88+
func ErrAsLocale(err error) *LocaleWrap {
89+
var e LocaleWrap
90+
if errors.As(err, &e) {
91+
return &e
92+
}
93+
return nil
94+
}

options/locale/locale_cs-CZ.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ show_only_public=Zobrazeny pouze veřejné
385385

386386
issues.in_your_repos=Ve vašich repozitářích
387387

388+
388389
[explore]
389390
repos=Repozitáře
390391
users=Uživatelé

options/locale/locale_de-DE.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ show_only_public=Nur öffentliche anzeigen
384384

385385
issues.in_your_repos=Eigene Repositories
386386

387+
387388
[explore]
388389
repos=Repositories
389390
users=Benutzer

options/locale/locale_el-GR.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ show_only_public=Εμφανίζονται μόνο δημόσια
335335

336336
issues.in_your_repos=Στα αποθετήρια σας
337337

338+
338339
[explore]
339340
repos=Αποθετήρια
340341
users=Χρήστες

options/locale/locale_en-US.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,13 @@ show_only_public = Showing only public
385385

386386
issues.in_your_repos = In your repositories
387387

388+
guide_title = No Activity
389+
guide_desc = You are currently not following any repositories or users, so there is no content to display. You can explore repositories or users of interest from the links below.
390+
explore_repos = Explore repositories
391+
explore_users = Explore users
392+
empty_org = There are no organizations yet.
393+
empty_repo = There are no repositories yet.
394+
388395
[explore]
389396
repos = Repositories
390397
users = Users

options/locale/locale_es-ES.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ show_only_public=Mostrar sólo repositorios públicos
333333

334334
issues.in_your_repos=En tus repositorios
335335

336+
336337
[explore]
337338
repos=Repositorios
338339
users=Usuarios

options/locale/locale_fa-IR.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ show_only_public=نمایش دادن موارد عمومی
256256

257257
issues.in_your_repos=در مخازن شما
258258

259+
259260
[explore]
260261
repos=مخازن
261262
users=کاربران

options/locale/locale_fi-FI.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ show_only_public=Näytetään vain julkiset
266266

267267
issues.in_your_repos=Repoissasi
268268

269+
269270
[explore]
270271
repos=Repot
271272
users=Käyttäjät

options/locale/locale_fr-FR.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ show_only_public=Afficher uniquement les dépôts publics
385385

386386
issues.in_your_repos=Dans vos dépôts
387387

388+
388389
[explore]
389390
repos=Dépôts
390391
users=Utilisateurs

options/locale/locale_ga-IE.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ show_only_public=Ag taispeáint poiblí amháin
385385

386386
issues.in_your_repos=I do stórais
387387

388+
388389
[explore]
389390
repos=Stórais
390391
users=Úsáideoirí

options/locale/locale_hu-HU.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ show_only_public=Csak publikus mutatása
225225

226226
issues.in_your_repos=A tárolóidban
227227

228+
228229
[explore]
229230
repos=Tárolók
230231
users=Felhasználók

options/locale/locale_id-ID.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ show_private=Pribadi
243243

244244
issues.in_your_repos=Dalam repositori anda
245245

246+
246247
[explore]
247248
repos=Repositori
248249
users=Pengguna

options/locale/locale_is-IS.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ show_only_public=Að sýna aðeins opinber
240240

241241
issues.in_your_repos=Í hugbúnaðarsöfnum þínum
242242

243+
243244
[explore]
244245
repos=Hugbúnaðarsöfn
245246
users=Notendur

options/locale/locale_it-IT.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ show_only_public=Mostrando solo pubblici
277277
278278
issues.in_your_repos=Nei tuoi repository
279279
280+
280281
[explore]
281282
repos=Repository
282283
users=Utenti

options/locale/locale_ja-JP.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ show_only_public=公開のみ表示
385385

386386
issues.in_your_repos=あなたのリポジトリ
387387

388+
388389
[explore]
389390
repos=リポジトリ
390391
users=ユーザー

options/locale/locale_ko-KR.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ show_private=비공개
212212

213213
issues.in_your_repos=당신의 저장소에
214214

215+
215216
[explore]
216217
repos=저장소
217218
users=유저

options/locale/locale_lv-LV.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ show_only_public=Attēlot tikai publiskos
338338

339339
issues.in_your_repos=Jūsu repozitorijos
340340

341+
341342
[explore]
342343
repos=Repozitoriji
343344
users=Lietotāji

options/locale/locale_nl-NL.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ show_only_public=Toon alleen opbenbaar
276276
277277
issues.in_your_repos=In uw repositories
278278
279+
279280
[explore]
280281
repos=Repositories
281282
users=Gebruikers

options/locale/locale_pl-PL.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ show_only_public=Wyświetlanie tylko publicznych
272272

273273
issues.in_your_repos=W Twoich repozytoriach
274274

275+
275276
[explore]
276277
repos=Repozytoria
277278
users=Użytkownicy

options/locale/locale_pt-BR.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ show_only_public=Mostrando somente públicos
335335

336336
issues.in_your_repos=Em seus repositórios
337337

338+
338339
[explore]
339340
repos=Repositórios
340341
users=Usuários

options/locale/locale_pt-PT.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ show_only_public=Apresentando somente os públicos
385385

386386
issues.in_your_repos=Nos seus repositórios
387387

388+
388389
[explore]
389390
repos=Repositórios
390391
users=Utilizadores

options/locale/locale_ru-RU.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ show_only_public=Показаны только публичные
333333

334334
issues.in_your_repos=В ваших репозиториях
335335

336+
336337
[explore]
337338
repos=Репозитории
338339
users=Пользователи

options/locale/locale_si-LK.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ show_only_public=ප්‍රසිද්ධ පමණක් පෙන්වය
246246

247247
issues.in_your_repos=ඔබගේ කෝෂ්ඨවල
248248

249+
249250
[explore]
250251
repos=කෝෂ්ඨ
251252
users=පරිශීලකයින්

options/locale/locale_sk-SK.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ show_only_public=Zobrazuje sa iba verejné
328328

329329
issues.in_your_repos=Vo vašich repozitároch
330330

331+
331332
[explore]
332333
repos=Repozitáre
333334
users=Používatelia

options/locale/locale_sv-SE.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ show_only_public=Visar endast publika
233233

234234
issues.in_your_repos=I dina utvecklingskataloger
235235

236+
236237
[explore]
237238
repos=Utvecklingskataloger
238239
users=Användare

options/locale/locale_tr-TR.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ show_only_public=Yalnızca açık olanlar gösteriliyor
380380

381381
issues.in_your_repos=Depolarınızda
382382

383+
383384
[explore]
384385
repos=Depolar
385386
users=Kullanıcılar

0 commit comments

Comments
 (0)