From cdc4f5208b7459205f559a1ad548aa22bec04c42 Mon Sep 17 00:00:00 2001 From: Morgan Schweers Date: Fri, 23 Oct 2009 23:57:30 -0700 Subject: [PATCH] Add a menu item and an action for pushing a repo up. --- PBRefController.m | 16 +++++++++++++++- PBRefMenuItem.m | 7 ++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/PBRefController.m b/PBRefController.m index 31c5590..d4ac81e 100644 --- a/PBRefController.m +++ b/PBRefController.m @@ -60,7 +60,21 @@ int ret = 1; [historyController.repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"checkout", [[sender ref] shortName], nil] retValue: &ret]; if (ret) { - [[historyController.repository windowController] showMessageSheet:@"Checking out branch failed" infoText:@"There was an error checking out the branch. Perhaps your working directory is not clean?"]; + NSString *info = [NSString stringWithFormat:@"There was an error checking out the branch. Perhaps your working directory is not clean?"]; + [[historyController.repository windowController] showMessageSheet:@"Checking out branch failed" infoText:info]; + return; + } + [historyController.repository reloadRefs]; + [commitController rearrangeObjects]; +} + +- (void) pushRef:(PBRefMenuItem *)sender +{ + int ret = 1; + NSString *rval = [historyController.repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"push", @"origin", [[sender ref] shortName], nil] retValue: &ret]; + if (ret) { + NSString *info = [NSString stringWithFormat:@"There was an error pushing the branch to the origin.\n\n%d\n%@", ret, rval]; + [[historyController.repository windowController] showMessageSheet:@"Pushing branch failed" infoText:info]; return; } [historyController.repository reloadRefs]; diff --git a/PBRefMenuItem.m b/PBRefMenuItem.m index 22aaae5..a711370 100644 --- a/PBRefMenuItem.m +++ b/PBRefMenuItem.m @@ -28,7 +28,12 @@ [array addObject:[[PBRefMenuItem alloc] initWithTitle:@"Checkout branch" action:@selector(checkoutRef:) keyEquivalent: @""]]; - + + if ([type isEqualToString:@"branch"]) + [array addObject:[[PBRefMenuItem alloc] initWithTitle:@"Push branch" + action:@selector(pushRef:) + keyEquivalent: @""]]; + if ([type isEqualToString:@"tag"]) [array addObject:[[PBRefMenuItem alloc] initWithTitle:@"View tag info" action:@selector(tagInfo:)