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
Adds a "Restore File to Previous Version" option.
We currently have a "Restore File to This Version", but it's common to want to get the file before the change in a known commit.
title:[NSStringstringWithFormat:NSLocalizedString(@"Are you sure you want to restore the file \"%@\" to the version from this commit?", nil), path.lastPathComponent]
293
-
message:NSLocalizedString(@"Any local changes will be overwritten. This action cannot be undone.", nil)
293
+
message:NSLocalizedString(@"Any local changes to this file will be overwritten. This action cannot be undone.", nil)
title:[NSStringstringWithFormat:NSLocalizedString(@"Are you sure you want to restore the file \"%@\" to the version before this commit?", nil), path.lastPathComponent]
317
+
message:NSLocalizedString(@"Any local changes to this file will be overwritten. This action cannot be undone.", nil)
318
+
button:NSLocalizedString(@"Restore", nil)
319
+
suppressionUserDefaultKey:nil
320
+
block:^{
321
+
NSError* error;
322
+
if (![self.repository safeDeleteFileIfExists:path error:&error] || ![self.repository checkoutFileToWorkingDirectory:path fromCommit:parentCommit skipIndex:YESerror:&error]) {
323
+
[selfpresentError:error];
324
+
}
325
+
[self.repository notifyWorkingDirectoryChanged];
326
+
}];
327
+
} else {
328
+
// File didn't exist in parent - it was added in this commit, so delete it
title:[NSStringstringWithFormat:NSLocalizedString(@"Are you sure you want to delete the file \"%@\"?", nil), path.lastPathComponent]
331
+
message:NSLocalizedString(@"The file did not exist before this commit. Any local changes to this file will be lost. This action cannot be undone.", nil)
332
+
button:NSLocalizedString(@"Delete", nil)
333
+
suppressionUserDefaultKey:nil
334
+
block:^{
335
+
NSError* error;
336
+
if (![self.repository safeDeleteFileIfExists:path error:&error]) {
337
+
[selfpresentError:error];
338
+
}
339
+
[self.repository notifyWorkingDirectoryChanged];
340
+
}];
341
+
}
342
+
} else {
343
+
// No parent commit (root commit) - file was added in this commit, so delete it
title:[NSStringstringWithFormat:NSLocalizedString(@"Are you sure you want to delete the file \"%@\"?", nil), path.lastPathComponent]
346
+
message:NSLocalizedString(@"The file did not exist before this commit. Any local changes to this file will be lost. This action cannot be undone.", nil)
347
+
button:NSLocalizedString(@"Delete", nil)
348
+
suppressionUserDefaultKey:nil
349
+
block:^{
350
+
NSError* error;
351
+
if (![self.repository safeDeleteFileIfExists:path error:&error]) {
[[NSWorkspacesharedWorkspace] openURL:[self.repository absoluteURLForFile:path]]; // This will silently fail if the file doesn't exist in the working directory
0 commit comments