Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

De-emphasize signed commits #31160

Merged
merged 40 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
7c4f9bf
feat: De-emphasize signed commits
BlenderDefender May 29, 2024
e816399
fix: Change indentation to tabs instead of spaces
BlenderDefender May 29, 2024
aba27b0
Merge branch 'main' into signed-commits-ui
BlenderDefender May 30, 2024
95fe298
refactor: Move the texts "Verified commit" and "Unverified commit" to…
BlenderDefender May 30, 2024
682a1e6
refactor: Remove classnames that don't have any effect
BlenderDefender May 30, 2024
f477bb4
refactor: Remove `isSigned` styles from `repo.css`
BlenderDefender May 30, 2024
9cfe8f9
fix: Adjust the border radius of the verified/unverified badge
BlenderDefender May 30, 2024
78e9b68
fix: Fix broken verification reason layout (in the verification detai…
BlenderDefender May 30, 2024
3c65283
Merge branch 'main' into signed-commits-ui
BlenderDefender May 31, 2024
22c2fcb
style: Remove unnecessary "else if" statement
BlenderDefender May 31, 2024
af677a7
introduce commit-hash-link class
silverwind May 31, 2024
ef95ac9
Update templates/repo/latest_commit.tmpl
silverwind May 31, 2024
e7f9e8e
Update templates/repo/commits_list.tmpl
silverwind May 31, 2024
ebb4979
Update templates/repo/commits_list_small.tmpl
silverwind May 31, 2024
ecd3be0
change last hover bg
silverwind May 31, 2024
6e36861
finish commit-hash-link changes
silverwind May 31, 2024
6b36467
try to fix integration tests
silverwind May 31, 2024
f920603
remove unnecessary span's
silverwind May 31, 2024
2055a3e
Merge branch 'main' into signed-commits-ui
BlenderDefender May 31, 2024
99d0171
refactor: Use `gap` instead of `margin` where applicable
BlenderDefender May 31, 2024
c11a97f
refactor: Remove unused selectors from repo.css
BlenderDefender May 31, 2024
11ccfb3
fix: Fix long commit summaries overflowing the layout
BlenderDefender May 31, 2024
c8f4cde
fix all the overflows, remove some unused css
silverwind May 31, 2024
4b81e7d
fix latest commit expansion
silverwind May 31, 2024
a3c6129
fine-tune
silverwind May 31, 2024
30c45ab
restore and fix author-wrapper css
silverwind May 31, 2024
01d26ff
fix white-space
silverwind May 31, 2024
7f8173f
fix: Fix failing compliance test because of two empty lines in repo.css
BlenderDefender Jun 1, 2024
7efff20
Merge branch 'main' into signed-commits-ui
BlenderDefender Jun 4, 2024
3776ad7
refactor: Remove unnecessary if-else-statement
BlenderDefender Jun 4, 2024
a0de5ae
Merge branch 'main' into signed-commits-ui
silverwind Jun 13, 2024
2071013
Merge branch 'main' into signed-commits-ui
wxiaoguang Dec 27, 2024
aae3308
temp
wxiaoguang Dec 27, 2024
71a17ef
fix
wxiaoguang Dec 27, 2024
adff3d6
fix
wxiaoguang Dec 27, 2024
c0a807f
fix
wxiaoguang Dec 27, 2024
b1585f4
Merge branch 'main' into signed-commits-ui
wxiaoguang Dec 27, 2024
7b85744
fix
wxiaoguang Dec 27, 2024
9538f47
Merge branch 'main' into signed-commits-ui
wxiaoguang Dec 27, 2024
42d0a1f
fix
wxiaoguang Dec 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 82 additions & 10 deletions routers/web/devtest/devtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import (
"strings"
"time"

"code.gitea.io/gitea/models/asymkey"
"code.gitea.io/gitea/models/db"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/templates"
"code.gitea.io/gitea/services/context"
)
Expand Down Expand Up @@ -41,16 +45,85 @@ func FetchActionTest(ctx *context.Context) {
ctx.JSONRedirect("")
}

func Tmpl(ctx *context.Context) {
now := time.Now()
ctx.Data["TimeNow"] = now
ctx.Data["TimePast5s"] = now.Add(-5 * time.Second)
ctx.Data["TimeFuture5s"] = now.Add(5 * time.Second)
ctx.Data["TimePast2m"] = now.Add(-2 * time.Minute)
ctx.Data["TimeFuture2m"] = now.Add(2 * time.Minute)
ctx.Data["TimePast1y"] = now.Add(-1 * 366 * 86400 * time.Second)
ctx.Data["TimeFuture1y"] = now.Add(1 * 366 * 86400 * time.Second)
func prepareMockData(ctx *context.Context) {
if ctx.Req.URL.Path == "/devtest/gitea-ui" {
now := time.Now()
ctx.Data["TimeNow"] = now
ctx.Data["TimePast5s"] = now.Add(-5 * time.Second)
ctx.Data["TimeFuture5s"] = now.Add(5 * time.Second)
ctx.Data["TimePast2m"] = now.Add(-2 * time.Minute)
ctx.Data["TimeFuture2m"] = now.Add(2 * time.Minute)
ctx.Data["TimePast1y"] = now.Add(-1 * 366 * 86400 * time.Second)
ctx.Data["TimeFuture1y"] = now.Add(1 * 366 * 86400 * time.Second)
}

if ctx.Req.URL.Path == "/devtest/commit-sign-badge" {
var commits []*asymkey.SignCommit
mockUsers, _ := db.Find[user_model.User](ctx, user_model.SearchUserOptions{ListOptions: db.ListOptions{PageSize: 1}})
mockUser := mockUsers[0]
commits = append(commits, &asymkey.SignCommit{
Verification: &asymkey.CommitVerification{},
UserCommit: &user_model.UserCommit{
Commit: &git.Commit{ID: git.Sha1ObjectFormat.EmptyObjectID()},
},
})
commits = append(commits, &asymkey.SignCommit{
Verification: &asymkey.CommitVerification{
Verified: true,
Reason: "name / key-id",
SigningUser: mockUser,
SigningKey: &asymkey.GPGKey{KeyID: "12345678"},
TrustStatus: "trusted",
},
UserCommit: &user_model.UserCommit{
User: mockUser,
Commit: &git.Commit{ID: git.Sha1ObjectFormat.EmptyObjectID()},
},
})
commits = append(commits, &asymkey.SignCommit{
Verification: &asymkey.CommitVerification{
Verified: true,
Reason: "name / key-id",
SigningUser: mockUser,
SigningSSHKey: &asymkey.PublicKey{Fingerprint: "aa:bb:cc:dd:ee"},
TrustStatus: "untrusted",
},
UserCommit: &user_model.UserCommit{
User: mockUser,
Commit: &git.Commit{ID: git.Sha1ObjectFormat.EmptyObjectID()},
},
})
commits = append(commits, &asymkey.SignCommit{
Verification: &asymkey.CommitVerification{
Verified: true,
Reason: "name / key-id",
SigningUser: mockUser,
SigningSSHKey: &asymkey.PublicKey{Fingerprint: "aa:bb:cc:dd:ee"},
TrustStatus: "other(unmatch)",
},
UserCommit: &user_model.UserCommit{
User: mockUser,
Commit: &git.Commit{ID: git.Sha1ObjectFormat.EmptyObjectID()},
},
})
commits = append(commits, &asymkey.SignCommit{
Verification: &asymkey.CommitVerification{
Warning: true,
Reason: "gpg.error",
SigningEmail: "[email protected]",
},
UserCommit: &user_model.UserCommit{
User: mockUser,
Commit: &git.Commit{ID: git.Sha1ObjectFormat.EmptyObjectID()},
},
})

ctx.Data["MockCommits"] = commits
}
}

func Tmpl(ctx *context.Context) {
prepareMockData(ctx)
if ctx.Req.Method == "POST" {
_ = ctx.Req.ParseForm()
ctx.Flash.Info("form: "+ctx.Req.Method+" "+ctx.Req.RequestURI+"<br>"+
Expand All @@ -60,6 +133,5 @@ func Tmpl(ctx *context.Context) {
)
time.Sleep(2 * time.Second)
}

ctx.HTML(http.StatusOK, templates.TplName("devtest"+path.Clean("/"+ctx.PathParam("sub"))))
}
13 changes: 13 additions & 0 deletions templates/devtest/commit-sign-badge.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{template "devtest/devtest-header"}}
<div class="page-content devtest ui container">
<div>
<h1>Commit Sign Badges</h1>
{{range $commit := .MockCommits}}
<div class="flex-text-block tw-my-2">
{{template "repo/commit_sign_badge" dict "Commit" $commit "CommitBaseLink" "/devtest/commit" "CommitSignVerification" $commit.Verification}}
{{template "repo/commit_sign_badge" dict "CommitSignVerification" $commit.Verification}}
</div>
{{end}}
</div>
</div>
{{template "devtest/devtest-footer"}}
179 changes: 50 additions & 129 deletions templates/repo/commit_page.tmpl
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
{{template "base/head" .}}
{{$commitLinkBase := print $.RepoLink (Iif $.PageIsWiki "/wiki" "") "/commit"}}
<div role="main" aria-label="{{.Title}}" class="page-content repository diff">
{{template "repo/header" .}}
<div class="ui container fluid padded">
{{$class := ""}}
{{if .Commit.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}}
<div class="ui top attached header clearing segment tw-relative commit-header {{$class}}">
<div class="ui top attached header clearing segment tw-relative commit-header">
<div class="tw-flex tw-mb-4 tw-gap-1">
<h3 class="tw-mb-0 tw-flex-1"><span class="commit-summary" title="{{.Commit.Summary}}">{{ctx.RenderUtils.RenderCommitMessage .Commit.Message ($.Repository.ComposeMetas ctx)}}</span>{{template "repo/commit_statuses" dict "Status" .CommitStatus "Statuses" .CommitStatuses}}</h3>
{{if not $.PageIsWiki}}
Expand Down Expand Up @@ -142,125 +128,59 @@
{{end}}
{{template "repo/commit_load_branches_and_tags" .}}
</div>
<div class="ui{{if not .Commit.Signature}} bottom{{end}} attached segment tw-flex tw-items-center tw-justify-between tw-py-1 commit-header-row tw-flex-wrap {{$class}}">
<div class="tw-flex tw-items-center author">
{{if .Author}}
{{ctx.AvatarUtils.Avatar .Author 28 "tw-mr-2"}}
{{if .Author.FullName}}
<a href="{{.Author.HomeLink}}"><strong>{{.Author.FullName}}</strong></a>
{{else}}
<a href="{{.Author.HomeLink}}"><strong>{{.Commit.Author.Name}}</strong></a>
{{end}}

<div class="ui bottom attached segment flex-text-block tw-flex-wrap">
<div class="flex-text-inline">
{{if .Author}}
{{ctx.AvatarUtils.Avatar .Author 20}}
{{if .Author.FullName}}
<a href="{{.Author.HomeLink}}"><strong>{{.Author.FullName}}</strong></a>
{{else}}
{{ctx.AvatarUtils.AvatarByEmail .Commit.Author.Email .Commit.Author.Email 28 "tw-mr-2"}}
<strong>{{.Commit.Author.Name}}</strong>
<a href="{{.Author.HomeLink}}"><strong>{{.Commit.Author.Name}}</strong></a>
{{end}}
<span class="text grey tw-ml-2" id="authored-time">{{DateUtils.TimeSince .Commit.Author.When}}</span>
{{if or (ne .Commit.Committer.Name .Commit.Author.Name) (ne .Commit.Committer.Email .Commit.Author.Email)}}
<span class="text grey tw-mx-2">{{ctx.Locale.Tr "repo.diff.committed_by"}}</span>
{{if ne .Verification.CommittingUser.ID 0}}
{{ctx.AvatarUtils.Avatar .Verification.CommittingUser 28 "tw-mx-2"}}
<a href="{{.Verification.CommittingUser.HomeLink}}"><strong>{{.Commit.Committer.Name}}</strong></a>
{{else}}
{{ctx.AvatarUtils.AvatarByEmail .Commit.Committer.Email .Commit.Committer.Name 28 "tw-mr-2"}}
<strong>{{.Commit.Committer.Name}}</strong>
{{end}}
{{end}}
</div>
<div class="tw-flex tw-items-center">
{{if .Parents}}
<div>
<span>{{ctx.Locale.Tr "repo.diff.parent"}}</span>
{{range .Parents}}
{{if $.PageIsWiki}}
<a class="ui primary sha label" href="{{$.RepoLink}}/wiki/commit/{{PathEscape .}}">{{ShortSha .}}</a>
{{else}}
<a class="ui primary sha label" href="{{$.RepoLink}}/commit/{{PathEscape .}}">{{ShortSha .}}</a>
{{end}}
{{end}}
</div>
{{end}}
<div class="item">
<span>{{ctx.Locale.Tr "repo.diff.commit"}}</span>
<span class="ui primary sha label">{{ShortSha .CommitID}}</span>
</div>
</div>
</div>
{{if .Commit.Signature}}
<div class="ui bottom attached message tw-text-left tw-flex tw-items-center tw-justify-between commit-header-row tw-flex-wrap tw-mb-0 {{$class}}">
<div class="tw-flex tw-items-center">
{{if .Verification.Verified}}
{{if ne .Verification.SigningUser.ID 0}}
{{svg "gitea-lock" 16 "tw-mr-2"}}
{{if eq .Verification.TrustStatus "trusted"}}
<span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.signed_by"}}:</span>
{{else if eq .Verification.TrustStatus "untrusted"}}
<span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.signed_by_untrusted_user"}}:</span>
{{else}}
<span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.signed_by_untrusted_user_unmatched"}}:</span>
{{end}}
{{ctx.AvatarUtils.Avatar .Verification.SigningUser 28 "tw-mr-2"}}
<a href="{{.Verification.SigningUser.HomeLink}}"><strong>{{.Verification.SigningUser.GetDisplayName}}</strong></a>
{{else}}
<span title="{{ctx.Locale.Tr "gpg.default_key"}}">{{svg "gitea-lock-cog" 16 "tw-mr-2"}}</span>
<span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.signed_by"}}:</span>
{{ctx.AvatarUtils.AvatarByEmail .Verification.SigningEmail "" 28 "tw-mr-2"}}
<strong>{{.Verification.SigningUser.GetDisplayName}}</strong>
{{end}}
{{else}}
{{ctx.AvatarUtils.AvatarByEmail .Commit.Author.Email .Commit.Author.Email 20}}
<strong>{{.Commit.Author.Name}}</strong>
{{end}}
</div>

<span class="text grey">{{DateUtils.TimeSince .Commit.Author.When}}</span>

<div class="flex-text-inline">
{{if or (ne .Commit.Committer.Name .Commit.Author.Name) (ne .Commit.Committer.Email .Commit.Author.Email)}}
<span class="text grey">{{ctx.Locale.Tr "repo.diff.committed_by"}}</span>
{{if ne .Verification.CommittingUser.ID 0}}
{{ctx.AvatarUtils.Avatar .Verification.CommittingUser 20}}
<a href="{{.Verification.CommittingUser.HomeLink}}"><strong>{{.Commit.Committer.Name}}</strong></a>
{{else}}
{{svg "gitea-unlock" 16 "tw-mr-2"}}
<span class="ui text">{{ctx.Locale.Tr .Verification.Reason}}</span>
{{ctx.AvatarUtils.AvatarByEmail .Commit.Committer.Email .Commit.Committer.Name 20}}
<strong>{{.Commit.Committer.Name}}</strong>
{{end}}
</div>
<div class="tw-flex tw-items-center">
{{if .Verification.Verified}}
{{if ne .Verification.SigningUser.ID 0}}
{{svg "octicon-verified" 16 "tw-mr-2"}}
{{if .Verification.SigningSSHKey}}
<span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.ssh_key_fingerprint"}}:</span>
{{.Verification.SigningSSHKey.Fingerprint}}
{{else}}
<span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.gpg_key_id"}}:</span>
{{.Verification.SigningKey.PaddedKeyID}}
{{end}}
{{else}}
{{svg "octicon-unverified" 16 "tw-mr-2"}}
{{if .Verification.SigningSSHKey}}
<span class="ui text tw-mr-2" data-tooltip-content="{{ctx.Locale.Tr "gpg.default_key"}}">{{ctx.Locale.Tr "repo.commits.ssh_key_fingerprint"}}:</span>
{{.Verification.SigningSSHKey.Fingerprint}}
{{else}}
<span class="ui text tw-mr-2" data-tooltip-content="{{ctx.Locale.Tr "gpg.default_key"}}">{{ctx.Locale.Tr "repo.commits.gpg_key_id"}}:</span>
{{.Verification.SigningKey.PaddedKeyID}}
{{end}}
{{end}}
{{else if .Verification.Warning}}
{{svg "octicon-unverified" 16 "tw-mr-2"}}
{{if .Verification.SigningSSHKey}}
<span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.ssh_key_fingerprint"}}:</span>
{{.Verification.SigningSSHKey.Fingerprint}}
{{else}}
<span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.gpg_key_id"}}:</span>
{{.Verification.SigningKey.PaddedKeyID}}
{{end}}
{{else}}
{{if .Verification.SigningKey}}
{{if ne .Verification.SigningKey.KeyID ""}}
{{svg "octicon-verified" 16 "tw-mr-2"}}
<span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.gpg_key_id"}}:</span>
{{.Verification.SigningKey.PaddedKeyID}}
{{end}}
{{end}}
{{if .Verification.SigningSSHKey}}
{{if ne .Verification.SigningSSHKey.Fingerprint ""}}
{{svg "octicon-verified" 16 "tw-mr-2"}}
<span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.ssh_key_fingerprint"}}:</span>
{{.Verification.SigningSSHKey.Fingerprint}}
{{end}}
{{end}}
</div>

{{if .Verification}}
{{template "repo/commit_sign_badge" dict "CommitSignVerification" .Verification}}
{{end}}

<div class="tw-flex-1"></div>

<div class="flex-text-inline tw-gap-5">
{{if .Parents}}
<div class="flex-text-inline">
<span>{{ctx.Locale.Tr "repo.diff.parent"}}</span>
{{range .Parents}}
<a class="ui label commit-id-short" href="{{$commitLinkBase}}/{{PathEscape .}}">{{ShortSha .}}</a>
{{end}}
{{end}}
</div>
{{end}}
<div class="flex-text-inline">
<span>{{ctx.Locale.Tr "repo.diff.commit"}}</span>
<a class="ui label commit-id-short" href="{{$commitLinkBase}}/{{PathEscape .CommitID}}">{{ShortSha .CommitID}}</a>
</div>
</div>
{{end}}
</div>

{{if .NoteRendered}}
<div class="ui top attached header segment git-notes">
{{svg "octicon-note" 16 "tw-mr-2"}}
Expand All @@ -276,12 +196,13 @@
{{else}}
<strong>{{.NoteCommit.Author.Name}}</strong>
{{end}}
<span class="text grey" id="note-authored-time">{{DateUtils.TimeSince .NoteCommit.Author.When}}</span>
<span class="text grey">{{DateUtils.TimeSince .NoteCommit.Author.When}}</span>
</div>
<div class="ui bottom attached info segment git-notes">
<pre class="commit-body">{{.NoteRendered | SanitizeHTML}}</pre>
</div>
{{end}}

{{template "repo/diff/box" .}}
</div>
</div>
Expand Down
Loading
Loading