Skip to content

Commit 4dc3b2e

Browse files
Use Name instead of DisplayName in LFS Lock (#21415)
Fixes #21268 Co-authored-by: techknowlogick <[email protected]>
1 parent e026459 commit 4dc3b2e

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

modules/convert/convert.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ func ToLFSLock(l *git_model.LFSLock) *api.LFSLock {
412412
Path: l.Path,
413413
LockedAt: l.Created.Round(time.Second),
414414
Owner: &api.LFSLockOwner{
415-
Name: u.DisplayName(),
415+
Name: u.Name,
416416
},
417417
}
418418
}

routers/web/repo/view.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
455455
ctx.ServerError("GetTreePathLock", err)
456456
return
457457
}
458-
ctx.Data["LFSLockOwner"] = u.DisplayName()
458+
ctx.Data["LFSLockOwner"] = u.Name
459459
ctx.Data["LFSLockOwnerHomeLink"] = u.HomeLink()
460460
ctx.Data["LFSLockHint"] = ctx.Tr("repo.editor.this_file_locked")
461461
}

tests/integration/api_repo_lfs_locks_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ func TestAPILFSLocksLogged(t *testing.T) {
112112
if len(test.addTime) > 0 {
113113
var lfsLock api.LFSLockResponse
114114
DecodeJSON(t, resp, &lfsLock)
115+
assert.Equal(t, test.user.Name, lfsLock.Lock.Owner.Name)
115116
assert.EqualValues(t, lfsLock.Lock.LockedAt.Format(time.RFC3339), lfsLock.Lock.LockedAt.Format(time.RFC3339Nano)) // locked at should be rounded to second
116117
for _, id := range test.addTime {
117118
resultsTests[id].locksTimes = append(resultsTests[id].locksTimes, time.Now())
@@ -129,7 +130,7 @@ func TestAPILFSLocksLogged(t *testing.T) {
129130
DecodeJSON(t, resp, &lfsLocks)
130131
assert.Len(t, lfsLocks.Locks, test.totalCount)
131132
for i, lock := range lfsLocks.Locks {
132-
assert.EqualValues(t, test.locksOwners[i].DisplayName(), lock.Owner.Name)
133+
assert.EqualValues(t, test.locksOwners[i].Name, lock.Owner.Name)
133134
assert.WithinDuration(t, test.locksTimes[i], lock.LockedAt, 10*time.Second)
134135
assert.EqualValues(t, lock.LockedAt.Format(time.RFC3339), lock.LockedAt.Format(time.RFC3339Nano)) // locked at should be rounded to second
135136
}
@@ -143,7 +144,7 @@ func TestAPILFSLocksLogged(t *testing.T) {
143144
assert.Len(t, lfsLocksVerify.Ours, test.oursCount)
144145
assert.Len(t, lfsLocksVerify.Theirs, test.theirsCount)
145146
for _, lock := range lfsLocksVerify.Ours {
146-
assert.EqualValues(t, test.user.DisplayName(), lock.Owner.Name)
147+
assert.EqualValues(t, test.user.Name, lock.Owner.Name)
147148
deleteTests = append(deleteTests, struct {
148149
user *user_model.User
149150
repo *repo_model.Repository
@@ -165,7 +166,7 @@ func TestAPILFSLocksLogged(t *testing.T) {
165166
var lfsLockRep api.LFSLockResponse
166167
DecodeJSON(t, resp, &lfsLockRep)
167168
assert.Equal(t, test.lockID, lfsLockRep.Lock.ID)
168-
assert.Equal(t, test.user.DisplayName(), lfsLockRep.Lock.Owner.Name)
169+
assert.Equal(t, test.user.Name, lfsLockRep.Lock.Owner.Name)
169170
}
170171

171172
// check that we don't have any lock

0 commit comments

Comments
 (0)