Skip to content

Commit 1966e98

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: [skip ci] Updated translations via Crowdin Fix bug when updating user email (go-gitea#36058) Add "Go to file", "Delete Directory" to repo file list page (go-gitea#35911) Replace `lint-go-gopls` with additional `govet` linters (go-gitea#36028) Fix Actions `pull_request.paths` being triggered incorrectly by rebase (go-gitea#36045)
2 parents d4a47e8 + 1e777f9 commit 1966e98

Some content is hidden

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

43 files changed

+788
-563
lines changed

.golangci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ linters:
114114
- stringsbuilder
115115
perfsprint:
116116
concat-loop: false
117+
govet:
118+
enable:
119+
- nilness
120+
- unusedwrite
117121
exclusions:
118122
generated: lax
119123
presets:

Makefile

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
4040
GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1
4141
GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1
4242
ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/[email protected]
43-
GOPLS_PACKAGE ?= golang.org/x/tools/[email protected]
4443

4544
DOCKER_IMAGE ?= gitea/gitea
4645
DOCKER_TAG ?= latest
@@ -333,7 +332,7 @@ lint-frontend: lint-js lint-css ## lint frontend files
333332
lint-frontend-fix: lint-js-fix lint-css-fix ## lint frontend files and fix issues
334333

335334
.PHONY: lint-backend
336-
lint-backend: lint-go lint-go-gitea-vet lint-go-gopls lint-editorconfig ## lint backend files
335+
lint-backend: lint-go lint-go-gitea-vet lint-editorconfig ## lint backend files
337336

338337
.PHONY: lint-backend-fix
339338
lint-backend-fix: lint-go-fix lint-go-gitea-vet lint-editorconfig ## lint backend files and fix issues
@@ -396,11 +395,6 @@ lint-go-gitea-vet: ## lint go files with gitea-vet
396395
@echo "Running gitea-vet..."
397396
@$(GO) vet -vettool="$(shell GOOS= GOARCH= go tool -n gitea-vet)" ./...
398397

399-
.PHONY: lint-go-gopls
400-
lint-go-gopls: ## lint go files with gopls
401-
@echo "Running gopls check..."
402-
@GO=$(GO) GOPLS_PACKAGE=$(GOPLS_PACKAGE) tools/lint-go-gopls.sh $(GO_SOURCES)
403-
404398
.PHONY: lint-editorconfig
405399
lint-editorconfig:
406400
@echo "Running editorconfig check..."
@@ -844,7 +838,6 @@ deps-tools: ## install tool dependencies
844838
$(GO) install $(GO_LICENSES_PACKAGE) & \
845839
$(GO) install $(GOVULNCHECK_PACKAGE) & \
846840
$(GO) install $(ACTIONLINT_PACKAGE) & \
847-
$(GO) install $(GOPLS_PACKAGE) & \
848841
wait
849842

850843
node_modules: pnpm-lock.yaml

options/locale/locale_en-US.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,8 +1354,11 @@ editor.this_file_locked = File is locked
13541354
editor.must_be_on_a_branch = You must be on a branch to make or propose changes to this file.
13551355
editor.fork_before_edit = You must fork this repository to make or propose changes to this file.
13561356
editor.delete_this_file = Delete File
1357+
editor.delete_this_directory = Delete Directory
13571358
editor.must_have_write_access = You must have write access to make or propose changes to this file.
13581359
editor.file_delete_success = File "%s" has been deleted.
1360+
editor.directory_delete_success = Directory "%s" has been deleted.
1361+
editor.delete_directory = Delete directory '%s'
13591362
editor.name_your_file = Name your file…
13601363
editor.filename_help = Add a directory by typing its name followed by a slash ('/'). Remove a directory by typing backspace at the beginning of the input field.
13611364
editor.or = or

options/locale/locale_ga-IE.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,8 +1354,11 @@ editor.this_file_locked=Tá an comhad faoi ghlas
13541354
editor.must_be_on_a_branch=Caithfidh tú a bheith ar bhrainse chun athruithe a dhéanamh nó a mholadh ar an gcomhad seo.
13551355
editor.fork_before_edit=Ní mór duit an stór seo a fhorcáil chun athruithe a dhéanamh nó a mholadh ar an gcomhad seo.
13561356
editor.delete_this_file=Scrios Comhad
1357+
editor.delete_this_directory=Scrios Eolaire
13571358
editor.must_have_write_access=Caithfidh rochtain scríofa a bheith agat chun athruithe a dhéanamh nó a mholadh ar an gcomhad seo.
13581359
editor.file_delete_success=Tá an comhad "%s" scriosta.
1360+
editor.directory_delete_success=Scriosadh an eolaire "%s".
1361+
editor.delete_directory=Scrios an eolaire '%s'
13591362
editor.name_your_file=Ainmnigh do chomhad…
13601363
editor.filename_help=Cuir eolaire leis trína ainm a chlóscríobh ina dhiaidh sin le slash ('/'). Bain eolaire trí backspace a chlóscríobh ag tús an réimse ionchuir.
13611364
editor.or=nó
@@ -1482,6 +1485,7 @@ projects.column.new_submit=Cruthaigh Colún
14821485
projects.column.new=Colún Nua
14831486
projects.column.set_default=Socraigh Réamhshocrú
14841487
projects.column.set_default_desc=Socraigh an colún seo mar réamhshocrú le haghaidh saincheisteanna agus tarraingtí gan chatagóir
1488+
projects.column.default_column_hint=Cuirfear saincheisteanna nua a chuirtear leis an tionscadal seo leis an gcolún seo
14851489
projects.column.delete=Scrios Colún
14861490
projects.column.deletion_desc=Ag scriosadh colún tionscadail aistríonn gach saincheist ghaolmhar chuig an gcolún. Lean ar aghaidh?
14871491
projects.column.color=Dath
@@ -3038,6 +3042,7 @@ dashboard.update_migration_poster_id=Nuashonraigh ID póstaer imir
30383042
dashboard.git_gc_repos=Bailitheoir bruscair gach stórais
30393043
dashboard.resync_all_sshkeys=Nuashonraigh an comhad '.ssh/authorized_keys' le heochracha SSH Gitea
30403044
dashboard.resync_all_sshprincipals=Nuashonraigh an comhad '.ssh/authorized_principals' le príomhoidí SSH Gitea
3045+
dashboard.resync_all_hooks=Athshioncrónaigh crúcaí git na stórtha uile (réamhghlacadh, nuashonrú, iarghlacadh, próiseasghlacadh, ...)
30413046
dashboard.reinit_missing_repos=Aththosaigh gach stórais Git atá in easnamh a bhfuil taifid ann dóibh
30423047
dashboard.sync_external_users=Sioncrónaigh sonraí úsáideoirí seachtracha
30433048
dashboard.cleanup_hook_task_table=Glan suas an tábla hook_task

options/locale/locale_pt-PT.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,8 +1354,11 @@ editor.this_file_locked=Ficheiro bloqueado
13541354
editor.must_be_on_a_branch=Tem que estar num ramo para fazer ou propor modificações neste ficheiro.
13551355
editor.fork_before_edit=Tem que fazer uma derivação deste repositório para fazer ou propor modificações neste ficheiro.
13561356
editor.delete_this_file=Eliminar ficheiro
1357+
editor.delete_this_directory=Eliminar pasta
13571358
editor.must_have_write_access=Tem que ter permissões de escrita para fazer ou propor modificações neste ficheiro.
13581359
editor.file_delete_success=O ficheiro "%s" foi eliminado.
1360+
editor.directory_delete_success=A pasta "%s" foi eliminada.
1361+
editor.delete_directory=Eliminar a pasta '%s'
13591362
editor.name_your_file=Nomeie o seu ficheiro…
13601363
editor.filename_help=Adicione uma pasta escrevendo o nome dessa pasta seguido de uma barra('/'). Remova uma pasta carregando na tecla de apagar ('') no início do campo.
13611364
editor.or=ou

routers/api/v1/repo/file.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -610,10 +610,6 @@ func handleChangeRepoFilesError(ctx *context.APIContext, err error) {
610610
ctx.APIError(http.StatusUnprocessableEntity, err)
611611
return
612612
}
613-
if git.IsErrBranchNotExist(err) || files_service.IsErrRepoFileDoesNotExist(err) || git.IsErrNotExist(err) {
614-
ctx.APIError(http.StatusNotFound, err)
615-
return
616-
}
617613
if errors.Is(err, util.ErrNotExist) {
618614
ctx.APIError(http.StatusNotFound, err)
619615
return

routers/web/admin/users.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ func EditUserPost(ctx *context.Context) {
409409
}
410410

411411
if form.Email != "" {
412-
if err := user_service.AdminAddOrSetPrimaryEmailAddress(ctx, u, form.Email); err != nil {
412+
if err := user_service.ReplacePrimaryEmailAddress(ctx, u, form.Email); err != nil {
413413
switch {
414414
case user_model.IsErrEmailCharIsNotSupported(err), user_model.IsErrEmailInvalid(err):
415415
ctx.Data["Err_Email"] = true

routers/web/repo/blame.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"net/url"
1111
"path"
1212
"strconv"
13-
"strings"
1413

1514
repo_model "code.gitea.io/gitea/models/repo"
1615
user_model "code.gitea.io/gitea/models/user"
@@ -42,8 +41,8 @@ type blameRow struct {
4241

4342
// RefBlame render blame page
4443
func RefBlame(ctx *context.Context) {
45-
ctx.Data["PageIsViewCode"] = true
4644
ctx.Data["IsBlame"] = true
45+
prepareRepoViewContent(ctx, ctx.Repo.RefTypeNameSubURL())
4746

4847
// Get current entry user currently looking at.
4948
if ctx.Repo.TreePath == "" {
@@ -56,17 +55,6 @@ func RefBlame(ctx *context.Context) {
5655
return
5756
}
5857

59-
treeNames := strings.Split(ctx.Repo.TreePath, "/")
60-
var paths []string
61-
for i := range treeNames {
62-
paths = append(paths, strings.Join(treeNames[:i+1], "/"))
63-
}
64-
65-
ctx.Data["Paths"] = paths
66-
ctx.Data["TreeNames"] = treeNames
67-
ctx.Data["BranchLink"] = ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL()
68-
ctx.Data["RawFileLink"] = ctx.Repo.RepoLink + "/raw/" + ctx.Repo.RefTypeNameSubURL() + "/" + util.PathEscapeSegments(ctx.Repo.TreePath)
69-
7058
blob := entry.Blob()
7159
fileSize := blob.Size()
7260
ctx.Data["FileSize"] = fileSize

routers/web/repo/editor.go

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ const (
4141
editorCommitChoiceNewBranch string = "commit-to-new-branch"
4242
)
4343

44-
func prepareEditorCommitFormOptions(ctx *context.Context, editorAction string) *context.CommitFormOptions {
44+
func prepareEditorPage(ctx *context.Context, editorAction string) *context.CommitFormOptions {
45+
prepareHomeTreeSideBarSwitch(ctx)
46+
return prepareEditorPageFormOptions(ctx, editorAction)
47+
}
48+
49+
func prepareEditorPageFormOptions(ctx *context.Context, editorAction string) *context.CommitFormOptions {
4550
cleanedTreePath := files_service.CleanGitTreePath(ctx.Repo.TreePath)
4651
if cleanedTreePath != ctx.Repo.TreePath {
4752
redirectTo := fmt.Sprintf("%s/%s/%s/%s", ctx.Repo.RepoLink, editorAction, util.PathEscapeSegments(ctx.Repo.BranchName), util.PathEscapeSegments(cleanedTreePath))
@@ -283,7 +288,7 @@ func EditFile(ctx *context.Context) {
283288
// on the "New File" page, we should add an empty path field to make end users could input a new name
284289
prepareTreePathFieldsAndPaths(ctx, util.Iif(isNewFile, ctx.Repo.TreePath+"/", ctx.Repo.TreePath))
285290

286-
prepareEditorCommitFormOptions(ctx, editorAction)
291+
prepareEditorPage(ctx, editorAction)
287292
if ctx.Written() {
288293
return
289294
}
@@ -376,33 +381,54 @@ func EditFilePost(ctx *context.Context) {
376381

377382
// DeleteFile render delete file page
378383
func DeleteFile(ctx *context.Context) {
379-
prepareEditorCommitFormOptions(ctx, "_delete")
384+
prepareEditorPage(ctx, "_delete")
380385
if ctx.Written() {
381386
return
382387
}
383388
ctx.Data["PageIsDelete"] = true
389+
prepareTreePathFieldsAndPaths(ctx, ctx.Repo.TreePath)
384390
ctx.HTML(http.StatusOK, tplDeleteFile)
385391
}
386392

387-
// DeleteFilePost response for deleting file
393+
// DeleteFilePost response for deleting file or directory
388394
func DeleteFilePost(ctx *context.Context) {
389395
parsed := prepareEditorCommitSubmittedForm[*forms.DeleteRepoFileForm](ctx)
390396
if ctx.Written() {
391397
return
392398
}
393399

394400
treePath := ctx.Repo.TreePath
395-
_, err := files_service.ChangeRepoFiles(ctx, ctx.Repo.Repository, ctx.Doer, &files_service.ChangeRepoFilesOptions{
401+
if treePath == "" {
402+
ctx.JSONError("cannot delete root directory") // it should not happen unless someone is trying to be malicious
403+
return
404+
}
405+
406+
// Check if the path is a directory
407+
entry, err := ctx.Repo.Commit.GetTreeEntryByPath(treePath)
408+
if err != nil {
409+
ctx.NotFoundOrServerError("GetTreeEntryByPath", git.IsErrNotExist, err)
410+
return
411+
}
412+
413+
var commitMessage string
414+
if entry.IsDir() {
415+
commitMessage = parsed.GetCommitMessage(ctx.Locale.TrString("repo.editor.delete_directory", treePath))
416+
} else {
417+
commitMessage = parsed.GetCommitMessage(ctx.Locale.TrString("repo.editor.delete", treePath))
418+
}
419+
420+
_, err = files_service.ChangeRepoFiles(ctx, ctx.Repo.Repository, ctx.Doer, &files_service.ChangeRepoFilesOptions{
396421
LastCommitID: parsed.form.LastCommit,
397422
OldBranch: parsed.OldBranchName,
398423
NewBranch: parsed.NewBranchName,
399424
Files: []*files_service.ChangeRepoFile{
400425
{
401-
Operation: "delete",
402-
TreePath: treePath,
426+
Operation: "delete",
427+
TreePath: treePath,
428+
DeleteRecursively: true,
403429
},
404430
},
405-
Message: parsed.GetCommitMessage(ctx.Locale.TrString("repo.editor.delete", treePath)),
431+
Message: commitMessage,
406432
Signoff: parsed.form.Signoff,
407433
Author: parsed.GitCommitter,
408434
Committer: parsed.GitCommitter,
@@ -412,15 +438,19 @@ func DeleteFilePost(ctx *context.Context) {
412438
return
413439
}
414440

415-
ctx.Flash.Success(ctx.Tr("repo.editor.file_delete_success", treePath))
441+
if entry.IsDir() {
442+
ctx.Flash.Success(ctx.Tr("repo.editor.directory_delete_success", treePath))
443+
} else {
444+
ctx.Flash.Success(ctx.Tr("repo.editor.file_delete_success", treePath))
445+
}
416446
redirectTreePath := getClosestParentWithFiles(ctx.Repo.GitRepo, parsed.NewBranchName, treePath)
417447
redirectForCommitChoice(ctx, parsed, redirectTreePath)
418448
}
419449

420450
func UploadFile(ctx *context.Context) {
421451
ctx.Data["PageIsUpload"] = true
422452
prepareTreePathFieldsAndPaths(ctx, ctx.Repo.TreePath)
423-
opts := prepareEditorCommitFormOptions(ctx, "_upload")
453+
opts := prepareEditorPage(ctx, "_upload")
424454
if ctx.Written() {
425455
return
426456
}

routers/web/repo/editor_apply_patch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
)
1515

1616
func NewDiffPatch(ctx *context.Context) {
17-
prepareEditorCommitFormOptions(ctx, "_diffpatch")
17+
prepareEditorPage(ctx, "_diffpatch")
1818
if ctx.Written() {
1919
return
2020
}

0 commit comments

Comments
 (0)