Skip to content

Commit 7f44370

Browse files
authored
Merge branch 'main' into support-issue-list
2 parents 8803a97 + 02c64e4 commit 7f44370

38 files changed

+210
-22
lines changed

models/actions/runner_token.go

+13-8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ 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"
1314
"code.gitea.io/gitea/modules/timeutil"
1415
"code.gitea.io/gitea/modules/util"
1516
)
@@ -51,7 +52,7 @@ func GetRunnerToken(ctx context.Context, token string) (*ActionRunnerToken, erro
5152
if err != nil {
5253
return nil, err
5354
} else if !has {
54-
return nil, fmt.Errorf("runner token %q: %w", token, util.ErrNotExist)
55+
return nil, fmt.Errorf(`runner token "%s...": %w`, base.TruncateString(token, 3), util.ErrNotExist)
5556
}
5657
return &runnerToken, nil
5758
}
@@ -68,19 +69,15 @@ func UpdateRunnerToken(ctx context.Context, r *ActionRunnerToken, cols ...string
6869
return err
6970
}
7071

71-
// NewRunnerToken creates a new active runner token and invalidate all old tokens
72+
// NewRunnerTokenWithValue creates a new active runner token and invalidate all old tokens
7273
// ownerID will be ignored and treated as 0 if repoID is non-zero.
73-
func NewRunnerToken(ctx context.Context, ownerID, repoID int64) (*ActionRunnerToken, error) {
74+
func NewRunnerTokenWithValue(ctx context.Context, ownerID, repoID int64, token string) (*ActionRunnerToken, error) {
7475
if ownerID != 0 && repoID != 0 {
7576
// It's trying to create a runner token that belongs to a repository, but OwnerID has been set accidentally.
7677
// Remove OwnerID to avoid confusion; it's not worth returning an error here.
7778
ownerID = 0
7879
}
7980

80-
token, err := util.CryptoRandomString(40)
81-
if err != nil {
82-
return nil, err
83-
}
8481
runnerToken := &ActionRunnerToken{
8582
OwnerID: ownerID,
8683
RepoID: repoID,
@@ -95,11 +92,19 @@ func NewRunnerToken(ctx context.Context, ownerID, repoID int64) (*ActionRunnerTo
9592
return err
9693
}
9794

98-
_, err = db.GetEngine(ctx).Insert(runnerToken)
95+
_, err := db.GetEngine(ctx).Insert(runnerToken)
9996
return err
10097
})
10198
}
10299

100+
func NewRunnerToken(ctx context.Context, ownerID, repoID int64) (*ActionRunnerToken, error) {
101+
token, err := util.CryptoRandomString(40)
102+
if err != nil {
103+
return nil, err
104+
}
105+
return NewRunnerTokenWithValue(ctx, ownerID, repoID, token)
106+
}
107+
103108
// GetLatestRunnerToken returns the latest runner token
104109
func GetLatestRunnerToken(ctx context.Context, ownerID, repoID int64) (*ActionRunnerToken, error) {
105110
if ownerID != 0 && repoID != 0 {

modules/git/repo_commit.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,6 @@ type CommitsByFileAndRangeOptions struct {
216216

217217
// CommitsByFileAndRange return the commits according revision file and the page
218218
func (repo *Repository) CommitsByFileAndRange(opts CommitsByFileAndRangeOptions) ([]*Commit, error) {
219-
skip := (opts.Page - 1) * setting.Git.CommitsRangeSize
220-
221219
stdoutReader, stdoutWriter := io.Pipe()
222220
defer func() {
223221
_ = stdoutReader.Close()
@@ -226,8 +224,8 @@ func (repo *Repository) CommitsByFileAndRange(opts CommitsByFileAndRangeOptions)
226224
go func() {
227225
stderr := strings.Builder{}
228226
gitCmd := NewCommand(repo.Ctx, "rev-list").
229-
AddOptionFormat("--max-count=%d", setting.Git.CommitsRangeSize*opts.Page).
230-
AddOptionFormat("--skip=%d", skip)
227+
AddOptionFormat("--max-count=%d", setting.Git.CommitsRangeSize).
228+
AddOptionFormat("--skip=%d", (opts.Page-1)*setting.Git.CommitsRangeSize)
231229
gitCmd.AddDynamicArguments(opts.Revision)
232230

233231
if opts.Not != "" {

modules/git/repo_commit_test.go

+22
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import (
88
"path/filepath"
99
"testing"
1010

11+
"code.gitea.io/gitea/modules/setting"
12+
"code.gitea.io/gitea/modules/test"
13+
1114
"github.com/stretchr/testify/assert"
15+
"github.com/stretchr/testify/require"
1216
)
1317

1418
func TestRepository_GetCommitBranches(t *testing.T) {
@@ -126,3 +130,21 @@ func TestGetRefCommitID(t *testing.T) {
126130
}
127131
}
128132
}
133+
134+
func TestCommitsByFileAndRange(t *testing.T) {
135+
defer test.MockVariableValue(&setting.Git.CommitsRangeSize, 2)()
136+
137+
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare")
138+
bareRepo1, err := openRepositoryWithDefaultContext(bareRepo1Path)
139+
require.NoError(t, err)
140+
defer bareRepo1.Close()
141+
142+
// "foo" has 3 commits in "master" branch
143+
commits, err := bareRepo1.CommitsByFileAndRange(CommitsByFileAndRangeOptions{Revision: "master", File: "foo", Page: 1})
144+
require.NoError(t, err)
145+
assert.Len(t, commits, 2)
146+
147+
commits, err = bareRepo1.CommitsByFileAndRange(CommitsByFileAndRangeOptions{Revision: "master", File: "foo", Page: 2})
148+
require.NoError(t, err)
149+
assert.Len(t, commits, 1)
150+
}

options/locale/locale_cs-CZ.ini

+1
Original file line numberDiff line numberDiff line change
@@ -3742,6 +3742,7 @@ variables.creation.success=Proměnná „%s“ byla přidána.
37423742
variables.update.failed=Úprava proměnné se nezdařila.
37433743
variables.update.success=Proměnná byla upravena.
37443744
3745+
37453746
[projects]
37463747
deleted.display_name=Odstraněný projekt
37473748
type-1.display_name=Samostatný projekt

options/locale/locale_de-DE.ini

+1
Original file line numberDiff line numberDiff line change
@@ -3556,6 +3556,7 @@ variables.creation.success=Die Variable „%s“ wurde hinzugefügt.
35563556
variables.update.failed=Fehler beim Bearbeiten der Variable.
35573557
variables.update.success=Die Variable wurde bearbeitet.
35583558

3559+
35593560
[projects]
35603561
type-1.display_name=Individuelles Projekt
35613562
type-2.display_name=Repository-Projekt

options/locale/locale_el-GR.ini

+1
Original file line numberDiff line numberDiff line change
@@ -3439,6 +3439,7 @@ variables.creation.success=Η μεταβλητή "%s" έχει προστεθε
34393439
variables.update.failed=Αποτυχία επεξεργασίας μεταβλητής.
34403440
variables.update.success=Η μεταβλητή έχει τροποποιηθεί.
34413441

3442+
34423443
[projects]
34433444
type-1.display_name=Ατομικό Έργο
34443445
type-2.display_name=Έργο Αποθετηρίου

options/locale/locale_en-US.ini

+1
Original file line numberDiff line numberDiff line change
@@ -3722,6 +3722,7 @@ runners.status.active = Active
37223722
runners.status.offline = Offline
37233723
runners.version = Version
37243724
runners.reset_registration_token = Reset registration token
3725+
runners.reset_registration_token_confirm = Would you like to invalidate the current token and generate a new one?
37253726
runners.reset_registration_token_success = Runner registration token reset successfully
37263727
37273728
runs.all_workflows = All Workflows

options/locale/locale_es-ES.ini

+1
Original file line numberDiff line numberDiff line change
@@ -3415,6 +3415,7 @@ variables.creation.success=La variable "%s" ha sido añadida.
34153415
variables.update.failed=Error al editar la variable.
34163416
variables.update.success=La variable ha sido editada.
34173417
3418+
34183419
[projects]
34193420
type-1.display_name=Proyecto individual
34203421
type-2.display_name=Proyecto repositorio

options/locale/locale_fa-IR.ini

+1
Original file line numberDiff line numberDiff line change
@@ -2529,6 +2529,7 @@ runs.commit=کامیت
25292529

25302530

25312531

2532+
25322533
[projects]
25332534

25342535
[git.filemode]

options/locale/locale_fi-FI.ini

+1
Original file line numberDiff line numberDiff line change
@@ -1707,6 +1707,7 @@ runs.commit=Commit
17071707

17081708

17091709

1710+
17101711
[projects]
17111712

17121713
[git.filemode]

options/locale/locale_fr-FR.ini

+3
Original file line numberDiff line numberDiff line change
@@ -1945,6 +1945,8 @@ pulls.delete.title=Supprimer cette demande d'ajout ?
19451945
pulls.delete.text=Voulez-vous vraiment supprimer cet demande d'ajout ? (Cela supprimera définitivement tout le contenu. Envisagez de le fermer à la place, si vous avez l'intention de le garder archivé)
19461946
19471947
pulls.recently_pushed_new_branches=Vous avez soumis sur la branche <strong>%[1]s</strong> %[2]s
1948+
pulls.upstream_diverging_prompt_behind_1=Cette branche est en retard de %d révision sur %s
1949+
pulls.upstream_diverging_prompt_behind_n=Cette branche est en retard de %d révisions sur %s
19481950
pulls.upstream_diverging_prompt_base_newer=La branche de base %s a de nouveaux changements
19491951
pulls.upstream_diverging_merge=Synchroniser la bifurcation
19501952
@@ -3770,6 +3772,7 @@ variables.creation.success=La variable « %s » a été ajoutée.
37703772
variables.update.failed=Impossible d’éditer la variable.
37713773
variables.update.success=La variable a bien été modifiée.
37723774

3775+
37733776
[projects]
37743777
deleted.display_name=Projet supprimé
37753778
type-1.display_name=Projet personnel

options/locale/locale_ga-IE.ini

+1
Original file line numberDiff line numberDiff line change
@@ -3770,6 +3770,7 @@ variables.creation.success=Tá an athróg "%s" curtha leis.
37703770
variables.update.failed=Theip ar athróg a chur in eagar.
37713771
variables.update.success=Tá an t-athróg curtha in eagar.
37723772

3773+
37733774
[projects]
37743775
deleted.display_name=Tionscadal scriosta
37753776
type-1.display_name=Tionscadal Aonair

options/locale/locale_hu-HU.ini

+1
Original file line numberDiff line numberDiff line change
@@ -1615,6 +1615,7 @@ runs.commit=Commit
16151615

16161616

16171617

1618+
16181619
[projects]
16191620

16201621
[git.filemode]

options/locale/locale_id-ID.ini

+1
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,7 @@ variables.creation.success=Variabel "%s" telah ditambahkan.
14441444
variables.update.failed=Gagal mengedit variabel.
14451445
variables.update.success=Variabel telah diedit.
14461446

1447+
14471448
[projects]
14481449
type-1.display_name=Proyek Individu
14491450
type-2.display_name=Proyek Repositori

options/locale/locale_is-IS.ini

+1
Original file line numberDiff line numberDiff line change
@@ -1342,6 +1342,7 @@ runs.commit=Framlag
13421342

13431343

13441344

1345+
13451346
[projects]
13461347

13471348
[git.filemode]

options/locale/locale_it-IT.ini

+1
Original file line numberDiff line numberDiff line change
@@ -2807,6 +2807,7 @@ runs.commit=Commit
28072807

28082808

28092809

2810+
28102811
[projects]
28112812

28122813
[git.filemode]

options/locale/locale_ja-JP.ini

+1
Original file line numberDiff line numberDiff line change
@@ -3762,6 +3762,7 @@ variables.creation.success=変数 "%s" を追加しました。
37623762
variables.update.failed=変数を更新できませんでした。
37633763
variables.update.success=変数を更新しました。
37643764

3765+
37653766
[projects]
37663767
deleted.display_name=削除されたプロジェクト
37673768
type-1.display_name=個人プロジェクト

options/locale/locale_ko-KR.ini

+1
Original file line numberDiff line numberDiff line change
@@ -1563,6 +1563,7 @@ runs.commit=커밋
15631563

15641564

15651565

1566+
15661567
[projects]
15671568

15681569
[git.filemode]

options/locale/locale_lv-LV.ini

+1
Original file line numberDiff line numberDiff line change
@@ -3443,6 +3443,7 @@ variables.creation.success=Mainīgais "%s" tika pievienots.
34433443
variables.update.failed=Neizdevās labot mainīgo.
34443444
variables.update.success=Mainīgais tika labots.
34453445
3446+
34463447
[projects]
34473448
type-1.display_name=Individuālais projekts
34483449
type-2.display_name=Repozitorija projekts

options/locale/locale_nl-NL.ini

+1
Original file line numberDiff line numberDiff line change
@@ -2537,6 +2537,7 @@ runs.commit=Commit
25372537
25382538
25392539
2540+
25402541
[projects]
25412542
25422543
[git.filemode]

options/locale/locale_pl-PL.ini

+1
Original file line numberDiff line numberDiff line change
@@ -2430,6 +2430,7 @@ runs.commit=Commit
24302430
24312431
24322432
2433+
24332434
[projects]
24342435
24352436
[git.filemode]

options/locale/locale_pt-BR.ini

+1
Original file line numberDiff line numberDiff line change
@@ -3353,6 +3353,7 @@ runs.empty_commit_message=(mensagem de commit vazia)
33533353
need_approval_desc=Precisa de aprovação para executar workflows para pull request do fork.
33543354

33553355

3356+
33563357
[projects]
33573358
type-1.display_name=Projeto individual
33583359
type-2.display_name=Projeto do repositório

options/locale/locale_pt-PT.ini

+3
Original file line numberDiff line numberDiff line change
@@ -3770,6 +3770,9 @@ variables.creation.success=A variável "%s" foi adicionada.
37703770
variables.update.failed=Falha ao editar a variável.
37713771
variables.update.success=A variável foi editada.
37723772

3773+
logs.always_auto_scroll=Rolar registos de forma automática e permanente
3774+
logs.always_expand_running=Expandir sempre os registos que vão rolando
3775+
37733776
[projects]
37743777
deleted.display_name=Planeamento eliminado
37753778
type-1.display_name=Planeamento individual

options/locale/locale_ru-RU.ini

+1
Original file line numberDiff line numberDiff line change
@@ -3373,6 +3373,7 @@ variables.creation.success=Переменная «%s» добавлена.
33733373
variables.update.failed=Не удалось изменить переменную.
33743374
variables.update.success=Переменная изменена.
33753375

3376+
33763377
[projects]
33773378
type-1.display_name=Индивидуальный проект
33783379
type-2.display_name=Проект репозитория

options/locale/locale_si-LK.ini

+1
Original file line numberDiff line numberDiff line change
@@ -2470,6 +2470,7 @@ runs.commit=කැප
24702470

24712471

24722472

2473+
24732474
[projects]
24742475

24752476
[git.filemode]

options/locale/locale_sk-SK.ini

+1
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,7 @@ runners.labels=Štítky
13281328

13291329

13301330

1331+
13311332
[projects]
13321333

13331334
[git.filemode]

options/locale/locale_sv-SE.ini

+1
Original file line numberDiff line numberDiff line change
@@ -2005,6 +2005,7 @@ runs.commit=Commit
20052005

20062006

20072007

2008+
20082009
[projects]
20092010

20102011
[git.filemode]

options/locale/locale_tr-TR.ini

+1
Original file line numberDiff line numberDiff line change
@@ -3633,6 +3633,7 @@ variables.creation.success=`"%s" değişkeni eklendi.`
36333633
variables.update.failed=Değişken düzenlenemedi.
36343634
variables.update.success=Değişken düzenlendi.
36353635

3636+
36363637
[projects]
36373638
deleted.display_name=Silinmiş Proje
36383639
type-1.display_name=Kişisel Proje

options/locale/locale_uk-UA.ini

+1
Original file line numberDiff line numberDiff line change
@@ -2538,6 +2538,7 @@ runs.commit=Коміт
25382538

25392539

25402540

2541+
25412542
[projects]
25422543

25432544
[git.filemode]

options/locale/locale_zh-CN.ini

+3
Original file line numberDiff line numberDiff line change
@@ -1945,6 +1945,8 @@ pulls.delete.title=删除此合并请求?
19451945
pulls.delete.text=你真的要删除这个合并请求吗? (这将永久删除所有内容。如果你打算将内容存档,请考虑关闭它)
19461946

19471947
pulls.recently_pushed_new_branches=您已经于%[2]s推送了分支 <strong>%[1]s</strong>
1948+
pulls.upstream_diverging_prompt_behind_1=该分支落后于 %[2]s %[1]d 个提交
1949+
pulls.upstream_diverging_prompt_behind_n=该分支落后于 %[2]s %[1]d 个提交
19481950
pulls.upstream_diverging_prompt_base_newer=基础分支 %s 有新的更改
19491951
pulls.upstream_diverging_merge=同步派生
19501952

@@ -3770,6 +3772,7 @@ variables.creation.success=变量 “%s” 添加成功。
37703772
variables.update.failed=编辑变量失败。
37713773
variables.update.success=该变量已被编辑。
37723774

3775+
37733776
[projects]
37743777
deleted.display_name=已删除项目
37753778
type-1.display_name=个人项目

options/locale/locale_zh-HK.ini

+1
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,7 @@ runners.task_list.repository=儲存庫
975975

976976

977977

978+
978979
[projects]
979980

980981
[git.filemode]

options/locale/locale_zh-TW.ini

+1
Original file line numberDiff line numberDiff line change
@@ -3763,6 +3763,7 @@ variables.creation.success=已新增變數「%s」。
37633763
variables.update.failed=編輯變數失敗。
37643764
variables.update.success=已編輯變數。
37653765

3766+
37663767
[projects]
37673768
deleted.display_name=已刪除的專案
37683769
type-1.display_name=個人專案

routers/init.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func InitWebInstalled(ctx context.Context) {
171171
auth.Init()
172172
mustInit(svg.Init)
173173

174-
actions_service.Init()
174+
mustInitCtx(ctx, actions_service.Init)
175175

176176
mustInit(repo_service.InitLicenseClassifier)
177177

routers/web/shared/actions/runners.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,8 @@ func RunnerResetRegistrationToken(ctx *context.Context, ownerID, repoID int64, r
136136
ctx.ServerError("ResetRunnerRegistrationToken", err)
137137
return
138138
}
139-
140139
ctx.Flash.Success(ctx.Tr("actions.runners.reset_registration_token_success"))
141-
ctx.Redirect(redirectTo)
140+
ctx.JSONRedirect(redirectTo)
142141
}
143142

144143
// RunnerDeletePost response for deleting a runner

routers/web/web.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ func registerRoutes(m *web.Router) {
463463
m.Combo("/{runnerid}").Get(repo_setting.RunnersEdit).
464464
Post(web.Bind(forms.EditRunnerForm{}), repo_setting.RunnersEditPost)
465465
m.Post("/{runnerid}/delete", repo_setting.RunnerDeletePost)
466-
m.Get("/reset_registration_token", repo_setting.ResetRunnerRegistrationToken)
466+
m.Post("/reset_registration_token", repo_setting.ResetRunnerRegistrationToken)
467467
})
468468
}
469469

0 commit comments

Comments
 (0)