@@ -223,6 +223,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
223
223
224
224
isTextFile := base .IsTextFile (buf )
225
225
isLFSFile := false
226
+ isLFSLock := false
226
227
ctx .Data ["IsTextFile" ] = isTextFile
227
228
228
229
//Check for LFS meta file
@@ -265,6 +266,13 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
265
266
ctx .Data ["RawFileLink" ] = fmt .Sprintf ("%s%s.git/info/lfs/objects/%s/%s" , setting .AppURL , ctx .Repo .Repository .FullName (), meta .Oid , filenameBase64 )
266
267
}
267
268
}
269
+ lfsLock , err := ctx .Repo .Repository .GetTreePathLock (ctx .Repo .TreePath )
270
+ if err != nil {
271
+ ctx .ServerError ("GetTreePathLock" , err )
272
+ }
273
+ if lfsLock != nil && lfsLock .OwnerID != ctx .User .ID {
274
+ isLFSLock = true
275
+ }
268
276
269
277
// Assume file is not editable first.
270
278
if isLFSFile {
@@ -329,8 +337,13 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
329
337
}
330
338
if ! isLFSFile {
331
339
if ctx .Repo .CanEnableEditor () {
332
- ctx .Data ["CanEditFile" ] = true
333
- ctx .Data ["EditFileTooltip" ] = ctx .Tr ("repo.editor.edit_this_file" )
340
+ if isLFSLock {
341
+ ctx .Data ["CanEditFile" ] = false
342
+ ctx .Data ["EditFileTooltip" ] = ctx .Tr ("repo.editor.this_file_locked" )
343
+ } else {
344
+ ctx .Data ["CanEditFile" ] = true
345
+ ctx .Data ["EditFileTooltip" ] = ctx .Tr ("repo.editor.edit_this_file" )
346
+ }
334
347
} else if ! ctx .Repo .IsViewBranch {
335
348
ctx .Data ["EditFileTooltip" ] = ctx .Tr ("repo.editor.must_be_on_a_branch" )
336
349
} else if ! ctx .Repo .CanWrite (models .UnitTypeCode ) {
@@ -363,8 +376,13 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
363
376
}
364
377
365
378
if ctx .Repo .CanEnableEditor () {
366
- ctx .Data ["CanDeleteFile" ] = true
367
- ctx .Data ["DeleteFileTooltip" ] = ctx .Tr ("repo.editor.delete_this_file" )
379
+ if isLFSLock {
380
+ ctx .Data ["CanDeleteFile" ] = false
381
+ ctx .Data ["DeleteFileTooltip" ] = ctx .Tr ("repo.editor.this_file_locked" )
382
+ } else {
383
+ ctx .Data ["CanDeleteFile" ] = true
384
+ ctx .Data ["DeleteFileTooltip" ] = ctx .Tr ("repo.editor.delete_this_file" )
385
+ }
368
386
} else if ! ctx .Repo .IsViewBranch {
369
387
ctx .Data ["DeleteFileTooltip" ] = ctx .Tr ("repo.editor.must_be_on_a_branch" )
370
388
} else if ! ctx .Repo .CanWrite (models .UnitTypeCode ) {
0 commit comments