aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWim <wim@42.be>2022-02-20 20:50:11 +0100
committerGitHub <noreply@github.com>2022-02-20 19:50:11 +0000
commita387636b9a9e1c92388d567508f67b2d56a3ba4e (patch)
treec90b611e85c338242afb79b32c5b80594c13173b
parente039b76a6fab9582e97dd85b6ed7412ce908f14e (diff)
downloadgitea-a387636b9a9e1c92388d567508f67b2d56a3ba4e.tar.gz
gitea-a387636b9a9e1c92388d567508f67b2d56a3ba4e.zip
Show fullname on issue edits and gpg/ssh signing info (#18827)
Show missing full names when configured to do so Co-authored-by: zeripath <art27@cantab.net>
-rw-r--r--models/issues/content_history.go3
-rw-r--r--models/issues/content_history_test.go5
-rw-r--r--routers/web/repo/issue_content_history.go10
-rw-r--r--templates/repo/commit_page.tmpl4
4 files changed, 16 insertions, 6 deletions
diff --git a/models/issues/content_history.go b/models/issues/content_history.go
index 2d2febfa5c..13aadcb1ea 100644
--- a/models/issues/content_history.go
+++ b/models/issues/content_history.go
@@ -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").
diff --git a/models/issues/content_history_test.go b/models/issues/content_history_test.go
index cc9a7c5107..71ccc6e6a7 100644
--- a/models/issues/content_history_test.go
+++ b/models/issues/content_history_test.go
@@ -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{})
diff --git a/routers/web/repo/issue_content_history.go b/routers/web/repo/issue_content_history.go
index 5b5aced6ec..ed9468b913 100644
--- a/routers/web/repo/issue_content_history.go
+++ b/routers/web/repo/issue_content_history.go
@@ -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 = ctx.Locale.Tr("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,
})
}
diff --git a/templates/repo/commit_page.tmpl b/templates/repo/commit_page.tmpl
index 370cafa2e1..f43050ad0e 100644
--- a/templates/repo/commit_page.tmpl
+++ b/templates/repo/commit_page.tmpl
@@ -202,12 +202,12 @@
<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"}}