Gitea: Feature: File locking in User interface

Created on 25 Oct 2019  路  11Comments  路  Source: go-gitea/gitea

Git LFS support file locking. File locking with git lfs can be used without storing the file as a git lfs file.

I would like to have the following functionality in Gitea UI:

  • [x] Respect file locking when editing. If a file is locked with git lfs it shall not be editable in the UI. (#8719)
  • [x] Respect file locking, no upload of file if locked (#8769)
  • [x] Show if a file is locked and who locked it (#8719)
  • [x] See all locks and force unlock in repo setting interface (#8726)
  • [ ] Check locks on server side when pushing (#11094)
  • [ ] Warn if user edits file that is lockable (.gitattributes), but not locked (?)
  • [ ] Support lock file and unlocking (your own lock) in UI. Files not marked as lockable can be locked but with warning?
kinenhancement revieweconfirmed

Most helpful comment

@davidsvantesson @guillep2k @lunny
I make a update to respect file locking. Files will not be editable if LFS locked.

However, I'm not sure if it's a good idea to allow user lock files in the UI.
For example, I'm not sure how to check is a file is lockable.

I'll keep working on this enhancement. I will send a PR at first at first.

All 11 comments

@davidsvantesson @guillep2k @lunny
I make a update to respect file locking. Files will not be editable if LFS locked.

However, I'm not sure if it's a good idea to allow user lock files in the UI.
For example, I'm not sure how to check is a file is lockable.

I'll keep working on this enhancement. I will send a PR at first at first.

Better to make smaller PRs than implement all at once. Determining if a file is locked is a first good step.

Locking a file actually doesn't require the lockable attribute. The lockable attribute is only used to make files read-only when they are not locked. But I am not sure if it is a good idea to allow locking a file in the UI that has not been set as lockable.

This is what I can find about determining if a file has the lockable attribute:
https://stackoverflow.com/a/56492205

I think you can't really rely on the lockable attribute in the .gitattributes file - probably if the attribute isn't there you might have to put a warning up but people can have attributes set in multiple ways so only providing locking to those files in .gitattributes would be annoying to them.

(As an aside when you create a file in the editor we read the .gitattributes to determine if it should be lfs'd - because there's no other way of knowing.)

If a file is "lockable" according to .gitattributes, shouldn't we force to lock the file before editing? I mean that would best correspond to how a checkout on computer works; The file is read-only until locking the file.

I suspect it's better to just give the user the option to lock in all cases, but have a slightly different UI when editing a file where the lockable attribute is set. Allowing people to lock new files is harder - you'd have to remember to remove the lock if they change the filename, and you can't easily test if the filename would be lockable without making a temporary repo (this could potentially be avoided), an index from the branch and then running git check-attr - it's really not free although I think we could make the index creation in read-tree a bit more efficient only reading in the .gitattributes. Similarly if you lock a file when editing are you supposed to lock the new file you're renaming it to?

We also don't have a mechanism to force the user to unlock if they've locked for any period of time. So if they navigate away a user could use this UI to lock all files.

The other issue is which .gitattributes do you interrogate - presumably you look at the one for the branch you're editing. Git lfs locks are locks for the whole of the repo.

Is git lfs using the .gitattributes file of the currently checked out branch, or the master (default) branch?

Git lfs uses what you have checked out or in your index. It runs git check-attr on the file.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

Ad Show if a file is locked and who locked it:
Do you think it would be nice to show locks (probably only the lock symbol) also already in the <Code> tab's file tree?

Yes, for files that are locked. Maybe for files that has the lockable attribute and is not locked it could be shown also (but not for other files).

True, open lock for lockable but not locked, closed lock for (lockable AND) locked ones.

Was this page helpful?
0 / 5 - 0 ratings