Skip to content

Commit 064c5ad

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

File tree

19 files changed

+179
-94
lines changed

19 files changed

+179
-94
lines changed

options/locale/locale_en-US.ini

Lines changed: 2 additions & 0 deletions
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

Lines changed: 43 additions & 0 deletions
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

Lines changed: 4 additions & 14 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 10 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 8 additions & 1 deletion
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}}

0 commit comments

Comments
 (0)