Skip to content

Commit 5f29893

Browse files
committed
Merge branch 'main' into support-trace
# Conflicts: # modules/web/routing/context.go
2 parents 94816bf + ab347fd commit 5f29893

Some content is hidden

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

44 files changed

+874
-653
lines changed

.eslintrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ module.exports = {
403403
'github/a11y-svg-has-accessible-name': [0],
404404
'github/array-foreach': [0],
405405
'github/async-currenttarget': [2],
406-
'github/async-preventdefault': [2],
406+
'github/async-preventdefault': [0], // https://github.com/github/eslint-plugin-github/issues/599
407407
'github/authenticity-token': [0],
408408
'github/get-attribute': [0],
409409
'github/js-class-name': [0],

models/fixtures/access.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,9 @@
171171
user_id: 40
172172
repo_id: 61
173173
mode: 4
174+
175+
-
176+
id: 30
177+
user_id: 40
178+
repo_id: 1
179+
mode: 2

options/locale/locale_en-US.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2714,6 +2714,8 @@ branch.create_branch_operation = Create branch
27142714
branch.new_branch = Create new branch
27152715
branch.new_branch_from = Create new branch from "%s"
27162716
branch.renamed = Branch %s was renamed to %s.
2717+
branch.rename_default_or_protected_branch_error = Only admins can rename default or protected branches.
2718+
branch.rename_protected_branch_failed = This branch is protected by glob-based protection rules.
27172719
27182720
tag.create_tag = Create tag %s
27192721
tag.create_tag_operation = Create tag

package-lock.json

Lines changed: 508 additions & 400 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
},
66
"dependencies": {
77
"@citation-js/core": "0.7.14",
8-
"@citation-js/plugin-bibtex": "0.7.16",
8+
"@citation-js/plugin-bibtex": "0.7.17",
99
"@citation-js/plugin-csl": "0.7.14",
1010
"@citation-js/plugin-software-formats": "0.6.1",
1111
"@github/markdown-toolbar-element": "2.2.3",
12-
"@github/relative-time-element": "4.4.4",
12+
"@github/relative-time-element": "4.4.5",
1313
"@github/text-expander-element": "2.8.0",
1414
"@mcaptcha/vanilla-glue": "0.1.0-alpha-3",
1515
"@primer/octicons": "19.14.0",
1616
"@silverwind/vue3-calendar-heatmap": "2.0.6",
1717
"add-asset-webpack-plugin": "3.0.0",
1818
"ansi_up": "6.0.2",
19-
"asciinema-player": "3.8.1",
19+
"asciinema-player": "3.8.2",
2020
"chart.js": "4.4.7",
2121
"chartjs-adapter-dayjs-4": "1.0.4",
2222
"chartjs-plugin-zoom": "2.2.0",
@@ -28,11 +28,11 @@
2828
"easymde": "2.18.0",
2929
"esbuild-loader": "4.2.2",
3030
"escape-goat": "4.0.0",
31-
"fast-glob": "3.3.2",
31+
"fast-glob": "3.3.3",
3232
"htmx.org": "2.0.4",
33-
"idiomorph": "0.3.0",
33+
"idiomorph": "0.4.0",
3434
"jquery": "3.7.1",
35-
"katex": "0.16.18",
35+
"katex": "0.16.20",
3636
"license-checker-webpack-plugin": "0.2.1",
3737
"mermaid": "11.4.1",
3838
"mini-css-extract-plugin": "2.9.2",
@@ -41,7 +41,7 @@
4141
"monaco-editor-webpack-plugin": "7.1.0",
4242
"pdfobject": "2.3.0",
4343
"perfect-debounce": "1.0.0",
44-
"postcss": "8.4.49",
44+
"postcss": "8.5.1",
4545
"postcss-loader": "8.1.1",
4646
"postcss-nesting": "13.0.1",
4747
"sortablejs": "1.15.6",
@@ -52,22 +52,22 @@
5252
"tippy.js": "6.3.7",
5353
"toastify-js": "1.12.0",
5454
"tributejs": "5.1.3",
55-
"typescript": "5.7.2",
55+
"typescript": "5.7.3",
5656
"uint8-to-base64": "0.2.0",
5757
"vanilla-colorful": "0.7.2",
5858
"vue": "3.5.13",
5959
"vue-bar-graph": "2.2.0",
6060
"vue-chartjs": "5.3.2",
6161
"vue-loader": "17.4.2",
6262
"webpack": "5.97.1",
63-
"webpack-cli": "5.1.4",
63+
"webpack-cli": "6.0.1",
6464
"wrap-ansi": "9.0.0"
6565
},
6666
"devDependencies": {
6767
"@eslint-community/eslint-plugin-eslint-comments": "4.4.1",
6868
"@playwright/test": "1.49.1",
6969
"@stoplight/spectral-cli": "6.14.2",
70-
"@stylistic/eslint-plugin-js": "2.12.1",
70+
"@stylistic/eslint-plugin-js": "2.13.0",
7171
"@stylistic/stylelint-plugin": "3.1.1",
7272
"@types/dropzone": "5.7.9",
7373
"@types/jquery": "3.5.32",
@@ -79,8 +79,8 @@
7979
"@types/throttle-debounce": "5.0.2",
8080
"@types/tinycolor2": "1.4.6",
8181
"@types/toastify-js": "1.12.3",
82-
"@typescript-eslint/eslint-plugin": "8.18.1",
83-
"@typescript-eslint/parser": "8.18.1",
82+
"@typescript-eslint/eslint-plugin": "8.20.0",
83+
"@typescript-eslint/parser": "8.20.0",
8484
"@vitejs/plugin-vue": "5.2.1",
8585
"eslint": "8.57.0",
8686
"eslint-import-resolver-typescript": "3.7.0",
@@ -98,16 +98,16 @@
9898
"eslint-plugin-vue": "9.32.0",
9999
"eslint-plugin-vue-scoped-css": "2.9.0",
100100
"eslint-plugin-wc": "2.2.0",
101-
"happy-dom": "15.11.7",
101+
"happy-dom": "16.6.0",
102102
"markdownlint-cli": "0.43.0",
103103
"nolyfill": "1.0.43",
104-
"postcss-html": "1.7.0",
105-
"stylelint": "16.12.0",
104+
"postcss-html": "1.8.0",
105+
"stylelint": "16.13.2",
106106
"stylelint-declaration-block-no-ignored-properties": "2.8.0",
107-
"stylelint-declaration-strict-value": "1.10.6",
107+
"stylelint-declaration-strict-value": "1.10.7",
108108
"stylelint-value-no-unknown-custom-properties": "6.0.1",
109109
"svgo": "3.3.2",
110-
"type-fest": "4.30.2",
110+
"type-fest": "4.32.0",
111111
"updates": "16.4.1",
112112
"vite-string-plugin": "1.3.4",
113113
"vitest": "2.1.8",

poetry.lock

Lines changed: 43 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package-mode = false
55
python = "^3.10"
66

77
[tool.poetry.group.dev.dependencies]
8-
djlint = "1.36.3"
8+
djlint = "1.36.4"
99
yamllint = "1.35.1"
1010

1111
[tool.djlint]

routers/api/v1/repo/branch.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"code.gitea.io/gitea/models/db"
1313
git_model "code.gitea.io/gitea/models/git"
1414
"code.gitea.io/gitea/models/organization"
15+
repo_model "code.gitea.io/gitea/models/repo"
1516
user_model "code.gitea.io/gitea/models/user"
1617
"code.gitea.io/gitea/modules/git"
1718
"code.gitea.io/gitea/modules/gitrepo"
@@ -443,7 +444,14 @@ func UpdateBranch(ctx *context.APIContext) {
443444

444445
msg, err := repo_service.RenameBranch(ctx, repo, ctx.Doer, ctx.Repo.GitRepo, oldName, opt.Name)
445446
if err != nil {
446-
ctx.Error(http.StatusInternalServerError, "RenameBranch", err)
447+
switch {
448+
case repo_model.IsErrUserDoesNotHaveAccessToRepo(err):
449+
ctx.Error(http.StatusForbidden, "", "User must be a repo or site admin to rename default or protected branches.")
450+
case errors.Is(err, git_model.ErrBranchIsProtected):
451+
ctx.Error(http.StatusForbidden, "", "Branch is protected by glob-based protection rules.")
452+
default:
453+
ctx.Error(http.StatusInternalServerError, "RenameBranch", err)
454+
}
447455
return
448456
}
449457
if msg == "target_exist" {

routers/web/repo/setting/protected_branch.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package setting
55

66
import (
7+
"errors"
78
"fmt"
89
"net/http"
910
"net/url"
@@ -14,6 +15,7 @@ import (
1415
"code.gitea.io/gitea/models/organization"
1516
"code.gitea.io/gitea/models/perm"
1617
access_model "code.gitea.io/gitea/models/perm/access"
18+
repo_model "code.gitea.io/gitea/models/repo"
1719
"code.gitea.io/gitea/modules/base"
1820
"code.gitea.io/gitea/modules/templates"
1921
"code.gitea.io/gitea/modules/web"
@@ -351,9 +353,15 @@ func RenameBranchPost(ctx *context.Context) {
351353
msg, err := repository.RenameBranch(ctx, ctx.Repo.Repository, ctx.Doer, ctx.Repo.GitRepo, form.From, form.To)
352354
if err != nil {
353355
switch {
356+
case repo_model.IsErrUserDoesNotHaveAccessToRepo(err):
357+
ctx.Flash.Error(ctx.Tr("repo.branch.rename_default_or_protected_branch_error"))
358+
ctx.Redirect(fmt.Sprintf("%s/branches", ctx.Repo.RepoLink))
354359
case git_model.IsErrBranchAlreadyExists(err):
355360
ctx.Flash.Error(ctx.Tr("repo.branch.branch_already_exists", form.To))
356361
ctx.Redirect(fmt.Sprintf("%s/branches", ctx.Repo.RepoLink))
362+
case errors.Is(err, git_model.ErrBranchIsProtected):
363+
ctx.Flash.Error(ctx.Tr("repo.branch.rename_protected_branch_failed"))
364+
ctx.Redirect(fmt.Sprintf("%s/branches", ctx.Repo.RepoLink))
357365
default:
358366
ctx.ServerError("RenameBranch", err)
359367
}

services/repository/branch.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,29 @@ func RenameBranch(ctx context.Context, repo *repo_model.Repository, doer *user_m
416416
return "from_not_exist", nil
417417
}
418418

419+
perm, err := access_model.GetUserRepoPermission(ctx, repo, doer)
420+
if err != nil {
421+
return "", err
422+
}
423+
424+
isDefault := from == repo.DefaultBranch
425+
if isDefault && !perm.IsAdmin() {
426+
return "", repo_model.ErrUserDoesNotHaveAccessToRepo{
427+
UserID: doer.ID,
428+
RepoName: repo.LowerName,
429+
}
430+
}
431+
432+
// If from == rule name, admins are allowed to modify them.
433+
if protectedBranch, err := git_model.GetProtectedBranchRuleByName(ctx, repo.ID, from); err != nil {
434+
return "", err
435+
} else if protectedBranch != nil && !perm.IsAdmin() {
436+
return "", repo_model.ErrUserDoesNotHaveAccessToRepo{
437+
UserID: doer.ID,
438+
RepoName: repo.LowerName,
439+
}
440+
}
441+
419442
if err := git_model.RenameBranch(ctx, repo, from, to, func(ctx context.Context, isDefault bool) error {
420443
err2 := gitRepo.RenameBranch(from, to)
421444
if err2 != nil {

templates/repo/issue/sidebar/issue_dependencies.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
{{range .BlockingDependencies}}
2323
<div class="item dependency{{if .Issue.IsClosed}} is-closed{{end}} tw-flex tw-items-center tw-justify-between">
2424
<div class="item-left tw-flex tw-justify-center tw-flex-col tw-flex-1 gt-ellipsis">
25-
<a class="muted gt-ellipsis" href="{{.Issue.Link}}" data-tooltip-content="#{{.Issue.Index}} {{.Issue.Title | ctx.RenderUtils.RenderEmoji}}">
25+
<a class="muted issue-dependency-title gt-ellipsis" href="{{.Issue.Link}}" data-tooltip-content="#{{.Issue.Index}} {{.Issue.Title | ctx.RenderUtils.RenderEmoji}}">
2626
#{{.Issue.Index}} {{.Issue.Title | ctx.RenderUtils.RenderEmoji}}
2727
</a>
2828
<div class="text small gt-ellipsis" data-tooltip-content="{{.Repository.OwnerName}}/{{.Repository.Name}}">
@@ -54,7 +54,7 @@
5454
{{range .BlockedByDependencies}}
5555
<div class="item dependency{{if .Issue.IsClosed}} is-closed{{end}} tw-flex tw-items-center tw-justify-between">
5656
<div class="item-left tw-flex tw-justify-center tw-flex-col tw-flex-1 gt-ellipsis">
57-
<a class="muted gt-ellipsis" href="{{.Issue.Link}}" data-tooltip-content="#{{.Issue.Index}} {{.Issue.Title | ctx.RenderUtils.RenderEmoji}}">
57+
<a class="muted issue-dependency-title gt-ellipsis" href="{{.Issue.Link}}" data-tooltip-content="#{{.Issue.Index}} {{.Issue.Title | ctx.RenderUtils.RenderEmoji}}">
5858
#{{.Issue.Index}} {{.Issue.Title | ctx.RenderUtils.RenderEmoji}}
5959
</a>
6060
<div class="text small gt-ellipsis" data-tooltip-content="{{.Repository.OwnerName}}/{{.Repository.Name}}">
@@ -76,7 +76,7 @@
7676
<div class="item-left tw-flex tw-justify-center tw-flex-col tw-flex-1 gt-ellipsis">
7777
<div class="gt-ellipsis">
7878
<span data-tooltip-content="{{ctx.Locale.Tr "repo.issues.dependency.no_permission.can_remove"}}">{{svg "octicon-lock" 16}}</span>
79-
<span class="gt-ellipsis" data-tooltip-content="#{{.Issue.Index}} {{.Issue.Title | ctx.RenderUtils.RenderEmoji}}">
79+
<span class="gt-ellipsis issue-dependency-title" data-tooltip-content="#{{.Issue.Index}} {{.Issue.Title | ctx.RenderUtils.RenderEmoji}}">
8080
#{{.Issue.Index}} {{.Issue.Title | ctx.RenderUtils.RenderEmoji}}
8181
</span>
8282
</div>

0 commit comments

Comments
 (0)