From d2ae6970e624a4ee09cef4847fd95ccd9910f923 Mon Sep 17 00:00:00 2001 From: iamyaash Date: Thu, 22 May 2025 16:58:58 +0530 Subject: [PATCH] refactor: added separate commits template for pull request area - created new `commits` template for pull request view - this template uses the duplicated `repo/commits_table` in `repo/pulls/commits_table` - the duplicated `repo/pulls/commits_table` calls the `repo/pulls/commits_list` instead of the default `repo/commits_list` chore: revert to original `repo/commits_list` for non pull-request views chore: alignment and order changes chore: removed the duplicated commits_table --- templates/repo/commits_list.tmpl | 104 ++++++++++--------------- templates/repo/pulls/commits.tmpl | 2 +- templates/repo/pulls/commits_list.tmpl | 97 +++++++++++++++++++++++ 3 files changed, 140 insertions(+), 63 deletions(-) create mode 100644 templates/repo/pulls/commits_list.tmpl diff --git a/templates/repo/commits_list.tmpl b/templates/repo/commits_list.tmpl index 250e60f888..f4c10e62f0 100644 --- a/templates/repo/commits_list.tmpl +++ b/templates/repo/commits_list.tmpl @@ -28,6 +28,21 @@ + {{$class := "ui sha label"}} + {{if .Signature}} + {{$class = (print $class " isSigned")}} + {{if .Verification.Verified}} + {{if eq .Verification.TrustStatus "trusted"}} + {{$class = (print $class " isVerified")}} + {{else if eq .Verification.TrustStatus "untrusted"}} + {{$class = (print $class " isVerifiedUntrusted")}} + {{else}} + {{$class = (print $class " isVerifiedUnmatched")}} + {{end}} + {{else if .Verification.Warning}} + {{$class = (print $class " isWarning")}} + {{end}} + {{end}} {{$commitShaLink := ""}} {{if $.PageIsWiki}} {{$commitShaLink = (printf "%s/wiki/commit/%s" $commitRepoLink (PathEscape .ID.String))}} @@ -36,12 +51,10 @@ {{else if $.Reponame}} {{$commitShaLink = (printf "%s/commit/%s" $commitRepoLink (PathEscape .ID.String))}} {{end}} - {{template "repo/shabox" (dict - "sha1" .ID.String - "commitLink" $commitShaLink - "signature" .Signature - "verification" .Verification - )}} + + {{ShortSha .ID.String}} + {{if .Signature}}{{template "repo/shabox_badge" dict "root" $ "verification" .Verification}}{{end}} + @@ -76,60 +89,27 @@ {{else}} {{DateUtils.TimeSince .Author.When}} {{end}} - {{end}} - {{$commitShaLink := ""}} - {{if $.PageIsWiki}} - {{$commitShaLink = (printf "%s/wiki/commit/%s" $commitRepoLink (PathEscape .ID.String))}} - {{else if $.PageIsPullCommits}} - {{$commitShaLink = (printf "%s/pulls/%d/commits/%s" $commitRepoLink $.Issue.Index (PathEscape .ID.String))}} - {{else if $.Reponame}} - {{$commitShaLink = (printf "%s/commit/%s" $commitRepoLink (PathEscape .ID.String))}} - {{end}} - - {{ShortSha .ID.String}} - {{if .Signature}}{{template "repo/shabox_badge" dict "root" $ "verification" .Verification}}{{end}} - - -
- {{$userName := .Author.Name}} - - {{if .User}} - {{if and .User.FullName DefaultShowFullName}} - {{$userName = .User.FullName}} - {{end}} - {{ctx.AvatarUtils.Avatar .User 28 "tw-mr-2"}}{{$userName}} - {{else}} - {{ctx.AvatarUtils.AvatarByEmail .Author.Email .Author.Name 28 "tw-mr-2"}} - {{$userName}} - {{end}} -
- - -
- {{$commitLink:= printf "%s/commit/%s" $commitRepoLink (PathEscape .ID.String)}} -
{{RenderCommitMessageLinkSubject $.Context .Message $commitLink ($.Repository.ComposeMetas ctx)}}
- {{if IsMultilineCommitMessage .Message}} - -
{{RenderCommitBody $.Context .Message ($.Repository.ComposeMetas ctx)}}
+ + + {{if not $.PageIsWiki}} + {{if $.FileName}} + + {{svg "octicon-file-diff"}} + + {{end}} + + {{svg "octicon-file-code"}} + + {{end}} + + {{end}} - {{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses}} -
- -
- {{if .Committer}}{{DateUtils.TimeSince .Committer.When}}{{else}}{{DateUtils.TimeSince .Author.When}}{{end}} -
- - -
- - {{if not $.PageIsWiki}} - {{if $.FileName}} - {{svg "octicon-file-diff"}} - {{end}} - {{svg "octicon-file-code"}} - {{end}} -
- - {{end}} - - + + + diff --git a/templates/repo/pulls/commits.tmpl b/templates/repo/pulls/commits.tmpl index bf6e8128d4..ba5d7ea931 100644 --- a/templates/repo/pulls/commits.tmpl +++ b/templates/repo/pulls/commits.tmpl @@ -4,7 +4,7 @@
{{template "repo/issue/view_title" .}} {{template "repo/pulls/tab_menu" .}} - {{template "repo/commits_table" .}} + {{template "repo/pulls/commits_table" .}}
{{template "base/footer" .}} diff --git a/templates/repo/pulls/commits_list.tmpl b/templates/repo/pulls/commits_list.tmpl new file mode 100644 index 0000000000..0a007153c1 --- /dev/null +++ b/templates/repo/pulls/commits_list.tmpl @@ -0,0 +1,97 @@ +
+ {{$commitRepoLink := $.RepoLink}}{{if $.CommitRepoLink}}{{$commitRepoLink = $.CommitRepoLink}}{{end}} + {{$prevDate := ""}} + {{range .Commits}} + {{$commitTime := .Committer.When}} + {{if not $commitTime}}{{$commitTime = .Author.When}}{{end}} + {{$commitDate := $commitTime.Format "2006-01-02"}} + {{if ne $commitDate $prevDate}} + {{if ne $prevDate ""}}
{{end}} + {{$prevDate = $commitDate}} + + +
+
+
{{ $commitTime.Format "Mon, 02 Jan 2006" }}
+ + +
+ {{end}} + + +
+
+ +
+ {{$userName := .Author.Name}} + + {{if .User}} + {{if and .User.FullName DefaultShowFullName}} + {{$userName = .User.FullName}} + {{end}} + {{ctx.AvatarUtils.Avatar .User 28 "tw-mr-2"}}{{$userName}} + {{else}} + {{ctx.AvatarUtils.AvatarByEmail .Author.Email .Author.Name 28 "tw-mr-2"}} + {{$userName}} + {{end}} +
+
+ +
+ {{$commitLink:= printf "%s/commit/%s" $commitRepoLink (PathEscape .ID.String)}} +
{{RenderCommitMessageLinkSubject $.Context .Message $commitLink ($.Repository.ComposeMetas ctx)}}
+ {{if IsMultilineCommitMessage .Message}} + +
{{RenderCommitBody $.Context .Message ($.Repository.ComposeMetas ctx)}}
+ {{end}} + {{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses}} +
+ +
+ {{$class := "ui sha label"}} + {{if .Signature}} + {{$class = (print $class " isSigned")}} + {{if .Verification.Verified}} + {{if eq .Verification.TrustStatus "trusted"}} + {{$class = (print $class " isVerified")}} + {{else if eq .Verification.TrustStatus "untrusted"}} + {{$class = (print $class " isVerifiedUntrusted")}} + {{else}} + {{$class = (print $class " isVerifiedUnmatched")}} + {{end}} + {{else if .Verification.Warning}} + {{$class = (print $class " isWarning")}} + {{end}} + {{end}} + {{$commitShaLink := ""}} + {{if $.PageIsWiki}} + {{$commitShaLink = (printf "%s/wiki/commit/%s" $commitRepoLink (PathEscape .ID.String))}} + {{else if $.PageIsPullCommits}} + {{$commitShaLink = (printf "%s/pulls/%d/commits/%s" $commitRepoLink $.Issue.Index (PathEscape .ID.String))}} + {{else if $.Reponame}} + {{$commitShaLink = (printf "%s/commit/%s" $commitRepoLink (PathEscape .ID.String))}} + {{end}} + + {{ShortSha .ID.String}} + {{if .Signature}}{{template "repo/shabox_badge" dict "root" $ "verification" .Verification}}{{end}} + +
+ +
+ {{if .Committer}}{{DateUtils.TimeSince .Committer.When}}{{else}}{{DateUtils.TimeSince .Author.When}}{{end}} +
+ + +
+ + {{if not $.PageIsWiki}} + {{if $.FileName}} + {{svg "octicon-file-diff"}} + {{end}} + {{svg "octicon-file-code"}} + {{end}} +
+
+ {{end}} +
+