From 5cb0c9aa0d7eed087055b1efca79628957207d36 Mon Sep 17 00:00:00 2001 From: zeripath Date: Wed, 19 Jan 2022 23:26:57 +0000 Subject: Propagate context and ensure git commands run in request context (#17868) This PR continues the work in #17125 by progressively ensuring that git commands run within the request context. This now means that the if there is a git repo already open in the context it will be used instead of reopening it. Signed-off-by: Andrew Thornton --- templates/repo/branch/list.tmpl | 4 ++-- templates/repo/commit_page.tmpl | 6 +++--- templates/repo/commits_list.tmpl | 4 ++-- templates/repo/commits_list_small.tmpl | 4 ++-- templates/repo/graph/commits.tmpl | 2 +- templates/repo/header.tmpl | 2 +- templates/repo/home.tmpl | 3 ++- templates/repo/issue/view_title.tmpl | 2 +- templates/repo/settings/options.tmpl | 6 +++--- templates/repo/view_list.tmpl | 6 +++--- 10 files changed, 20 insertions(+), 19 deletions(-) (limited to 'templates/repo') diff --git a/templates/repo/branch/list.tmpl b/templates/repo/branch/list.tmpl index fc81901069..ea259949b4 100644 --- a/templates/repo/branch/list.tmpl +++ b/templates/repo/branch/list.tmpl @@ -18,7 +18,7 @@ {{svg "octicon-shield-lock"}} {{end}} {{.DefaultBranch}} -

{{svg "octicon-git-commit" 16 "mr-2"}}{{ShortSha .DefaultBranchBranch.Commit.ID.String}} · {{RenderCommitMessage .DefaultBranchBranch.Commit.CommitMessage .RepoLink .Repository.ComposeMetas}} · {{.i18n.Tr "org.repo_updated"}} {{TimeSince .DefaultBranchBranch.Commit.Committer.When .i18n.Lang}}

+

{{svg "octicon-git-commit" 16 "mr-2"}}{{ShortSha .DefaultBranchBranch.Commit.ID.String}} · {{RenderCommitMessage $.Context .DefaultBranchBranch.Commit.CommitMessage .RepoLink .Repository.ComposeMetas}} · {{.i18n.Tr "org.repo_updated"}} {{TimeSince .DefaultBranchBranch.Commit.Committer.When .i18n.Lang}}

{{if and $.IsWriter (not $.Repository.IsArchived) (not .IsDeleted)}} @@ -59,7 +59,7 @@ {{svg "octicon-shield-lock"}} {{end}} {{.Name}} -

{{svg "octicon-git-commit" 16 "mr-2"}}{{ShortSha .Commit.ID.String}} · {{RenderCommitMessage .Commit.CommitMessage $.RepoLink $.Repository.ComposeMetas}} · {{$.i18n.Tr "org.repo_updated"}} {{TimeSince .Commit.Committer.When $.i18n.Lang}}

+

{{svg "octicon-git-commit" 16 "mr-2"}}{{ShortSha .Commit.ID.String}} · {{RenderCommitMessage $.Context .Commit.CommitMessage $.RepoLink $.Repository.ComposeMetas}} · {{$.i18n.Tr "org.repo_updated"}} {{TimeSince .Commit.Committer.When $.i18n.Lang}}

{{end}} diff --git a/templates/repo/commit_page.tmpl b/templates/repo/commit_page.tmpl index c995273643..931201fed6 100644 --- a/templates/repo/commit_page.tmpl +++ b/templates/repo/commit_page.tmpl @@ -23,9 +23,9 @@ {{.i18n.Tr "repo.diff.browse_source"}} {{end}} -

{{RenderCommitMessage .Commit.Message $.RepoLink $.Repository.ComposeMetas}}{{template "repo/commit_statuses" dict "Status" .CommitStatus "Statuses" .CommitStatuses "root" $}}

+

{{RenderCommitMessage $.Context .Commit.Message $.RepoLink $.Repository.ComposeMetas}}{{template "repo/commit_statuses" dict "Status" .CommitStatus "Statuses" .CommitStatuses "root" $}}

{{if IsMultilineCommitMessage .Commit.Message}} -
{{RenderCommitBody .Commit.Message $.RepoLink $.Repository.ComposeMetas}}
+
{{RenderCommitBody $.Context .Commit.Message $.RepoLink $.Repository.ComposeMetas}}
{{end}} {{if .BranchName}} {{svg "octicon-git-branch" 16 "mr-2"}}{{.BranchName}} @@ -172,7 +172,7 @@ {{TimeSince .NoteCommit.Author.When $.Lang}}
-
{{RenderNote .Note $.RepoLink $.Repository.ComposeMetas}}
+
{{RenderNote $.Context .Note $.RepoLink $.Repository.ComposeMetas}}
{{end}} {{template "repo/diff/box" .}} diff --git a/templates/repo/commits_list.tmpl b/templates/repo/commits_list.tmpl index d43170e525..7bc37175c2 100644 --- a/templates/repo/commits_list.tmpl +++ b/templates/repo/commits_list.tmpl @@ -64,7 +64,7 @@ {{.Summary | RenderEmoji}} {{else }} {{ $commitLink:= printf "%s/commit/%s" $commitRepoLink (PathEscape .ID.String) }} - {{RenderCommitMessageLinkSubject .Message $commitRepoLink $commitLink $.Repository.ComposeMetas}} + {{RenderCommitMessageLinkSubject $.Context .Message $commitRepoLink $commitLink $.Repository.ComposeMetas}} {{end}} {{if IsMultilineCommitMessage .Message}} @@ -72,7 +72,7 @@ {{end}} {{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses "root" $}} {{if IsMultilineCommitMessage .Message}} - + {{end}} {{TimeSince .Author.When $.Lang}} diff --git a/templates/repo/commits_list_small.tmpl b/templates/repo/commits_list_small.tmpl index 1593ac8129..ddcccf0db5 100644 --- a/templates/repo/commits_list_small.tmpl +++ b/templates/repo/commits_list_small.tmpl @@ -47,12 +47,12 @@ {{ $commitLink:= printf "%s/commit/%s" $.comment.Issue.PullRequest.BaseRepo.Link (PathEscape .ID.String) }} - {{RenderCommitMessageLinkSubject .Message ($.comment.Issue.PullRequest.BaseRepo.Link|Escape) $commitLink $.comment.Issue.PullRequest.BaseRepo.ComposeMetas}} + {{RenderCommitMessageLinkSubject $.Context .Message ($.comment.Issue.PullRequest.BaseRepo.Link|Escape) $commitLink $.comment.Issue.PullRequest.BaseRepo.ComposeMetas}} {{if IsMultilineCommitMessage .Message}} {{end}} {{if IsMultilineCommitMessage .Message}} - + {{end}} {{end}} diff --git a/templates/repo/graph/commits.tmpl b/templates/repo/graph/commits.tmpl index d213c53e96..478121f27c 100644 --- a/templates/repo/graph/commits.tmpl +++ b/templates/repo/graph/commits.tmpl @@ -29,7 +29,7 @@ - {{RenderCommitMessage $commit.Subject $.RepoLink $.Repository.ComposeMetas}} + {{RenderCommitMessage $.Context $commit.Subject $.RepoLink $.Repository.ComposeMetas}} {{range $commit.Refs}} diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index 014623dc9a..01ec0f0c83 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -36,7 +36,7 @@ {{end}} - {{if .IsMirror}}{{end}} + {{if .IsMirror}}{{end}} {{if .IsFork}}
{{$.i18n.Tr "repo.forked_from"}} {{.BaseRepo.FullName}}
{{end}} {{if .IsGenerated}}
{{$.i18n.Tr "repo.generated_from"}} {{.TemplateRepo.FullName}}
{{end}} diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index 5ee6cc2df7..9924ae547d 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -5,7 +5,8 @@ {{template "base/alert" .}}
- {{if .Repository.DescriptionHTML}}{{.Repository.DescriptionHTML}}{{else if .IsRepositoryAdmin}}{{.i18n.Tr "repo.no_desc"}}{{end}} + {{ $description := .Repository.DescriptionHTML $.Context}} + {{if $description}}{{$description}}{{else if .IsRepositoryAdmin}}{{.i18n.Tr "repo.no_desc"}}{{end}} {{.Repository.Website}}
{{if .RepoSearchEnabled}} diff --git a/templates/repo/issue/view_title.tmpl b/templates/repo/issue/view_title.tmpl index b43015f1d2..07c700afea 100644 --- a/templates/repo/issue/view_title.tmpl +++ b/templates/repo/issue/view_title.tmpl @@ -6,7 +6,7 @@
{{end}}

- {{RenderIssueTitle .Issue.Title $.RepoLink $.Repository.ComposeMetas}} + {{RenderIssueTitle $.Context .Issue.Title $.RepoLink $.Repository.ComposeMetas}} #{{.Issue.Index}} - {{$address := MirrorRemoteAddress .Mirror}} + {{$address := MirrorRemoteAddress $.Context .Mirror}}
@@ -168,7 +168,7 @@ {{range .PushMirrors}} - {{$address := MirrorRemoteAddress .}} + {{$address := MirrorRemoteAddress $.Context .}} {{$address.Address}} {{$.i18n.Tr "repo.settings.mirror_settings.direction.push"}} {{if .LastUpdateUnix}}{{.LastUpdateUnix.AsTime}}{{else}}{{$.i18n.Tr "never"}}{{end}} {{if .LastError}}
{{$.i18n.Tr "error"}}
{{end}} diff --git a/templates/repo/view_list.tmpl b/templates/repo/view_list.tmpl index d490220694..870bbb92e8 100644 --- a/templates/repo/view_list.tmpl +++ b/templates/repo/view_list.tmpl @@ -26,10 +26,10 @@ {{template "repo/commit_statuses" dict "Status" .LatestCommitStatus "Statuses" .LatestCommitStatuses "root" $}} {{ $commitLink:= printf "%s/commit/%s" .RepoLink (PathEscape .LatestCommit.ID.String) }} - {{RenderCommitMessageLinkSubject .LatestCommit.Message $.RepoLink $commitLink $.Repository.ComposeMetas}} + {{RenderCommitMessageLinkSubject $.Context .LatestCommit.Message $.RepoLink $commitLink $.Repository.ComposeMetas}} {{if IsMultilineCommitMessage .LatestCommit.Message}} - + {{end}} {{end}} @@ -81,7 +81,7 @@ {{if $commit}} {{$commitLink := printf "%s/commit/%s" $.RepoLink (PathEscape $commit.ID.String)}} - {{RenderCommitMessageLinkSubject $commit.Message $.RepoLink $commitLink $.Repository.ComposeMetas}} + {{RenderCommitMessageLinkSubject $.Context $commit.Message $.RepoLink $commitLink $.Repository.ComposeMetas}} {{else}}
{{end}} -- cgit v1.2.3