]> source.dussan.org Git - gitea.git/commitdiff
Show fullname on issue edits and gpg/ssh signing info (#18828)
authorWim <wim@42.be>
Sun, 20 Feb 2022 21:47:17 +0000 (22:47 +0100)
committerGitHub <noreply@github.com>
Sun, 20 Feb 2022 21:47:17 +0000 (21:47 +0000)
Co-authored-by: zeripath <art27@cantab.net>
models/issues/content_history.go
models/issues/content_history_test.go
routers/web/repo/issue_content_history.go
templates/repo/commit_page.tmpl

index 721ce11f85b4b891bf4aa1ea81211d9e6185dca8..57a6ea728f60160edc9cd143ceba2bf79c0f1261 100644 (file)
@@ -137,6 +137,7 @@ func QueryIssueContentHistoryEditedCountMap(dbCtx context.Context, issueID int64
 type IssueContentListItem struct {
        UserID         int64
        UserName       string
+       UserFullName   string
        UserAvatarLink string
 
        HistoryID      int64
@@ -148,7 +149,7 @@ type IssueContentListItem struct {
 // FetchIssueContentHistoryList fetch list
 func FetchIssueContentHistoryList(dbCtx context.Context, issueID, commentID int64) ([]*IssueContentListItem, error) {
        res := make([]*IssueContentListItem, 0)
-       err := db.GetEngine(dbCtx).Select("u.id as user_id, u.name as user_name,"+
+       err := db.GetEngine(dbCtx).Select("u.id as user_id, u.name as user_name, u.full_name as user_full_name,"+
                "h.id as history_id, h.edited_unix, h.is_first_created, h.is_deleted").
                Table([]string{"issue_content_history", "h"}).
                Join("LEFT", []string{"user", "u"}, "h.poster_id = u.id").
index cc9a7c51074cb13208004c69d3235c9b16eb39d8..71ccc6e6a7f95e1674f565d5e0bc7e7e2b984c09 100644 (file)
@@ -43,8 +43,9 @@ func TestContentHistory(t *testing.T) {
                when the refactor of models are done, this test will be possible to be run then with a real `User` model.
        */
        type User struct {
-               ID   int64
-               Name string
+               ID       int64
+               Name     string
+               FullName string
        }
        _ = dbEngine.Sync2(&User{})
 
index 08eb98acb873395dfbc56a44950628db2b22f696..90217a0346e9212ac1a24430f90c9be043c5841f 100644 (file)
@@ -9,6 +9,7 @@ import (
        "fmt"
        "html"
        "net/http"
+       "strings"
 
        "code.gitea.io/gitea/models"
        "code.gitea.io/gitea/models/db"
@@ -16,6 +17,7 @@ import (
        "code.gitea.io/gitea/models/unit"
        "code.gitea.io/gitea/modules/context"
        "code.gitea.io/gitea/modules/log"
+       "code.gitea.io/gitea/modules/setting"
        "code.gitea.io/gitea/modules/timeutil"
 
        "github.com/sergi/go-diff/diffmatchpatch"
@@ -68,9 +70,15 @@ func GetContentHistoryList(ctx *context.Context) {
                        actionText = i18n.Tr(lang, "repo.issues.content_history.edited")
                }
                timeSinceText := timeutil.TimeSinceUnix(item.EditedUnix, lang)
+
+               username := item.UserName
+               if setting.UI.DefaultShowFullName && strings.TrimSpace(item.UserFullName) != "" {
+                       username = strings.TrimSpace(item.UserFullName)
+               }
+
                results = append(results, map[string]interface{}{
                        "name": fmt.Sprintf("<img class='ui avatar image' src='%s'><strong>%s</strong> %s %s",
-                               html.EscapeString(item.UserAvatarLink), html.EscapeString(item.UserName), actionText, timeSinceText),
+                               html.EscapeString(item.UserAvatarLink), html.EscapeString(username), actionText, timeSinceText),
                        "value": item.HistoryID,
                })
        }
index c995273643ad6854bd6f31255a5e775a0b400189..0248a0dedaf97106f60389f0ac606311d27e55cf 100644 (file)
                                                                <span class="ui text mr-3">{{.i18n.Tr "repo.commits.signed_by_untrusted_user_unmatched"}}:</span>
                                                        {{end}}
                                                        {{avatar .Verification.SigningUser 28}}
-                                                       <a href="{{.Verification.SigningUser.HomeLink}}"><strong>{{.Verification.SigningUser.Name}}</strong></a>
+                                                       <a href="{{.Verification.SigningUser.HomeLink}}"><strong>{{.Verification.SigningUser.GetDisplayName}}</strong></a>
                                                {{else}}
                                                        <span title="{{.i18n.Tr "gpg.default_key"}}">{{svg "gitea-lock-cog"}}</span>
                                                        <span class="ui text">{{.i18n.Tr "repo.commits.signed_by"}}:</span>
                                                        {{avatarByEmail .Verification.SigningEmail "" 28}}
-                                                       <strong>{{.Verification.SigningUser.Name}}</strong>
+                                                       <strong>{{.Verification.SigningUser.GetDisplayName}}</strong>
                                                {{end}}
                                        {{else}}
                                                {{svg "gitea-unlock" 16 "mr-3"}}