@@ -310,6 +310,7 @@ class LocksView : Subview
310
310
311
311
[ SerializeField ] private CacheUpdateEvent lastLocksChangedEvent ;
312
312
[ SerializeField ] private List < GitLock > lockedFiles = new List < GitLock > ( ) ;
313
+ [ SerializeField ] private string currentUsername ;
313
314
314
315
public override void OnEnable ( )
315
316
{
@@ -349,8 +350,22 @@ public override void OnGUI()
349
350
} ,
350
351
entry => { } ,
351
352
entry => {
352
- GenericMenu menu = new GenericMenu ( ) ;
353
- menu . AddItem ( new GUIContent ( "Unlock File" ) , false , UnlockFile ) ;
353
+ string unlockFile ;
354
+ GenericMenu . MenuFunction menuFunction ;
355
+
356
+ if ( entry . User == currentUsername )
357
+ {
358
+ unlockFile = "Unlock File" ;
359
+ menuFunction = UnlockSelectedEntry ;
360
+ }
361
+ else
362
+ {
363
+ unlockFile = "Force Unlock File" ;
364
+ menuFunction = ForceUnlockSelectedEntry ;
365
+ }
366
+
367
+ var menu = new GenericMenu ( ) ;
368
+ menu . AddItem ( new GUIContent ( unlockFile ) , false , menuFunction ) ;
354
369
menu . ShowAsContext ( ) ;
355
370
} ) ;
356
371
@@ -359,7 +374,14 @@ public override void OnGUI()
359
374
}
360
375
}
361
376
362
- private void UnlockFile ( )
377
+ private void UnlockSelectedEntry ( )
378
+ {
379
+ Repository
380
+ . ReleaseLock ( selectedEntry . Path , false )
381
+ . Start ( ) ;
382
+ }
383
+
384
+ private void ForceUnlockSelectedEntry ( )
363
385
{
364
386
Repository
365
387
. ReleaseLock ( selectedEntry . Path , true )
@@ -414,6 +436,10 @@ private void MaybeUpdateData()
414
436
415
437
lockedFiles = Repository . CurrentLocks ;
416
438
439
+ //TODO: ONE_USER_LOGIN This assumes only ever one user can login
440
+ var keychainConnection = Platform . Keychain . Connections . First ( ) ;
441
+ currentUsername = keychainConnection . Username ;
442
+
417
443
BuildLocksControl ( ) ;
418
444
}
419
445
}
0 commit comments