@@ -265,6 +265,17 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
265265 ctx .Data ["RawFileLink" ] = fmt .Sprintf ("%s%s.git/info/lfs/objects/%s/%s" , setting .AppURL , ctx .Repo .Repository .FullName (), meta .Oid , filenameBase64 )
266266 }
267267 }
268+ // Check LFS Lock
269+ lfsLock , err := ctx .Repo .Repository .GetTreePathLock (ctx .Repo .TreePath )
270+ ctx .Data ["LFSLock" ] = lfsLock
271+ if err != nil {
272+ ctx .ServerError ("GetTreePathLock" , err )
273+ return
274+ }
275+ if lfsLock != nil {
276+ ctx .Data ["LFSLockOwner" ] = lfsLock .Owner .DisplayName ()
277+ ctx .Data ["LFSLockHint" ] = ctx .Tr ("repo.editor.this_file_locked" )
278+ }
268279
269280 // Assume file is not editable first.
270281 if isLFSFile {
@@ -334,8 +345,13 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
334345 }
335346 if ! isLFSFile {
336347 if ctx .Repo .CanEnableEditor () {
337- ctx .Data ["CanEditFile" ] = true
338- ctx .Data ["EditFileTooltip" ] = ctx .Tr ("repo.editor.edit_this_file" )
348+ if lfsLock != nil && lfsLock .OwnerID != ctx .User .ID {
349+ ctx .Data ["CanEditFile" ] = false
350+ ctx .Data ["EditFileTooltip" ] = ctx .Tr ("repo.editor.this_file_locked" )
351+ } else {
352+ ctx .Data ["CanEditFile" ] = true
353+ ctx .Data ["EditFileTooltip" ] = ctx .Tr ("repo.editor.edit_this_file" )
354+ }
339355 } else if ! ctx .Repo .IsViewBranch {
340356 ctx .Data ["EditFileTooltip" ] = ctx .Tr ("repo.editor.must_be_on_a_branch" )
341357 } else if ! ctx .Repo .CanWrite (models .UnitTypeCode ) {
@@ -368,8 +384,13 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
368384 }
369385
370386 if ctx .Repo .CanEnableEditor () {
371- ctx .Data ["CanDeleteFile" ] = true
372- ctx .Data ["DeleteFileTooltip" ] = ctx .Tr ("repo.editor.delete_this_file" )
387+ if lfsLock != nil && lfsLock .OwnerID != ctx .User .ID {
388+ ctx .Data ["CanDeleteFile" ] = false
389+ ctx .Data ["DeleteFileTooltip" ] = ctx .Tr ("repo.editor.this_file_locked" )
390+ } else {
391+ ctx .Data ["CanDeleteFile" ] = true
392+ ctx .Data ["DeleteFileTooltip" ] = ctx .Tr ("repo.editor.delete_this_file" )
393+ }
373394 } else if ! ctx .Repo .IsViewBranch {
374395 ctx .Data ["DeleteFileTooltip" ] = ctx .Tr ("repo.editor.must_be_on_a_branch" )
375396 } else if ! ctx .Repo .CanWrite (models .UnitTypeCode ) {
0 commit comments