mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-29 12:46:16 +01:00
8820191476
Follow #23328 The improvements: 1. The `contains` functions are covered by tests 2. The inconsistent behavior of `containGeneric` is replaced by `StringUtils.Contains` and `SliceUtils.Contains` 3. In the future we can move more help functions into XxxUtils to simplify the `helper.go` and reduce unnecessary global functions. FAQ: 1. Why it's called `StringUtils.Contains` but not `strings.Contains` like Golang? Because our `StringUtils` is not Golang's `strings` package. There will be our own string functions. --------- Co-authored-by: silverwind <me@silverwind.io>
79 lines
3.5 KiB
Handlebars
79 lines
3.5 KiB
Handlebars
<div id="rev-container">
|
|
<ul id="rev-list">
|
|
{{range $commitI, $commit := .Graph.Commits}}
|
|
<li {{if $commit.Rev}}id="commit-{{$commit.Rev}}"{{end}} data-flow="{{$commit.Flow}}">
|
|
{{if $commit.OnlyRelation}}
|
|
<span></span>
|
|
{{else}}
|
|
<span class="sha" id="{{$commit.ShortRev}}">
|
|
{{$class := "ui sha label"}}
|
|
{{if $commit.Commit.Signature}}
|
|
{{$class = (printf "%s%s" $class " isSigned")}}
|
|
{{if $commit.Verification.Verified}}
|
|
{{if eq $commit.Verification.TrustStatus "trusted"}}
|
|
{{$class = (printf "%s%s" $class " isVerified")}}
|
|
{{else if eq $commit.Verification.TrustStatus "untrusted"}}
|
|
{{$class = (printf "%s%s" $class " isVerifiedUntrusted")}}
|
|
{{else}}
|
|
{{$class = (printf "%s%s" $class " isVerifiedUnmatched")}}
|
|
{{end}}
|
|
{{else if $commit.Verification.Warning}}
|
|
{{$class = (printf "%s%s" $class " isWarning")}}
|
|
{{end}}
|
|
{{end}}
|
|
<a href="{{$.RepoLink}}/commit/{{$commit.Rev|PathEscape}}" rel="nofollow" class="{{$class}}">
|
|
<span class="shortsha">{{ShortSha $commit.Commit.ID.String}}</span>
|
|
{{- if $commit.Commit.Signature -}}
|
|
<span class="shortsha-pad"></span>{{template "repo/shabox_badge" dict "root" $ "verification" $commit.Verification}}
|
|
{{- end -}}
|
|
</a>
|
|
</span>
|
|
<span class="message gt-dib gt-ellipsis gt-mr-3">
|
|
<span>{{RenderCommitMessage $.Context $commit.Subject $.RepoLink $.Repository.ComposeMetas}}</span>
|
|
</span>
|
|
<span class="tags gt-df gt-ac gt-mr-2">
|
|
{{range $commit.Refs}}
|
|
{{$refGroup := .RefGroup}}
|
|
{{if eq $refGroup "pull"}}
|
|
{{if or (not $.HidePRRefs) (SliceUtils.Contains $.SelectedBranches .Name)}}
|
|
<!-- it's intended to use issues not pulls, if it's a pull you will get redirected -->
|
|
<a class="ui labelled icon button basic tiny gt-mr-2" href="{{$.RepoLink}}/{{if $.Repository.UnitEnabled $.Context $.UnitTypePullRequests}}pulls{{else}}issues{{end}}/{{.ShortName|PathEscape}}">
|
|
{{svg "octicon-git-pull-request" 16 "gt-mr-2"}}#{{.ShortName}}
|
|
</a>
|
|
{{end}}
|
|
{{else if eq $refGroup "tags"}}
|
|
<a class="ui labelled icon button basic tiny gt-mr-2" href="{{$.RepoLink}}/src/tag/{{.ShortName|PathEscape}}">
|
|
{{svg "octicon-tag" 16 "gt-mr-2"}}{{.ShortName}}
|
|
</a>
|
|
{{else if eq $refGroup "remotes"}}
|
|
<a class="ui labelled icon button basic tiny gt-mr-2" href="{{$.RepoLink}}/src/commit/{{$commit.Rev|PathEscape}}">
|
|
{{svg "octicon-cross-reference" 16 "gt-mr-2"}}{{.ShortName}}
|
|
</a>
|
|
{{else if eq $refGroup "heads"}}
|
|
<a class="ui labelled icon button basic tiny gt-mr-2" href="{{$.RepoLink}}/src/branch/{{.ShortName|PathEscape}}">
|
|
{{svg "octicon-git-branch" 16 "gt-mr-2"}}{{.ShortName}}
|
|
</a>
|
|
{{else}}
|
|
<!-- Unknown ref type .Name -->
|
|
{{end}}
|
|
{{end}}
|
|
</span>
|
|
<span class="author gt-df gt-ac gt-mr-3">
|
|
{{$userName := $commit.Commit.Author.Name}}
|
|
{{if $commit.User}}
|
|
{{if $commit.User.FullName}}
|
|
{{$userName = $commit.User.FullName}}
|
|
{{end}}
|
|
<span class="gt-mr-2">{{avatar $.Context $commit.User}}</span>
|
|
<a href="{{$commit.User.HomeLink}}">{{$userName}}</a>
|
|
{{else}}
|
|
<span class="gt-mr-2">{{avatarByEmail $.Context $commit.Commit.Author.Email $userName}}</span>
|
|
{{$userName}}
|
|
{{end}}
|
|
</span>
|
|
<span class="time gt-df gt-ac">{{$commit.Date}}</span>
|
|
{{end}}
|
|
</li>
|
|
{{end}}
|
|
</ul>
|
|
</div>
|