mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
Update PBGitErrors to include some error messages dealing with missing remote tracking branches.
This is especially useful for the new button functionality.
This commit is contained in:
@@ -268,7 +268,7 @@
|
||||
F56CC7310E65E0E5004307B4 /* PBGraphCellInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGraphCellInfo.m; sourceTree = "<group>"; };
|
||||
F57240BA0E9678EA00D8EE66 /* deleted_file.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = deleted_file.png; path = Images/deleted_file.png; sourceTree = "<group>"; };
|
||||
F574A2830EAE2EAC003F2CB1 /* PBRefController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBRefController.h; sourceTree = "<group>"; };
|
||||
F574A2840EAE2EAC003F2CB1 /* PBRefController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBRefController.m; sourceTree = "<group>"; };
|
||||
F574A2840EAE2EAC003F2CB1 /* PBRefController.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = PBRefController.m; sourceTree = "<group>"; tabWidth = 4; usesTabs = 0; };
|
||||
F57CC38F0E05DDF2000472E2 /* PBEasyPipe.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBEasyPipe.h; sourceTree = "<group>"; };
|
||||
F57CC3900E05DDF2000472E2 /* PBEasyPipe.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBEasyPipe.m; sourceTree = "<group>"; };
|
||||
F57CC43F0E05E496000472E2 /* PBGitWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitWindowController.h; sourceTree = "<group>"; };
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
OBJC_EXTERN NSString * const PBGitXErrorDomain;
|
||||
OBJC_EXTERN NSString * const PBCLIProxyErrorDomain;
|
||||
|
||||
OBJC_EXTERN NSString * const PBInvalidBranchErrMsg;
|
||||
OBJC_EXTERN NSString * const PBMissingRemoteErrMsg;
|
||||
|
||||
OBJC_EXTERN const NSInteger PBFileReadingUnsupportedErrorCode; /* @"Reading files is not supported." */
|
||||
OBJC_EXTERN const NSInteger PBNotAGitRepositoryErrorCode; /* @"%@ does not appear to be a git repository." */
|
||||
OBJC_EXTERN const NSInteger PBGitBinaryNotFoundErrorCode;
|
||||
+6
-2
@@ -19,9 +19,13 @@
|
||||
|
||||
#import "PBGitXErrors.h"
|
||||
|
||||
NSString * const PBGitXErrorDomain = @"GitXErrorDomain";
|
||||
NSString * const PBCLIProxyErrorDomain = @"CLIProxyErrorDomain";
|
||||
NSString * const PBGitXErrorDomain = @"GitXErrorDomain";
|
||||
NSString * const PBCLIProxyErrorDomain = @"CLIProxyErrorDomain";
|
||||
|
||||
NSString * const PBInvalidBranchErrMsg = @"Please select a local branch from the branch popup menu, which has a corresponding remote tracking branch set up.\n\n"
|
||||
@"You can also use the context menu to choose a branch by right clicking on its label in the history view.";
|
||||
|
||||
NSString * const PBMissingRemoteErrMsg = @"This branch does not appear to have a remote tracking branch associated in its config file section.";
|
||||
|
||||
const NSInteger PBNotAGitRepositoryErrorCode = 1;
|
||||
const NSInteger PBFileReadingUnsupportedErrorCode = 2;
|
||||
|
||||
@@ -45,6 +45,8 @@
|
||||
- (BOOL) rebaseImpl:(NSString *)refName;
|
||||
- (BOOL) fetchImpl:(NSString *)refName;
|
||||
|
||||
- (void) showMessageSheet:(NSString *)title message:(NSString *)msg;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSString (PBRefSpecAdditions)
|
||||
|
||||
+60
-27
@@ -104,9 +104,13 @@
|
||||
- (BOOL) pushImpl:(NSString *)refName
|
||||
{
|
||||
int ret = 1;
|
||||
BOOL success = NO;
|
||||
BOOL success = NO;
|
||||
NSString *remote = [[historyController.repository config] valueForKeyPath:[NSString stringWithFormat:@"branch.%@.remote", refName]];
|
||||
NSString *rval = [historyController.repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"push", remote, refName, nil] retValue: &ret];
|
||||
if (!remote) {
|
||||
[self showMessageSheet:@"Push to Remote" message:PBMissingRemoteErrMsg];
|
||||
return success;
|
||||
}
|
||||
if (ret) {
|
||||
NSString *info = [NSString stringWithFormat:@"There was an error pushing the branch to the remote repository.\n\n%d\n%@", ret, rval];
|
||||
[[historyController.repository windowController] showMessageSheet:@"Pushing branch failed" infoText:info];
|
||||
@@ -123,6 +127,10 @@
|
||||
int ret = 1;
|
||||
BOOL success = NO;
|
||||
NSString *remote = [[historyController.repository config] valueForKeyPath:[NSString stringWithFormat:@"branch.%@.remote", refName]];
|
||||
if (!remote) {
|
||||
[self showMessageSheet:@"Pull from Remote" message:PBMissingRemoteErrMsg];
|
||||
return success;
|
||||
}
|
||||
NSString *rval = [historyController.repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"pull", remote, refName, nil] retValue: &ret];
|
||||
if (ret) {
|
||||
NSString *info = [NSString stringWithFormat:@"There was an error pulling from the remote repository.\n\n%d\n%@", ret, rval];
|
||||
@@ -140,6 +148,10 @@
|
||||
int ret = 1;
|
||||
BOOL success = NO;
|
||||
NSString *remote = [[[historyController repository] config] valueForKeyPath:[NSString stringWithFormat:@"branch.%@.remote", refName]];
|
||||
if (!remote) {
|
||||
[self showMessageSheet:@"Pull Rebase from Remote" message:PBMissingRemoteErrMsg];
|
||||
return success;
|
||||
}
|
||||
NSString *rval = [[historyController repository] outputInWorkdirForArguments:[NSArray arrayWithObjects:@"pull", @"--rebase", remote, refName, nil] retValue: &ret];
|
||||
if (ret) {
|
||||
NSString *info = [NSString stringWithFormat:@"There was an error rebasing from the remote repository.\n\n%d\n%@", ret, rval];
|
||||
@@ -254,52 +266,73 @@
|
||||
# pragma mark Add ref methods
|
||||
-(void)addRef:(id)sender
|
||||
{
|
||||
[errorMessage setStringValue:@""];
|
||||
[NSApp beginSheet:newBranchSheet
|
||||
modalForWindow:[[historyController view] window]
|
||||
modalDelegate:NULL
|
||||
didEndSelector:NULL
|
||||
contextInfo:NULL];
|
||||
[errorMessage setStringValue:@""];
|
||||
[NSApp beginSheet:newBranchSheet
|
||||
modalForWindow:[[historyController view] window]
|
||||
modalDelegate:NULL
|
||||
didEndSelector:NULL
|
||||
contextInfo:NULL];
|
||||
}
|
||||
|
||||
- (void) showMessageSheet:(NSString *)title message:(NSString *)msg {
|
||||
|
||||
[[NSAlert alertWithMessageText:title
|
||||
defaultButton:@"OK"
|
||||
alternateButton:nil
|
||||
otherButton:nil
|
||||
informativeTextWithFormat:msg]
|
||||
beginSheetModalForWindow:[[historyController view] window]
|
||||
modalDelegate:self
|
||||
didEndSelector:nil
|
||||
contextInfo:nil];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
-(void)rebaseButton:(id)sender
|
||||
{
|
||||
[sender setEnabled:NO];
|
||||
NSString *refName = [[historyController.repository.currentBranch simpleRef] refForSpec];
|
||||
if (refName)
|
||||
NSString *refName = [[[[historyController repository] currentBranch] simpleRef] refForSpec];
|
||||
if (refName) {
|
||||
[self rebaseImpl:refName];
|
||||
[sender setEnabled:YES];
|
||||
// NSLog([NSString stringWithFormat:@"Rebase hit for %@!", refName]);
|
||||
} else {
|
||||
[self showMessageSheet:@"Pull Rebase from Remote" message:PBInvalidBranchErrMsg];
|
||||
}
|
||||
// NSLog([NSString stringWithFormat:@"Rebase hit for %@!", refName]);
|
||||
}
|
||||
|
||||
-(void)pushButton:(id)sender
|
||||
{
|
||||
[sender setEnabled:NO];
|
||||
NSString *refName = [[historyController.repository.currentBranch simpleRef] refForSpec];
|
||||
if (refName)
|
||||
NSString *refName = [[[[historyController repository] currentBranch] simpleRef] refForSpec];
|
||||
if (refName) {
|
||||
[self pushImpl:refName];
|
||||
[sender setEnabled:YES];
|
||||
// NSLog([NSString stringWithFormat:@"Push hit for %@!", refName]);
|
||||
} else {
|
||||
[self showMessageSheet:@"Push to Remote" message:PBInvalidBranchErrMsg];
|
||||
}
|
||||
// NSLog([NSString stringWithFormat:@"Push hit for %@!", refName]);
|
||||
}
|
||||
|
||||
-(void)pullButton:(id)sender
|
||||
- (void) pullButton:(id)sender
|
||||
{
|
||||
[sender setEnabled:NO];
|
||||
NSString *refName = [[historyController.repository.currentBranch simpleRef] refForSpec];
|
||||
if (refName)
|
||||
NSString * refName = [[[[historyController repository] currentBranch] simpleRef] refForSpec];
|
||||
if (refName) {
|
||||
[self pullImpl:refName];
|
||||
[sender setEnabled:YES];
|
||||
} else {
|
||||
[sender setEnabled:YES];
|
||||
[self showMessageSheet:@"Pull from Remote" message:PBInvalidBranchErrMsg];
|
||||
}
|
||||
// NSLog([NSString stringWithFormat:@"Pull hit for %@!", refName]);
|
||||
}
|
||||
|
||||
-(void)fetchButton:(id)sender
|
||||
{
|
||||
[sender setEnabled:NO];
|
||||
NSString *refName = [[historyController.repository.currentBranch simpleRef] refForSpec];
|
||||
if (refName)
|
||||
NSString *refName = [[[[historyController repository] currentBranch] simpleRef] refForSpec];
|
||||
if (refName) {
|
||||
[self fetchImpl:refName];
|
||||
[sender setEnabled:YES];
|
||||
// NSLog([NSString stringWithFormat:@"Fetch hit for %@!", refName]);
|
||||
} else {
|
||||
[sender setEnabled:YES];
|
||||
[self showMessageSheet:@"Fetch from Remote" message:PBInvalidBranchErrMsg];
|
||||
}
|
||||
// NSLog([NSString stringWithFormat:@"Fetch hit for %@!", refName]);
|
||||
}
|
||||
|
||||
-(void)saveSheet:(id) sender
|
||||
|
||||
Reference in New Issue
Block a user