Skip to content

Commit 36148ed

Browse files
42wimzeripath
andauthored
Show fullname on issue edits and gpg/ssh signing info (#18828)
Co-authored-by: zeripath <[email protected]>
1 parent db4c7dc commit 36148ed

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

models/issues/content_history.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ func QueryIssueContentHistoryEditedCountMap(dbCtx context.Context, issueID int64
137137
type IssueContentListItem struct {
138138
UserID int64
139139
UserName string
140+
UserFullName string
140141
UserAvatarLink string
141142

142143
HistoryID int64
@@ -148,7 +149,7 @@ type IssueContentListItem struct {
148149
// FetchIssueContentHistoryList fetch list
149150
func FetchIssueContentHistoryList(dbCtx context.Context, issueID, commentID int64) ([]*IssueContentListItem, error) {
150151
res := make([]*IssueContentListItem, 0)
151-
err := db.GetEngine(dbCtx).Select("u.id as user_id, u.name as user_name,"+
152+
err := db.GetEngine(dbCtx).Select("u.id as user_id, u.name as user_name, u.full_name as user_full_name,"+
152153
"h.id as history_id, h.edited_unix, h.is_first_created, h.is_deleted").
153154
Table([]string{"issue_content_history", "h"}).
154155
Join("LEFT", []string{"user", "u"}, "h.poster_id = u.id").

models/issues/content_history_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ func TestContentHistory(t *testing.T) {
4343
when the refactor of models are done, this test will be possible to be run then with a real `User` model.
4444
*/
4545
type User struct {
46-
ID int64
47-
Name string
46+
ID int64
47+
Name string
48+
FullName string
4849
}
4950
_ = dbEngine.Sync2(&User{})
5051

routers/web/repo/issue_content_history.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ import (
99
"fmt"
1010
"html"
1111
"net/http"
12+
"strings"
1213

1314
"code.gitea.io/gitea/models"
1415
"code.gitea.io/gitea/models/db"
1516
issuesModel "code.gitea.io/gitea/models/issues"
1617
"code.gitea.io/gitea/models/unit"
1718
"code.gitea.io/gitea/modules/context"
1819
"code.gitea.io/gitea/modules/log"
20+
"code.gitea.io/gitea/modules/setting"
1921
"code.gitea.io/gitea/modules/timeutil"
2022

2123
"github.com/sergi/go-diff/diffmatchpatch"
@@ -68,9 +70,15 @@ func GetContentHistoryList(ctx *context.Context) {
6870
actionText = i18n.Tr(lang, "repo.issues.content_history.edited")
6971
}
7072
timeSinceText := timeutil.TimeSinceUnix(item.EditedUnix, lang)
73+
74+
username := item.UserName
75+
if setting.UI.DefaultShowFullName && strings.TrimSpace(item.UserFullName) != "" {
76+
username = strings.TrimSpace(item.UserFullName)
77+
}
78+
7179
results = append(results, map[string]interface{}{
7280
"name": fmt.Sprintf("<img class='ui avatar image' src='%s'><strong>%s</strong> %s %s",
73-
html.EscapeString(item.UserAvatarLink), html.EscapeString(item.UserName), actionText, timeSinceText),
81+
html.EscapeString(item.UserAvatarLink), html.EscapeString(username), actionText, timeSinceText),
7482
"value": item.HistoryID,
7583
})
7684
}

templates/repo/commit_page.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@
9393
<span class="ui text mr-3">{{.i18n.Tr "repo.commits.signed_by_untrusted_user_unmatched"}}:</span>
9494
{{end}}
9595
{{avatar .Verification.SigningUser 28}}
96-
<a href="{{.Verification.SigningUser.HomeLink}}"><strong>{{.Verification.SigningUser.Name}}</strong></a>
96+
<a href="{{.Verification.SigningUser.HomeLink}}"><strong>{{.Verification.SigningUser.GetDisplayName}}</strong></a>
9797
{{else}}
9898
<span title="{{.i18n.Tr "gpg.default_key"}}">{{svg "gitea-lock-cog"}}</span>
9999
<span class="ui text">{{.i18n.Tr "repo.commits.signed_by"}}:</span>
100100
{{avatarByEmail .Verification.SigningEmail "" 28}}
101-
<strong>{{.Verification.SigningUser.Name}}</strong>
101+
<strong>{{.Verification.SigningUser.GetDisplayName}}</strong>
102102
{{end}}
103103
{{else}}
104104
{{svg "gitea-unlock" 16 "mr-3"}}

0 commit comments

Comments
 (0)