Skip to content

Commit cf56c71

Browse files
authored
Merge branch 'main' into refactor-sha1
2 parents ccebcbc + f1d9f18 commit cf56c71

File tree

16 files changed

+132
-52
lines changed

16 files changed

+132
-52
lines changed

models/unit/unit.go

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"errors"
88
"fmt"
99
"strings"
10+
"sync/atomic"
1011

1112
"code.gitea.io/gitea/models/perm"
1213
"code.gitea.io/gitea/modules/container"
@@ -106,10 +107,23 @@ var (
106107
TypeExternalTracker,
107108
}
108109

109-
// DisabledRepoUnits contains the units that have been globally disabled
110-
DisabledRepoUnits = []Type{}
110+
disabledRepoUnitsAtomic atomic.Pointer[[]Type] // the units that have been globally disabled
111111
)
112112

113+
// DisabledRepoUnitsGet returns the globally disabled units, it is a quick patch to fix data-race during testing.
114+
// Because the queue worker might read when a test is mocking the value. FIXME: refactor to a clear solution later.
115+
func DisabledRepoUnitsGet() []Type {
116+
v := disabledRepoUnitsAtomic.Load()
117+
if v == nil {
118+
return nil
119+
}
120+
return *v
121+
}
122+
123+
func DisabledRepoUnitsSet(v []Type) {
124+
disabledRepoUnitsAtomic.Store(&v)
125+
}
126+
113127
// Get valid set of default repository units from settings
114128
func validateDefaultRepoUnits(defaultUnits, settingDefaultUnits []Type) []Type {
115129
units := defaultUnits
@@ -127,7 +141,7 @@ func validateDefaultRepoUnits(defaultUnits, settingDefaultUnits []Type) []Type {
127141
}
128142

129143
// Remove disabled units
130-
for _, disabledUnit := range DisabledRepoUnits {
144+
for _, disabledUnit := range DisabledRepoUnitsGet() {
131145
for i, unit := range units {
132146
if unit == disabledUnit {
133147
units = append(units[:i], units[i+1:]...)
@@ -140,11 +154,11 @@ func validateDefaultRepoUnits(defaultUnits, settingDefaultUnits []Type) []Type {
140154

141155
// LoadUnitConfig load units from settings
142156
func LoadUnitConfig() error {
143-
var invalidKeys []string
144-
DisabledRepoUnits, invalidKeys = FindUnitTypes(setting.Repository.DisabledRepoUnits...)
157+
disabledRepoUnits, invalidKeys := FindUnitTypes(setting.Repository.DisabledRepoUnits...)
145158
if len(invalidKeys) > 0 {
146159
log.Warn("Invalid keys in disabled repo units: %s", strings.Join(invalidKeys, ", "))
147160
}
161+
DisabledRepoUnitsSet(disabledRepoUnits)
148162

149163
setDefaultRepoUnits, invalidKeys := FindUnitTypes(setting.Repository.DefaultRepoUnits...)
150164
if len(invalidKeys) > 0 {
@@ -167,7 +181,7 @@ func LoadUnitConfig() error {
167181

168182
// UnitGlobalDisabled checks if unit type is global disabled
169183
func (u Type) UnitGlobalDisabled() bool {
170-
for _, ud := range DisabledRepoUnits {
184+
for _, ud := range DisabledRepoUnitsGet() {
171185
if u == ud {
172186
return true
173187
}

models/unit/unit_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import (
1414
func TestLoadUnitConfig(t *testing.T) {
1515
t.Run("regular", func(t *testing.T) {
1616
defer func(disabledRepoUnits, defaultRepoUnits, defaultForkRepoUnits []Type) {
17-
DisabledRepoUnits = disabledRepoUnits
17+
DisabledRepoUnitsSet(disabledRepoUnits)
1818
DefaultRepoUnits = defaultRepoUnits
1919
DefaultForkRepoUnits = defaultForkRepoUnits
20-
}(DisabledRepoUnits, DefaultRepoUnits, DefaultForkRepoUnits)
20+
}(DisabledRepoUnitsGet(), DefaultRepoUnits, DefaultForkRepoUnits)
2121
defer func(disabledRepoUnits, defaultRepoUnits, defaultForkRepoUnits []string) {
2222
setting.Repository.DisabledRepoUnits = disabledRepoUnits
2323
setting.Repository.DefaultRepoUnits = defaultRepoUnits
@@ -28,16 +28,16 @@ func TestLoadUnitConfig(t *testing.T) {
2828
setting.Repository.DefaultRepoUnits = []string{"repo.code", "repo.releases", "repo.issues", "repo.pulls"}
2929
setting.Repository.DefaultForkRepoUnits = []string{"repo.releases"}
3030
assert.NoError(t, LoadUnitConfig())
31-
assert.Equal(t, []Type{TypeIssues}, DisabledRepoUnits)
31+
assert.Equal(t, []Type{TypeIssues}, DisabledRepoUnitsGet())
3232
assert.Equal(t, []Type{TypeCode, TypeReleases, TypePullRequests}, DefaultRepoUnits)
3333
assert.Equal(t, []Type{TypeReleases}, DefaultForkRepoUnits)
3434
})
3535
t.Run("invalid", func(t *testing.T) {
3636
defer func(disabledRepoUnits, defaultRepoUnits, defaultForkRepoUnits []Type) {
37-
DisabledRepoUnits = disabledRepoUnits
37+
DisabledRepoUnitsSet(disabledRepoUnits)
3838
DefaultRepoUnits = defaultRepoUnits
3939
DefaultForkRepoUnits = defaultForkRepoUnits
40-
}(DisabledRepoUnits, DefaultRepoUnits, DefaultForkRepoUnits)
40+
}(DisabledRepoUnitsGet(), DefaultRepoUnits, DefaultForkRepoUnits)
4141
defer func(disabledRepoUnits, defaultRepoUnits, defaultForkRepoUnits []string) {
4242
setting.Repository.DisabledRepoUnits = disabledRepoUnits
4343
setting.Repository.DefaultRepoUnits = defaultRepoUnits
@@ -48,16 +48,16 @@ func TestLoadUnitConfig(t *testing.T) {
4848
setting.Repository.DefaultRepoUnits = []string{"repo.code", "invalid.2", "repo.releases", "repo.issues", "repo.pulls"}
4949
setting.Repository.DefaultForkRepoUnits = []string{"invalid.3", "repo.releases"}
5050
assert.NoError(t, LoadUnitConfig())
51-
assert.Equal(t, []Type{TypeIssues}, DisabledRepoUnits)
51+
assert.Equal(t, []Type{TypeIssues}, DisabledRepoUnitsGet())
5252
assert.Equal(t, []Type{TypeCode, TypeReleases, TypePullRequests}, DefaultRepoUnits)
5353
assert.Equal(t, []Type{TypeReleases}, DefaultForkRepoUnits)
5454
})
5555
t.Run("duplicate", func(t *testing.T) {
5656
defer func(disabledRepoUnits, defaultRepoUnits, defaultForkRepoUnits []Type) {
57-
DisabledRepoUnits = disabledRepoUnits
57+
DisabledRepoUnitsSet(disabledRepoUnits)
5858
DefaultRepoUnits = defaultRepoUnits
5959
DefaultForkRepoUnits = defaultForkRepoUnits
60-
}(DisabledRepoUnits, DefaultRepoUnits, DefaultForkRepoUnits)
60+
}(DisabledRepoUnitsGet(), DefaultRepoUnits, DefaultForkRepoUnits)
6161
defer func(disabledRepoUnits, defaultRepoUnits, defaultForkRepoUnits []string) {
6262
setting.Repository.DisabledRepoUnits = disabledRepoUnits
6363
setting.Repository.DefaultRepoUnits = defaultRepoUnits
@@ -68,16 +68,16 @@ func TestLoadUnitConfig(t *testing.T) {
6868
setting.Repository.DefaultRepoUnits = []string{"repo.code", "repo.releases", "repo.issues", "repo.pulls", "repo.code"}
6969
setting.Repository.DefaultForkRepoUnits = []string{"repo.releases", "repo.releases"}
7070
assert.NoError(t, LoadUnitConfig())
71-
assert.Equal(t, []Type{TypeIssues}, DisabledRepoUnits)
71+
assert.Equal(t, []Type{TypeIssues}, DisabledRepoUnitsGet())
7272
assert.Equal(t, []Type{TypeCode, TypeReleases, TypePullRequests}, DefaultRepoUnits)
7373
assert.Equal(t, []Type{TypeReleases}, DefaultForkRepoUnits)
7474
})
7575
t.Run("empty_default", func(t *testing.T) {
7676
defer func(disabledRepoUnits, defaultRepoUnits, defaultForkRepoUnits []Type) {
77-
DisabledRepoUnits = disabledRepoUnits
77+
DisabledRepoUnitsSet(disabledRepoUnits)
7878
DefaultRepoUnits = defaultRepoUnits
7979
DefaultForkRepoUnits = defaultForkRepoUnits
80-
}(DisabledRepoUnits, DefaultRepoUnits, DefaultForkRepoUnits)
80+
}(DisabledRepoUnitsGet(), DefaultRepoUnits, DefaultForkRepoUnits)
8181
defer func(disabledRepoUnits, defaultRepoUnits, defaultForkRepoUnits []string) {
8282
setting.Repository.DisabledRepoUnits = disabledRepoUnits
8383
setting.Repository.DefaultRepoUnits = defaultRepoUnits
@@ -88,7 +88,7 @@ func TestLoadUnitConfig(t *testing.T) {
8888
setting.Repository.DefaultRepoUnits = []string{}
8989
setting.Repository.DefaultForkRepoUnits = []string{"repo.releases", "repo.releases"}
9090
assert.NoError(t, LoadUnitConfig())
91-
assert.Equal(t, []Type{TypeIssues}, DisabledRepoUnits)
91+
assert.Equal(t, []Type{TypeIssues}, DisabledRepoUnitsGet())
9292
assert.ElementsMatch(t, []Type{TypeCode, TypePullRequests, TypeReleases, TypeUncyclo, TypePackages, TypeProjects, TypeActions}, DefaultRepoUnits)
9393
assert.Equal(t, []Type{TypeReleases}, DefaultForkRepoUnits)
9494
})

modules/util/color.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright 2023 The Gitea Authors. All rights reserved.
22
// SPDX-License-Identifier: MIT
3+
34
package util
45

56
import (
@@ -8,7 +9,7 @@ import (
89
"strings"
910
)
1011

11-
// Get color as RGB values in 0..255 range from the hex color string (with or without #)
12+
// HexToRBGColor parses color as RGB values in 0..255 range from the hex color string (with or without #)
1213
func HexToRBGColor(colorString string) (float64, float64, float64) {
1314
hexString := colorString
1415
if strings.HasPrefix(colorString, "#") {
@@ -35,7 +36,7 @@ func HexToRBGColor(colorString string) (float64, float64, float64) {
3536
return r, g, b
3637
}
3738

38-
// Returns relative luminance for a SRGB color - https://en.wikipedia.org/wiki/Relative_luminance
39+
// GetRelativeLuminance returns relative luminance for a SRGB color - https://en.wikipedia.org/wiki/Relative_luminance
3940
// Keep this in sync with web_src/js/utils/color.js
4041
func GetRelativeLuminance(color string) float64 {
4142
r, g, b := HexToRBGColor(color)
@@ -46,8 +47,8 @@ func UseLightText(backgroundColor string) bool {
4647
return GetRelativeLuminance(backgroundColor) < 0.453
4748
}
4849

49-
// Given a background color, returns a black or white foreground color that the highest
50-
// contrast ratio. In the future, the APCA contrast function, or CSS `contrast-color` will be better.
50+
// ContrastColor returns a black or white foreground color that the highest contrast ratio.
51+
// In the future, the APCA contrast function, or CSS `contrast-color` will be better.
5152
// https://github.com/color-js/color.js/blob/eb7b53f7a13bb716ec8b28c7a56f052cd599acd9/src/contrast/APCA.js#L42
5253
func ContrastColor(backgroundColor string) string {
5354
if UseLightText(backgroundColor) {

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3415,6 +3415,7 @@ error.unit_not_allowed = You are not allowed to access this repository section.
34153415
title = Packages
34163416
desc = Manage repository packages.
34173417
empty = There are no packages yet.
3418+
no_metadata = No metadata.
34183419
empty.documentation = For more information on the package registry, see <a target="_blank" rel="noopener noreferrer" href="%s">the documentation</a>.
34193420
empty.repo = Did you upload a package, but it's not shown here? Go to <a href="%[1]s">package settings</a> and link it to this repo.
34203421
registry.documentation = For more information on the %s registry, see <a target="_blank" rel="noopener noreferrer" href="%s">the documentation</a>.

routers/web/auth/oauth.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,16 @@ func GrantApplicationOAuth(ctx *context.Context) {
541541
ctx.Error(http.StatusBadRequest)
542542
return
543543
}
544+
545+
if !form.Granted {
546+
handleAuthorizeError(ctx, AuthorizeError{
547+
State: form.State,
548+
ErrorDescription: "the request is denied",
549+
ErrorCode: ErrorCodeAccessDenied,
550+
}, form.RedirectURI)
551+
return
552+
}
553+
544554
app, err := auth.GetOAuth2ApplicationByClientID(ctx, form.ClientID)
545555
if err != nil {
546556
ctx.ServerError("GetOAuth2ApplicationByClientID", err)

services/forms/user_form.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ func (f *AuthorizationForm) Validate(req *http.Request, errs binding.Errors) bin
161161
// GrantApplicationForm form for authorizing oauth2 clients
162162
type GrantApplicationForm struct {
163163
ClientID string `binding:"Required"`
164+
Granted bool
164165
RedirectURI string
165166
State string
166167
Scope string

templates/package/content/maven.tmpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
{{if eq .PackageDescriptor.Package.Type "maven"}}
1+
{{if and (eq .PackageDescriptor.Package.Type "maven") (not .PackageDescriptor.Metadata)}}
2+
<h4 class="ui top attached header">{{ctx.Locale.Tr "packages.installation"}}</h4>
3+
<div class="ui attached segment">{{ctx.Locale.Tr "packages.no_metadata"}}</div>
4+
{{end}}
5+
{{if and (eq .PackageDescriptor.Package.Type "maven") .PackageDescriptor.Metadata}}
26
<h4 class="ui top attached header">{{ctx.Locale.Tr "packages.installation"}}</h4>
37
<div class="ui attached segment">
48
<div class="ui form">

templates/package/metadata/maven.tmpl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
{{if eq .PackageDescriptor.Package.Type "maven"}}
1+
{{if and (eq .PackageDescriptor.Package.Type "maven") (not .PackageDescriptor.Metadata)}}
2+
<div class="item">{{svg "octicon-note" 16 "tw-mr-2"}} {{ctx.Locale.Tr "packages.no_metadata"}}</div>
3+
{{end}}
4+
{{if and (eq .PackageDescriptor.Package.Type "maven") .PackageDescriptor.Metadata}}
25
{{if .PackageDescriptor.Metadata.Name}}<div class="item">{{svg "octicon-note" 16 "tw-mr-2"}} {{.PackageDescriptor.Metadata.Name}}</div>{{end}}
36
{{if .PackageDescriptor.Metadata.ProjectURL}}<div class="item">{{svg "octicon-link-external" 16 "tw-mr-2"}} <a href="{{.PackageDescriptor.Metadata.ProjectURL}}" target="_blank" rel="noopener noreferrer me">{{ctx.Locale.Tr "packages.details.project_site"}}</a></div>{{end}}
47
{{range .PackageDescriptor.Metadata.Licenses}}<div class="item" title="{{ctx.Locale.Tr "packages.details.license"}}">{{svg "octicon-law" 16 "tw-mr-2"}} {{.}}</div>{{end}}

templates/projects/view.tmpl

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,14 @@
6868
{{range .Columns}}
6969
<div class="ui segment project-column"{{if .Color}} style="background: {{.Color}} !important; color: {{ContrastColor .Color}} !important"{{end}} data-id="{{.ID}}" data-sorting="{{.Sorting}}" data-url="{{$.Link}}/{{.ID}}">
7070
<div class="project-column-header{{if $canWriteProject}} tw-cursor-grab{{end}}">
71-
<div class="ui large label project-column-title tw-py-1">
72-
<div class="ui small circular grey label project-column-issue-count">
73-
{{.NumIssues ctx}}
74-
</div>
75-
<span class="project-column-title-label">{{.Title}}</span>
71+
<div class="ui circular label project-column-issue-count">
72+
{{.NumIssues ctx}}
7673
</div>
74+
<div class="project-column-title-label gt-ellipsis">{{.Title}}</div>
7775
{{if $canWriteProject}}
78-
<div class="ui dropdown jump item">
79-
<div class="tw-px-2">
80-
{{svg "octicon-kebab-horizontal"}}
81-
</div>
82-
<div class="menu user-menu">
76+
<div class="ui dropdown tw-p-1">
77+
{{svg "octicon-kebab-horizontal"}}
78+
<div class="menu">
8379
<a class="item show-modal button" data-modal="#edit-project-column-modal-{{.ID}}">
8480
{{svg "octicon-pencil"}}
8581
{{ctx.Locale.Tr "repo.projects.column.edit"}}

templates/repo/diff/section_split.tmpl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{{$file := .file}}
2+
{{$blobExcerptRepoLink := or ctx.RootData.CommitRepoLink ctx.RootData.RepoLink}}
23
<colgroup>
34
<col width="50">
45
<col width="10">
@@ -18,17 +19,17 @@
1819
<td class="lines-num lines-num-old">
1920
<div class="tw-flex">
2021
{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}}
21-
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=down&wiki={{$.root.PageIsUncyclo}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
22+
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=down&wiki={{$.root.PageIsUncyclo}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
2223
{{svg "octicon-fold-down"}}
2324
</button>
2425
{{end}}
2526
{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4)}}
26-
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=up&wiki={{$.root.PageIsUncyclo}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
27+
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=up&wiki={{$.root.PageIsUncyclo}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
2728
{{svg "octicon-fold-up"}}
2829
</button>
2930
{{end}}
3031
{{if eq $line.GetExpandDirection 2}}
31-
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=&wiki={{$.root.PageIsUncyclo}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
32+
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=&wiki={{$.root.PageIsUncyclo}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
3233
{{svg "octicon-fold"}}
3334
</button>
3435
{{end}}

templates/repo/diff/section_unified.tmpl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{{$file := .file}}
2+
{{$blobExcerptRepoLink := or ctx.RootData.CommitRepoLink ctx.RootData.RepoLink}}
23
<colgroup>
34
<col width="50">
45
<col width="50">
@@ -14,17 +15,17 @@
1415
<td colspan="2" class="lines-num">
1516
<div class="tw-flex">
1617
{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}}
17-
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=down&wiki={{$.root.PageIsUncyclo}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
18+
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=down&wiki={{$.root.PageIsUncyclo}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
1819
{{svg "octicon-fold-down"}}
1920
</button>
2021
{{end}}
2122
{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4)}}
22-
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=up&wiki={{$.root.PageIsUncyclo}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
23+
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=up&wiki={{$.root.PageIsUncyclo}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
2324
{{svg "octicon-fold-up"}}
2425
</button>
2526
{{end}}
2627
{{if eq $line.GetExpandDirection 2}}
27-
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=&wiki={{$.root.PageIsUncyclo}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
28+
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=&wiki={{$.root.PageIsUncyclo}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
2829
{{svg "octicon-fold"}}
2930
</button>
3031
{{end}}

templates/user/auth/grant.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
<input type="hidden" name="scope" value="{{.Scope}}">
2424
<input type="hidden" name="nonce" value="{{.Nonce}}">
2525
<input type="hidden" name="redirect_uri" value="{{.RedirectURI}}">
26-
<button type="submit" id="authorize-app" value="{{ctx.Locale.Tr "auth.authorize_application"}}" class="ui red inline button">{{ctx.Locale.Tr "auth.authorize_application"}}</button>
27-
<a href="{{.RedirectURI}}" class="ui basic primary inline button">Cancel</a>
26+
<button type="submit" id="authorize-app" name="granted" value="true" class="ui red inline button">{{ctx.Locale.Tr "auth.authorize_application"}}</button>
27+
<button type="submit" name="granted" value="false" class="ui basic primary inline button">{{ctx.Locale.Tr "cancel"}}</button>
2828
</form>
2929
</div>
3030
</div>

tests/integration/api_packages_maven_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"code.gitea.io/gitea/models/unittest"
1616
user_model "code.gitea.io/gitea/models/user"
1717
"code.gitea.io/gitea/modules/packages/maven"
18+
"code.gitea.io/gitea/modules/test"
1819
"code.gitea.io/gitea/tests"
1920

2021
"github.com/stretchr/testify/assert"
@@ -241,4 +242,13 @@ func TestPackageMaven(t *testing.T) {
241242
putFile(t, fmt.Sprintf("/%s/maven-metadata.xml", snapshotVersion), "test", http.StatusCreated)
242243
putFile(t, fmt.Sprintf("/%s/maven-metadata.xml", snapshotVersion), "test-overwrite", http.StatusCreated)
243244
})
245+
246+
t.Run("InvalidFile", func(t *testing.T) {
247+
ver := packageVersion + "-invalid"
248+
putFile(t, fmt.Sprintf("/%s/%s", ver, filename), "any invalid content", http.StatusCreated)
249+
req := NewRequestf(t, "GET", "/%s/-/packages/maven/%s-%s/%s", user.Name, groupID, artifactID, ver)
250+
resp := MakeRequest(t, req, http.StatusOK)
251+
assert.Contains(t, resp.Body.String(), "No metadata.")
252+
assert.True(t, test.IsNormalPageCompleted(resp.Body.String()))
253+
})
244254
}

0 commit comments

Comments
 (0)