maintner, devapp: display proper owner names instead of Gerrit User NNN

This change deletes the OwnerName method on GerritCL, since Gerrit's
format for its NoteDB backing store changed to display "Gerrit User NNN"
instead of the proper display name in the meta commit.

Update golang/go#28663

Change-Id: Ifa64ca2b2694b17e888451582b9c63f3f37280a9
Reviewed-on: https://go-review.googlesource.com/c/148557
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Andrew Bonventre 2018-11-08 12:07:56 -05:00
Родитель 6f12689aa1
Коммит 5df336cd7f
4 изменённых файлов: 8 добавлений и 19 удалений

Просмотреть файл

@ -71,7 +71,7 @@ func (s *server) handleReviews(t *template.Template, w http.ResponseWriter, r *h
for _, p := range s.data.reviews.Projects {
var cs []*change
for _, c := range p.Changes {
if c.OwnerName() == ownerFilter {
if o := c.Owner(); o != nil && o.Name() == ownerFilter {
cs = append(cs, c)
totalChanges++
}
@ -115,6 +115,7 @@ func (s *server) updateReviewsData() {
proj := &project{GerritProject: p}
p.ForeachOpenCL(func(cl *maintner.GerritCL) error {
if cl.WorkInProgress() ||
cl.Owner() == nil ||
strings.Contains(cl.Commit.Msg, "DO NOT REVIEW") ||
strings.Contains(cl.Commit.Msg, "DO NOT SUBMIT") {
return nil

Просмотреть файл

@ -66,7 +66,7 @@ header {
{{range .Changes}}
<div class="row">
<div class="date">{{.FormattedLastUpdate}}</div>
<a class="owner" href="?owner={{.OwnerName}}">{{.OwnerName}}</a>
<a class="owner" href="?owner={{.Owner.Name}}">{{.Owner.Name}}</a>
<span class="change">
<a href="https://{{$p.ReviewServer}}/{{.Number}}" target="_blank">{{.Number}}</a>
{{.Subject}}

Просмотреть файл

@ -442,14 +442,6 @@ func (cl *GerritCL) Footer(key string) string {
return v
}
// OwnerName returns the name of the CLs owner or an empty string on error.
func (cl *GerritCL) OwnerName() string {
if !cl.complete() {
return ""
}
return cl.Metas[0].Commit.Author.Name()
}
// OwnerID returns the ID of the CLs owner. It will return -1 on error.
func (cl *GerritCL) OwnerID() int {
if !cl.complete() {

Просмотреть файл

@ -197,7 +197,7 @@ func TestGetGerritMessage(t *testing.T) {
}
}
func TestOwnerNameAndID(t *testing.T) {
func TestOwnerID(t *testing.T) {
cl := &GerritCL{}
meta := newGerritMeta(
&GitCommit{
@ -212,20 +212,16 @@ func TestOwnerNameAndID(t *testing.T) {
cl.Commit = &GitCommit{}
testCases := []struct {
cl *GerritCL
OwnerID int
OwnerName string
cl *GerritCL
OwnerID int
}{
{&GerritCL{}, -1, ""},
{cl, 137, "Rick Sanchez"},
{&GerritCL{}, -1},
{cl, 137},
}
for _, tc := range testCases {
if got := tc.cl.OwnerID(); got != tc.OwnerID {
t.Errorf("cl.OwnerID() = %d; want %d", got, tc.OwnerID)
}
if got := tc.cl.OwnerName(); got != tc.OwnerName {
t.Errorf("cl.OwnerName() = %q; want %q", got, tc.OwnerName)
}
}
}