You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4e4a230
Browse filesBrowse the repository at this point in the historyBrowse files
[Worktree] Prune worktrees, and lock or unlock them
Slice 3 of #675: the actions that keep the worktree list tidy, offered
wherever a worktree's branch is offered, and only as far as the git in
use can carry them out.
- Give Reveal Worktree in Finder and Lock or Unlock a group of their
own after Open Worktree and Copy name, in the menu the sidebar row and
the history label share; git refuses to lock the main worktree, so
there Lock is disabled and says why
- Ask for an optional lock reason on a sheet; git keeps it and the
row's tooltip shows it
- Offer Prune on the WORKTREES header and confirm it with git's own dry
run, enabling it when a worktree is prunable or its folder is gone,
since moving a folder away touches nothing git watches
- Offer both Lock and Unlock, and always Prune, before git 2.31, which
does not report whether a worktree is locked or prunable
NSString *lockTitle = NSLocalizedString(@"Lock Worktree…", @"Contextual Menu Item to lock a worktree");
1164
+
NSString *unlockTitle = NSLocalizedString(@"Unlock Worktree", @"Contextual Menu Item to unlock a worktree");
1165
+
NSString *version = self.gitVersion;
1166
+
1167
+
if (worktree.isMain)
1168
+
return @[ [selfmenuItemWithTitle:lockTitle action:@selector(lockWorktree:) worktree:worktree disabledBecause:NSLocalizedString(@"git cannot lock the main worktree", @"Contextual Menu Item tooltip for the main worktree, which cannot be locked")] ];
1169
+
1170
+
if (![PBGitBinary version:version isAtLeast:@PBGitWorktreeLockVersion])
if (![[NSFileManagerdefaultManager] fileExistsAtPath:worktree.path])
1188
+
reason = [NSStringstringWithFormat:NSLocalizedString(@"The folder %@ no longer exists", @"Contextual Menu Item tooltip for a worktree whose folder is gone"), worktree.path];
1189
+
1190
+
return [selfmenuItemWithTitle:NSLocalizedString(@"Reveal Worktree in Finder", @"Contextual Menu Item to show a worktree's folder in the Finder") action:@selector(revealWorktreeInFinder:) worktree:worktree disabledBecause:reason];
return @[ [selfmenuItemWithTitle:title action:@selector(pruneWorktrees:) worktree:nildisabledBecause:NSLocalizedString(@"Every worktree still has its folder", @"Contextual Menu Item tooltip when no worktree can be pruned")] ];
NSString *copyTitle = [NSStringstringWithFormat:NSLocalizedString(@"Copy name “%@”", @"Contextual Menu Item to copy the selected ref's name to the clipboard"), refName];
NSString *createBranchTitle = ref.isRemoteBranch ? [NSStringstringWithFormat:NSLocalizedString(@"Create Branch tracking “%@”…", @"Contextual Menu Item to create a branch tracking the selected remote branch"), refName] : NSLocalizedString(@"Create Branch…", @"Contextual Menu Item to create a new branch at the selected ref");
alert.messageText = [NSStringstringWithFormat:NSLocalizedString(@"Lock the worktree at %@?", @"Title of the sheet that locks a worktree"), worktree.path];
754
+
alert.informativeText = NSLocalizedString(@"git will not prune, move or remove a locked worktree, and shows the reason to anyone who tries.", @"Explanation on the sheet that locks a worktree");
755
+
alert.accessoryView = reasonField;
756
+
[alert addButtonWithTitle:NSLocalizedString(@"Lock", @"Button that locks a worktree")];
alert.messageText = NSLocalizedString(@"Prune these worktrees?", @"Title of the sheet that confirms pruning worktrees");
804
+
alert.informativeText = [NSStringstringWithFormat:NSLocalizedString(@"git will forget these worktrees:\n\n%@", @"Explanation on the sheet that confirms pruning worktrees, followed by git's own list"), report];
805
+
[alert addButtonWithTitle:NSLocalizedString(@"Prune", @"Button that prunes worktrees")];
0 commit comments