mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-21 08:04:54 +02:00
Fix bug when displaying git user avatar in commits list (#35006)
A quick fix for #34991 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
e13deb7a16
commit
9f1baa7d18
@ -7,6 +7,7 @@ been added to each release, please refer to the [blog](https://blog.gitea.com).
|
|||||||
## [1.24.3](https://github.com/go-gitea/gitea/releases/tag/1.24.3) - 2025-07-10
|
## [1.24.3](https://github.com/go-gitea/gitea/releases/tag/1.24.3) - 2025-07-10
|
||||||
|
|
||||||
* BUGFIXES
|
* BUGFIXES
|
||||||
|
* Fix bug when displaying git user avatar in commits list (#35006)
|
||||||
* Fix API response for swagger spec (#35029)
|
* Fix API response for swagger spec (#35029)
|
||||||
* Start automerge check again after the conflict check and the schedule (#34988) (#35002)
|
* Start automerge check again after the conflict check and the schedule (#34988) (#35002)
|
||||||
* Fix the response format for actions/workflows (#35009) (#35016)
|
* Fix the response format for actions/workflows (#35009) (#35016)
|
||||||
|
@ -1176,12 +1176,14 @@ func GetUsersByEmails(ctx context.Context, emails []string) (*EmailUserMap, erro
|
|||||||
|
|
||||||
needCheckEmails := make(container.Set[string])
|
needCheckEmails := make(container.Set[string])
|
||||||
needCheckUserNames := make(container.Set[string])
|
needCheckUserNames := make(container.Set[string])
|
||||||
|
noReplyAddressSuffix := "@" + strings.ToLower(setting.Service.NoReplyAddress)
|
||||||
for _, email := range emails {
|
for _, email := range emails {
|
||||||
if strings.HasSuffix(email, "@"+setting.Service.NoReplyAddress) {
|
emailLower := strings.ToLower(email)
|
||||||
username := strings.TrimSuffix(email, "@"+setting.Service.NoReplyAddress)
|
if noReplyUserNameLower, ok := strings.CutSuffix(emailLower, noReplyAddressSuffix); ok {
|
||||||
needCheckUserNames.Add(strings.ToLower(username))
|
needCheckUserNames.Add(noReplyUserNameLower)
|
||||||
|
needCheckEmails.Add(emailLower)
|
||||||
} else {
|
} else {
|
||||||
needCheckEmails.Add(strings.ToLower(email))
|
needCheckEmails.Add(emailLower)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +85,10 @@ func TestUserEmails(t *testing.T) {
|
|||||||
testGetUserByEmail(t, c.Email, c.UID)
|
testGetUserByEmail(t, c.Email, c.UID)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
t.Run("NoReplyConflict", func(t *testing.T) {
|
||||||
|
setting.Service.NoReplyAddress = "example.com"
|
||||||
|
testGetUserByEmail(t, "user1-2@example.COM", 1)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<td class="author">
|
<td class="author">
|
||||||
<div class="tw-flex">
|
<div class="tw-flex">
|
||||||
{{$userName := .Author.Name}}
|
{{$userName := .Author.Name}}
|
||||||
{{if .User}}
|
{{if and .User (gt .User.ID 0)}}
|
||||||
{{if and .User.FullName DefaultShowFullName}}
|
{{if and .User.FullName DefaultShowFullName}}
|
||||||
{{$userName = .User.FullName}}
|
{{$userName = .User.FullName}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -23,39 +23,59 @@ import (
|
|||||||
|
|
||||||
func TestRepoCommits(t *testing.T) {
|
func TestRepoCommits(t *testing.T) {
|
||||||
defer tests.PrepareTestEnv(t)()
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
|
||||||
session := loginUser(t, "user2")
|
session := loginUser(t, "user2")
|
||||||
|
|
||||||
// Request repository commits page
|
t.Run("CommitList", func(t *testing.T) {
|
||||||
req := NewRequest(t, "GET", "/user2/repo1/commits/branch/master")
|
req := NewRequest(t, "GET", "/user2/repo16/commits/branch/master")
|
||||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
doc := NewHTMLParser(t, resp.Body)
|
var commits, userHrefs []string
|
||||||
commitURL, exists := doc.doc.Find("#commits-table .commit-id-short").Attr("href")
|
doc := NewHTMLParser(t, resp.Body)
|
||||||
assert.True(t, exists)
|
doc.doc.Find("#commits-table .commit-id-short").Each(func(i int, s *goquery.Selection) {
|
||||||
assert.NotEmpty(t, commitURL)
|
commits = append(commits, path.Base(s.AttrOr("href", "")))
|
||||||
}
|
})
|
||||||
|
doc.doc.Find("#commits-table .author-wrapper").Each(func(i int, s *goquery.Selection) {
|
||||||
func Test_ReposGitCommitListNotMaster(t *testing.T) {
|
userHrefs = append(userHrefs, s.AttrOr("href", ""))
|
||||||
defer tests.PrepareTestEnv(t)()
|
})
|
||||||
session := loginUser(t, "user2")
|
assert.Equal(t, []string{"69554a64c1e6030f051e5c3f94bfbd773cd6a324", "27566bd5738fc8b4e3fef3c5e72cce608537bd95", "5099b81332712fe655e34e8dd63574f503f61811"}, commits)
|
||||||
req := NewRequest(t, "GET", "/user2/repo16/commits/branch/master")
|
assert.Equal(t, []string{"/user2", "/user21", "/user2"}, userHrefs)
|
||||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
|
||||||
|
|
||||||
doc := NewHTMLParser(t, resp.Body)
|
|
||||||
var commits []string
|
|
||||||
doc.doc.Find("#commits-table .commit-id-short").Each(func(i int, s *goquery.Selection) {
|
|
||||||
commitURL, _ := s.Attr("href")
|
|
||||||
commits = append(commits, path.Base(commitURL))
|
|
||||||
})
|
})
|
||||||
assert.Equal(t, []string{"69554a64c1e6030f051e5c3f94bfbd773cd6a324", "27566bd5738fc8b4e3fef3c5e72cce608537bd95", "5099b81332712fe655e34e8dd63574f503f61811"}, commits)
|
|
||||||
|
|
||||||
var userHrefs []string
|
t.Run("LastCommit", func(t *testing.T) {
|
||||||
doc.doc.Find("#commits-table .author-wrapper").Each(func(i int, s *goquery.Selection) {
|
req := NewRequest(t, "GET", "/user2/repo16")
|
||||||
userHref, _ := s.Attr("href")
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
userHrefs = append(userHrefs, userHref)
|
doc := NewHTMLParser(t, resp.Body)
|
||||||
|
commitHref := doc.doc.Find(".latest-commit .commit-id-short").AttrOr("href", "")
|
||||||
|
authorHref := doc.doc.Find(".latest-commit .author-wrapper").AttrOr("href", "")
|
||||||
|
assert.Equal(t, "/user2/repo16/commit/69554a64c1e6030f051e5c3f94bfbd773cd6a324", commitHref)
|
||||||
|
assert.Equal(t, "/user2", authorHref)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("CommitListNonExistingCommiter", func(t *testing.T) {
|
||||||
|
// check the commit list for a repository with no gitea user
|
||||||
|
// * commit 985f0301dba5e7b34be866819cd15ad3d8f508ee (branch2)
|
||||||
|
// * Author: 6543 <6543@obermui.de>
|
||||||
|
req := NewRequest(t, "GET", "/user2/repo1/commits/branch/branch2")
|
||||||
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
|
doc := NewHTMLParser(t, resp.Body)
|
||||||
|
commitHref := doc.doc.Find("#commits-table tr:first-child .commit-id-short").AttrOr("href", "")
|
||||||
|
assert.Equal(t, "/user2/repo1/commit/985f0301dba5e7b34be866819cd15ad3d8f508ee", commitHref)
|
||||||
|
authorElem := doc.doc.Find("#commits-table tr:first-child .author-wrapper")
|
||||||
|
assert.Equal(t, "6543", authorElem.Text())
|
||||||
|
assert.Equal(t, "span", authorElem.Nodes[0].Data)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("LastCommitNonExistingCommiter", func(t *testing.T) {
|
||||||
|
req := NewRequest(t, "GET", "/user2/repo1/src/branch/branch2")
|
||||||
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
doc := NewHTMLParser(t, resp.Body)
|
||||||
|
commitHref := doc.doc.Find(".latest-commit .commit-id-short").AttrOr("href", "")
|
||||||
|
assert.Equal(t, "/user2/repo1/commit/985f0301dba5e7b34be866819cd15ad3d8f508ee", commitHref)
|
||||||
|
authorElem := doc.doc.Find(".latest-commit .author-wrapper")
|
||||||
|
assert.Equal(t, "6543", authorElem.Text())
|
||||||
|
assert.Equal(t, "span", authorElem.Nodes[0].Data)
|
||||||
})
|
})
|
||||||
assert.Equal(t, []string{"/user2", "/user21", "/user2"}, userHrefs)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func doTestRepoCommitWithStatus(t *testing.T, state string, classes ...string) {
|
func doTestRepoCommitWithStatus(t *testing.T, state string, classes ...string) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user