Skip to content

Commit 064c5ad

Browse files
authored
Merge branch 'main' into main
2 parents 5b52a1f + dcb648e commit 064c5ad

19 files changed

+179
-94
lines changed

options/locale/locale_en-US.ini

+2
Original file line numberDiff line numberDiff line change
@@ -1786,6 +1786,8 @@ pulls.status_checks_failure = Some checks failed
17861786
pulls.status_checks_error = Some checks reported errors
17871787
pulls.status_checks_requested = Required
17881788
pulls.status_checks_details = Details
1789+
pulls.status_checks_hide_all = Hide all checks
1790+
pulls.status_checks_show_all = Show all checks
17891791
pulls.update_branch = Update branch by merge
17901792
pulls.update_branch_rebase = Update branch by rebase
17911793
pulls.update_branch_success = Branch update was successful

routers/web/githttp.go

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright 2023 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package web
5+
6+
import (
7+
"net/http"
8+
9+
"code.gitea.io/gitea/modules/context"
10+
"code.gitea.io/gitea/modules/setting"
11+
"code.gitea.io/gitea/modules/web"
12+
"code.gitea.io/gitea/routers/web/repo"
13+
context_service "code.gitea.io/gitea/services/context"
14+
)
15+
16+
func requireSignIn(ctx *context.Context) {
17+
if !setting.Service.RequireSignInView {
18+
return
19+
}
20+
21+
// rely on the results of Contexter
22+
if !ctx.IsSigned {
23+
// TODO: support digit auth - which would be Authorization header with digit
24+
ctx.Resp.Header().Set("WWW-Authenticate", `Basic realm="Gitea"`)
25+
ctx.Error(http.StatusUnauthorized)
26+
}
27+
}
28+
29+
func gitHTTPRouters(m *web.Route) {
30+
m.Group("", func() {
31+
m.PostOptions("/git-upload-pack", repo.ServiceUploadPack)
32+
m.PostOptions("/git-receive-pack", repo.ServiceReceivePack)
33+
m.GetOptions("/info/refs", repo.GetInfoRefs)
34+
m.GetOptions("/HEAD", repo.GetTextFile("HEAD"))
35+
m.GetOptions("/objects/info/alternates", repo.GetTextFile("objects/info/alternates"))
36+
m.GetOptions("/objects/info/http-alternates", repo.GetTextFile("objects/info/http-alternates"))
37+
m.GetOptions("/objects/info/packs", repo.GetInfoPacks)
38+
m.GetOptions("/objects/info/{file:[^/]*}", repo.GetTextFile(""))
39+
m.GetOptions("/objects/{head:[0-9a-f]{2}}/{hash:[0-9a-f]{38}}", repo.GetLooseObject)
40+
m.GetOptions("/objects/pack/pack-{file:[0-9a-f]{40}}.pack", repo.GetPackFile)
41+
m.GetOptions("/objects/pack/pack-{file:[0-9a-f]{40}}.idx", repo.GetIdxFile)
42+
}, ignSignInAndCsrf, requireSignIn, repo.HTTPGitEnabledHandler, repo.CorsHandler(), context_service.UserAssignmentWeb())
43+
}
File renamed without changes.
File renamed without changes.

routers/web/web.go

+4-14
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,16 @@ func Routes() *web.Route {
276276
return routes
277277
}
278278

279+
var ignSignInAndCsrf = verifyAuthWithOptions(&common.VerifyOptions{DisableCSRF: true})
280+
279281
// registerRoutes register routes
280282
func registerRoutes(m *web.Route) {
281283
reqSignIn := verifyAuthWithOptions(&common.VerifyOptions{SignInRequired: true})
282284
reqSignOut := verifyAuthWithOptions(&common.VerifyOptions{SignOutRequired: true})
283285
// TODO: rename them to "optSignIn", which means that the "sign-in" could be optional, depends on the VerifyOptions (RequireSignInView)
284286
ignSignIn := verifyAuthWithOptions(&common.VerifyOptions{SignInRequired: setting.Service.RequireSignInView})
285287
ignExploreSignIn := verifyAuthWithOptions(&common.VerifyOptions{SignInRequired: setting.Service.RequireSignInView || setting.Service.Explore.RequireSigninView})
286-
ignSignInAndCsrf := verifyAuthWithOptions(&common.VerifyOptions{DisableCSRF: true})
288+
287289
validation.AddBindingRules()
288290

289291
linkAccountEnabled := func(ctx *context.Context) {
@@ -1516,19 +1518,7 @@ func registerRoutes(m *web.Route) {
15161518
})
15171519
}, ignSignInAndCsrf, lfsServerEnabled)
15181520

1519-
m.Group("", func() {
1520-
m.PostOptions("/git-upload-pack", repo.ServiceUploadPack)
1521-
m.PostOptions("/git-receive-pack", repo.ServiceReceivePack)
1522-
m.GetOptions("/info/refs", repo.GetInfoRefs)
1523-
m.GetOptions("/HEAD", repo.GetTextFile("HEAD"))
1524-
m.GetOptions("/objects/info/alternates", repo.GetTextFile("objects/info/alternates"))
1525-
m.GetOptions("/objects/info/http-alternates", repo.GetTextFile("objects/info/http-alternates"))
1526-
m.GetOptions("/objects/info/packs", repo.GetInfoPacks)
1527-
m.GetOptions("/objects/info/{file:[^/]*}", repo.GetTextFile(""))
1528-
m.GetOptions("/objects/{head:[0-9a-f]{2}}/{hash:[0-9a-f]{38}}", repo.GetLooseObject)
1529-
m.GetOptions("/objects/pack/pack-{file:[0-9a-f]{40}}.pack", repo.GetPackFile)
1530-
m.GetOptions("/objects/pack/pack-{file:[0-9a-f]{40}}.idx", repo.GetIdxFile)
1531-
}, ignSignInAndCsrf, repo.HTTPGitEnabledHandler, repo.CorsHandler(), context_service.UserAssignmentWeb())
1521+
gitHTTPRouters(m)
15321522
})
15331523
})
15341524
// ***** END: Repository *****

templates/repo/commit_page.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
{{end}}
2020
<div class="ui top attached header clearing segment gt-relative commit-header {{$class}}">
2121
<div class="gt-df gt-mb-4 gt-fw">
22-
<h3 class="gt-mb-0 gt-f1"><span class="commit-summary" title="{{.Commit.Summary}}">{{RenderCommitMessage $.Context .Commit.Message $.RepoLink ($.Repository.ComposeMetas ctx)}}</span>{{template "repo/commit_statuses" dict "Status" .CommitStatus "Statuses" .CommitStatuses "root" $}}</h3>
22+
<h3 class="gt-mb-0 gt-f1"><span class="commit-summary" title="{{.Commit.Summary}}">{{RenderCommitMessage $.Context .Commit.Message $.RepoLink ($.Repository.ComposeMetas ctx)}}</span>{{template "repo/commit_statuses" dict "Status" .CommitStatus "Statuses" .CommitStatuses}}</h3>
2323
{{if not $.PageIsWiki}}
2424
<div>
2525
<a class="ui primary tiny button" href="{{.SourcePath}}">

templates/repo/commit_statuses.tmpl

+2-10
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,7 @@
88
{{template "repo/commit_status" .Status}}
99
</span>
1010
{{end}}
11-
<div class="tippy-target ui relaxed list divided">
12-
{{range .Statuses}}
13-
<div class="ui item singular-status gt-df">
14-
{{template "repo/commit_status" .}}
15-
<span class="ui gt-ml-3 gt-f1">{{.Context}} <span class="text grey">{{.Description}}</span></span>
16-
{{if .TargetURL}}
17-
<a class="gt-ml-3" href="{{.TargetURL}}" target="_blank" rel="noopener noreferrer">{{ctx.Locale.Tr "repo.pulls.status_checks_details"}}</a>
18-
{{end}}
19-
</div>
20-
{{end}}
11+
<div class="tippy-target">
12+
{{template "repo/pulls/status" (dict "CommitStatuses" .Statuses "CommitStatus" .Status)}}
2113
</div>
2214
{{end}}

templates/repo/commits_list.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
{{if IsMultilineCommitMessage .Message}}
6767
<button class="ui button js-toggle-commit-body ellipsis-button" aria-expanded="false">...</button>
6868
{{end}}
69-
{{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses "root" $}}
69+
{{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses}}
7070
{{if IsMultilineCommitMessage .Message}}
7171
<pre class="commit-body gt-hidden">{{RenderCommitBody $.Context .Message $commitRepoLink ($.Repository.ComposeMetas ctx)}}</pre>
7272
{{end}}

templates/repo/commits_list_small.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
{{$commitLink:= printf "%s/commit/%s" $.comment.Issue.PullRequest.BaseRepo.Link (PathEscape .ID.String)}}
1515

1616
<span class="shabox gt-df gt-ac gt-float-right">
17-
{{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses "root" $.root}}
17+
{{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses}}
1818
{{$class := "ui sha label"}}
1919
{{if .Signature}}
2020
{{$class = (print $class " isSigned")}}

templates/repo/issue/view_content/pull.tmpl

+8-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@
2020
{{- else if .Issue.PullRequest.CanAutoMerge}}green
2121
{{- else}}red{{end}}">{{svg "octicon-git-merge" 40}}</div>
2222
<div class="content">
23-
{{template "repo/pulls/status" .}}
23+
<div class="ui attached segment fitted">
24+
{{template "repo/pulls/status" (dict
25+
"CommitStatus" .LatestCommitStatus
26+
"CommitStatuses" .LatestCommitStatuses
27+
"ShowHideChecks" true
28+
"is_context_required" .is_context_required
29+
)}}
30+
</div>
2431
{{$showGeneralMergeForm := false}}
2532
<div class="ui attached merge-section segment {{if not $.LatestCommitStatus}}no-header{{end}} flex-items-block">
2633
{{if .Issue.PullRequest.HasMerged}}

templates/repo/pulls/status.tmpl

+42-25
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,51 @@
1-
{{if $.LatestCommitStatus}}
2-
{{if not $.Issue.PullRequest.HasMerged}}
3-
<div class="ui top attached header">
4-
{{if eq .LatestCommitStatus.State "pending"}}
5-
{{ctx.Locale.Tr "repo.pulls.status_checking"}}
6-
{{else if eq .LatestCommitStatus.State "success"}}
7-
{{ctx.Locale.Tr "repo.pulls.status_checks_success"}}
8-
{{else if eq .LatestCommitStatus.State "warning"}}
9-
{{ctx.Locale.Tr "repo.pulls.status_checks_warning"}}
10-
{{else if eq .LatestCommitStatus.State "failure"}}
11-
{{ctx.Locale.Tr "repo.pulls.status_checks_failure"}}
12-
{{else if eq .LatestCommitStatus.State "error"}}
13-
{{ctx.Locale.Tr "repo.pulls.status_checks_error"}}
14-
{{else}}
15-
{{ctx.Locale.Tr "repo.pulls.status_checking"}}
16-
{{end}}
17-
</div>
18-
{{end}}
1+
{{/*
2+
Template Attributes:
3+
* CommitStatus: summary of all commit status state
4+
* CommitStatuses: all commit status elements
5+
* ShowHideChecks: whether use a button to show/hide the checks
6+
* is_context_required: Used in pull request commit status check table
7+
*/}}
8+
9+
{{if .CommitStatus}}
10+
<div class="commit-status-panel">
11+
<div class="ui top attached header commit-status-header">
12+
{{if eq .CommitStatus.State "pending"}}
13+
{{ctx.Locale.Tr "repo.pulls.status_checking"}}
14+
{{else if eq .CommitStatus.State "success"}}
15+
{{ctx.Locale.Tr "repo.pulls.status_checks_success"}}
16+
{{else if eq .CommitStatus.State "warning"}}
17+
{{ctx.Locale.Tr "repo.pulls.status_checks_warning"}}
18+
{{else if eq .CommitStatus.State "failure"}}
19+
{{ctx.Locale.Tr "repo.pulls.status_checks_failure"}}
20+
{{else if eq .CommitStatus.State "error"}}
21+
{{ctx.Locale.Tr "repo.pulls.status_checks_error"}}
22+
{{else}}
23+
{{ctx.Locale.Tr "repo.pulls.status_checking"}}
24+
{{end}}
1925

20-
{{range $.LatestCommitStatuses}}
21-
<div class="ui attached segment pr-status">
22-
{{template "repo/commit_status" .}}
23-
<div class="status-context">
24-
<span>{{.Context}} <span class="text grey">{{.Description}}</span></span>
26+
{{if .ShowHideChecks}}
27+
<div class="ui right">
28+
<button class="commit-status-hide-checks btn interact-fg"
29+
data-show-all="{{ctx.Locale.Tr "repo.pulls.status_checks_show_all"}}"
30+
data-hide-all="{{ctx.Locale.Tr "repo.pulls.status_checks_hide_all"}}">
31+
{{ctx.Locale.Tr "repo.pulls.status_checks_hide_all"}}</button>
32+
</div>
33+
{{end}}
34+
</div>
35+
36+
<div class="commit-status-list">
37+
{{range .CommitStatuses}}
38+
<div class="commit-status-item">
39+
{{template "repo/commit_status" .}}
40+
<div class="status-context gt-ellipsis">{{.Context}} <span class="text light-2">{{.Description}}</span></div>
2541
<div class="ui status-details">
2642
{{if $.is_context_required}}
2743
{{if (call $.is_context_required .Context)}}<div class="ui label">{{ctx.Locale.Tr "repo.pulls.status_checks_requested"}}</div>{{end}}
2844
{{end}}
2945
<span>{{if .TargetURL}}<a href="{{.TargetURL}}">{{ctx.Locale.Tr "repo.pulls.status_checks_details"}}</a>{{end}}</span>
3046
</div>
3147
</div>
32-
</div>
33-
{{end}}
48+
{{end}}
49+
</div>
50+
</div>
3451
{{end}}

templates/repo/view_list.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
{{template "repo/shabox_badge" dict "root" $ "verification" .LatestCommitVerification}}
2525
{{end}}
2626
</a>
27-
{{template "repo/commit_statuses" dict "Status" .LatestCommitStatus "Statuses" .LatestCommitStatuses "root" $}}
27+
{{template "repo/commit_statuses" dict "Status" .LatestCommitStatus "Statuses" .LatestCommitStatuses}}
2828
{{$commitLink:= printf "%s/commit/%s" .RepoLink (PathEscape .LatestCommit.ID.String)}}
2929
<span class="grey commit-summary" title="{{.LatestCommit.Summary}}"><span class="message-wrapper">{{RenderCommitMessageLinkSubject $.Context .LatestCommit.Message $.RepoLink $commitLink ($.Repository.ComposeMetas ctx)}}</span>
3030
{{if IsMultilineCommitMessage .LatestCommit.Message}}

templates/shared/issuelist.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<a class="gt-no-underline issue-title" href="{{if .Link}}{{.Link}}{{else}}{{$.Link}}/{{.Index}}{{end}}">{{RenderEmoji $.Context .Title | RenderCodeBlock}}</a>
1717
{{if .IsPull}}
1818
{{if (index $.CommitStatuses .PullRequest.ID)}}
19-
{{template "repo/commit_statuses" dict "Status" (index $.CommitLastStatus .PullRequest.ID) "Statuses" (index $.CommitStatuses .PullRequest.ID) "root" $}}
19+
{{template "repo/commit_statuses" dict "Status" (index $.CommitLastStatus .PullRequest.ID) "Statuses" (index $.CommitStatuses .PullRequest.ID)}}
2020
{{end}}
2121
{{end}}
2222
<span class="labels-list gt-ml-2">

web_src/css/modules/tippy.css

+35-22
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
}
77

88
[data-tippy-root] {
9-
max-width: calc(100vw - 10px);
9+
max-width: calc(100vw - 32px);
1010
}
1111

1212
.tippy-box {
@@ -18,37 +18,59 @@
1818
font-size: 1rem;
1919
}
2020

21+
.tippy-content {
22+
position: relative;
23+
padding: 1rem; /* if you need different padding, use different data-theme */
24+
z-index: 1;
25+
}
26+
27+
/* tooltip theme for text tooltips */
28+
2129
.tippy-box[data-theme="tooltip"] {
2230
background-color: var(--color-tooltip-bg);
2331
color: var(--color-tooltip-text);
2432
border: none;
2533
}
2634

35+
.tippy-box[data-theme="tooltip"] .tippy-content {
36+
padding: 0.5rem 1rem;
37+
}
38+
39+
.tippy-box[data-theme="tooltip"] .tippy-svg-arrow-inner,
40+
.tippy-box[data-theme="tooltip"] .tippy-svg-arrow-outer {
41+
fill: var(--color-tooltip-bg);
42+
}
43+
44+
/* menu theme for .ui.menu */
45+
2746
.tippy-box[data-theme="menu"] {
2847
background-color: var(--color-menu);
2948
color: var(--color-text);
3049
}
3150

32-
.tippy-box[data-theme="form-fetch-error"] {
33-
border-color: var(--color-error-border);
34-
background-color: var(--color-error-bg);
35-
color: var(--color-error-text);
51+
.tippy-box[data-theme="menu"] .tippy-content {
52+
padding: 0;
3653
}
3754

38-
.tippy-content {
39-
position: relative;
40-
padding: 1rem;
41-
z-index: 1;
55+
.tippy-box[data-theme="menu"] .tippy-svg-arrow-inner {
56+
fill: var(--color-menu);
4257
}
4358

44-
.tippy-box[data-theme="tooltip"] .tippy-content {
45-
padding: 0.5rem 1rem;
46-
}
59+
/* box-with-header theme to look like .ui.attached.segment. can contain .ui.attached.header */
4760

48-
.tippy-box[data-theme="menu"] .tippy-content {
61+
.tippy-box[data-theme="box-with-header"] .tippy-content {
62+
background: var(--color-box-body);
4963
padding: 0;
5064
}
5165

66+
.tippy-box[data-theme="box-with-header"][data-placement^="top"] .tippy-svg-arrow-inner {
67+
fill: var(--color-box-body);
68+
}
69+
70+
.tippy-box[data-theme="box-with-header"][data-placement^="bottom"] .tippy-svg-arrow-inner {
71+
fill: var(--color-box-header);
72+
}
73+
5274
.tippy-box[data-placement^="top"] > .tippy-svg-arrow {
5375
bottom: 0;
5476
}
@@ -107,12 +129,3 @@
107129
.tippy-svg-arrow-inner {
108130
fill: var(--color-body);
109131
}
110-
111-
.tippy-box[data-theme="tooltip"] .tippy-svg-arrow-inner,
112-
.tippy-box[data-theme="tooltip"] .tippy-svg-arrow-outer {
113-
fill: var(--color-tooltip-bg);
114-
}
115-
116-
.tippy-box[data-theme="menu"] .tippy-svg-arrow-inner {
117-
fill: var(--color-menu);
118-
}

0 commit comments

Comments
 (0)