Skip to content

Commit 12d4008

Browse files
author
Robert Kyriakis
committed
After cloneTo is asked, if user want to create a new Remote to the clone
1 parent 0f3cc69 commit 12d4008

14 files changed

+81
-23
lines changed

ApplicationController.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,7 @@ - (void)applicationWillTerminate:(NSNotification *)aNotification
402402
}
403403
}
404404

405-
[self removeObserver:self forKeyPath:@"ErrorMessageDidEnd"];
406-
[self removeObserver:self forKeyPath:@"GitCommandSent"];
405+
[[NSNotificationCenter defaultCenter] removeObserver:self];
407406
}
408407

409408
/**

Controller/GlobalProtocols.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// GlobalProtocols.h
3+
// GitX
4+
//
5+
// Created by Robert Kyriakis on 08.01.12.
6+
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
@protocol Messages
12+
@required
13+
- (void)showMessageSheet:(NSString *)messageText infoText:(NSString *)infoText;
14+
- (void)showErrorSheet:(NSError *)error;
15+
@end

GitX.xcodeproj/project.pbxproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@
8282
65D58BC7132D48C2003F7290 /* PBResetSheet.m in Sources */ = {isa = PBXBuildFile; fileRef = 65D58BC6132D48C0003F7290 /* PBResetSheet.m */; };
8383
770B37ED0679A11B001EADE2 /* GitTest_DataModel.xcdatamodel in Sources */ = {isa = PBXBuildFile; fileRef = 770B37EC0679A11B001EADE2 /* GitTest_DataModel.xcdatamodel */; };
8484
77C8280E06725ACE000B614F /* ApplicationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77C8280C06725ACE000B614F /* ApplicationController.m */; };
85-
812F400914ACF14E0032373A /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29B97324FDCFA39411CA2CEA /* AppKit.framework */; };
8685
812BDD8B14AA0B110072748D /* PBChangeRemoteUrlSheet.xib in Resources */ = {isa = PBXBuildFile; fileRef = 812BDD8914AA0B110072748D /* PBChangeRemoteUrlSheet.xib */; };
8786
812BDD8F14AA0E9C0072748D /* PBChangeRemoteUrlSheet.m in Sources */ = {isa = PBXBuildFile; fileRef = 812BDD8E14AA0E9C0072748D /* PBChangeRemoteUrlSheet.m */; };
87+
812F400914ACF14E0032373A /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29B97324FDCFA39411CA2CEA /* AppKit.framework */; };
8888
8166B9CF149E1BC0007C8619 /* PBRenameSheet.m in Sources */ = {isa = PBXBuildFile; fileRef = 8166B9CE149E1BC0007C8619 /* PBRenameSheet.m */; };
8989
81840633149E1AA00014646A /* PBRenameSheet.xib in Resources */ = {isa = PBXBuildFile; fileRef = 81840631149E1AA00014646A /* PBRenameSheet.xib */; };
9090
89087CA613A3E46B00911503 /* PBWebCommitController.m in Sources */ = {isa = PBXBuildFile; fileRef = 89087CA513A3E46B00911503 /* PBWebCommitController.m */; };
@@ -348,6 +348,7 @@
348348
812BDD8A14AA0B110072748D /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/PBChangeRemoteUrlSheet.xib; sourceTree = "<group>"; };
349349
812BDD8D14AA0E9C0072748D /* PBChangeRemoteUrlSheet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBChangeRemoteUrlSheet.h; sourceTree = "<group>"; };
350350
812BDD8E14AA0E9C0072748D /* PBChangeRemoteUrlSheet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBChangeRemoteUrlSheet.m; sourceTree = "<group>"; };
351+
81401EB114B9DE12003683C1 /* GlobalProtocols.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GlobalProtocols.h; path = Controller/GlobalProtocols.h; sourceTree = "<group>"; };
351352
8166B9CD149E1BC0007C8619 /* PBRenameSheet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBRenameSheet.h; sourceTree = "<group>"; };
352353
8166B9CE149E1BC0007C8619 /* PBRenameSheet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBRenameSheet.m; sourceTree = "<group>"; };
353354
81840632149E1AA00014646A /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/PBRenameSheet.xib; sourceTree = "<group>"; };
@@ -980,6 +981,7 @@
980981
F5E927F90E883EF600056E75 /* Commit */,
981982
D82F435F111B9C6D00A25A39 /* Sheets */,
982983
8998B1AB13A55A9B00121729 /* Stash */,
984+
81401EB114B9DE12003683C1 /* GlobalProtocols.h */,
983985
77C8280B06725ACE000B614F /* ApplicationController.h */,
984986
77C8280C06725ACE000B614F /* ApplicationController.m */,
985987
93CB42C00EAB7B2200530609 /* PBGitDefaults.h */,

PBAddRemoteSheet.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020

2121
NSOpenPanel *browseSheet;
2222
NSView *browseAccessoryView;
23+
24+
NSString *remoteUrl;
2325
}
2426

25-
+ (void) beginAddRemoteSheetForRepository:(PBGitRepository *)repo;
27+
+ (void) beginAddRemoteSheetForRepository:(PBGitRepository *)repo withRemoteURL:(NSString*)url;
2628

2729
- (IBAction) browseFolders:(id)sender;
2830
- (IBAction) addRemote:(id)sender;

PBAddRemoteSheet.m

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
@interface PBAddRemoteSheet ()
1616

17-
- (void) beginAddRemoteSheetForRepository:(PBGitRepository *)repo;
17+
- (void) beginAddRemoteSheetForRepository:(PBGitRepository *)repo withRemoteURL:(NSString*)url;
1818
- (void) openAddRemoteSheet;
1919

2020
@end
@@ -37,18 +37,19 @@ @implementation PBAddRemoteSheet
3737
#pragma mark -
3838
#pragma mark PBAddRemoteSheet
3939

40-
+ (void) beginAddRemoteSheetForRepository:(PBGitRepository *)repo
40+
+ (void) beginAddRemoteSheetForRepository:(PBGitRepository *)repo withRemoteURL:(NSString*)url;
4141
{
4242
if(!sheet){
4343
sheet = [[self alloc] initWithWindowNibName:@"PBAddRemoteSheet"];
4444
}
45-
[sheet beginAddRemoteSheetForRepository:repo];
45+
[sheet beginAddRemoteSheetForRepository:repo withRemoteURL:url];
4646
}
4747

4848

49-
- (void) beginAddRemoteSheetForRepository:(PBGitRepository *)repo
49+
- (void) beginAddRemoteSheetForRepository:(PBGitRepository *)repo withRemoteURL:(NSString*)url
5050
{
5151
self.repository = repo;
52+
remoteUrl = url;
5253

5354
[self window];
5455
[self openAddRemoteSheet];
@@ -58,6 +59,12 @@ - (void) beginAddRemoteSheetForRepository:(PBGitRepository *)repo
5859
- (void) openAddRemoteSheet
5960
{
6061
[self.errorMessage setStringValue:@""];
62+
63+
if (remoteUrl)
64+
{
65+
[remoteURL setStringValue:remoteUrl];
66+
[remoteURL setEnabled:NO];
67+
}
6168

6269
[NSApp beginSheet:[self window] modalForWindow:[self.repository.windowController window] modalDelegate:self didEndSelector:nil contextInfo:NULL];
6370
}
@@ -100,7 +107,7 @@ - (IBAction) addRemote:(id)sender
100107
{
101108
[self.errorMessage setStringValue:@""];
102109

103-
NSString *name = [[self.remoteName stringValue] copy];
110+
NSString *name = [self.remoteName stringValue];
104111

105112
if ([name isEqualToString:@""]) {
106113
[self.errorMessage setStringValue:@"Remote name is required"];
@@ -112,7 +119,7 @@ - (IBAction) addRemote:(id)sender
112119
return;
113120
}
114121

115-
NSString *url = [[self.remoteURL stringValue] copy];
122+
NSString *url = [self.remoteURL stringValue];
116123
if ([url isEqualToString:@""]) {
117124
[self.errorMessage setStringValue:@"Remote URL is required"];
118125
return;

PBCloneRepositoryPanel.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
//
88

99
#import <Cocoa/Cocoa.h>
10+
#import "GlobalProtocols.h"
1011

1112

12-
@interface PBCloneRepositoryPanel : NSWindowController {
13+
@interface PBCloneRepositoryPanel : NSWindowController <Messages> {
1314
NSTextField *repositoryURL;
1415
NSTextField *destinationPath;
1516
NSTextField *errorMessage;

PBGitHistoryController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ - (IBAction) createTag:(id)sender
695695

696696
- (IBAction) showAddRemoteSheet:(id)sender
697697
{
698-
[PBAddRemoteSheet beginAddRemoteSheetForRepository:self.repository];
698+
[PBAddRemoteSheet beginAddRemoteSheetForRepository:self.repository withRemoteURL:Nil];
699699
}
700700

701701
- (IBAction) merge:(id)sender

PBGitRepository.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,9 @@ - (void) cloneRepositoryToPath:(NSString *)path bare:(BOOL)isBare
935935
NSString *description = [NSString stringWithFormat:@"Cloning the repository %@ to %@", [self projectName], path];
936936
NSString *title = @"Cloning Repository";
937937
[PBRemoteProgressSheet beginRemoteProgressSheetForArguments:arguments title:title description:description inRepository:self];
938+
939+
NSDictionary *userInfoDict = [NSDictionary dictionaryWithObject:path forKey:@"CloneToPath"];
940+
[[NSNotificationCenter defaultCenter] postNotificationName:@"CloneToOperationInProgress" object:self userInfo:userInfoDict];
938941
}
939942

940943
- (void) beginAddRemote:(NSString *)remoteName forURL:(NSString *)remoteURL

PBGitSidebarController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ - (IBAction) fetchPullPushAction:(id)sender
575575
NSInteger selectedSegment = [sender selectedSegment];
576576

577577
if (selectedSegment == kAddRemoteSegment) {
578-
[PBAddRemoteSheet beginAddRemoteSheetForRepository:repository];
578+
[PBAddRemoteSheet beginAddRemoteSheetForRepository:repository withRemoteURL:Nil];
579579
return;
580580
}
581581

PBGitWindowController.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88

99
#import <Cocoa/Cocoa.h>
1010
#import "PBGitRepository.h"
11+
#import "GlobalProtocols.h"
1112

1213
#define kGitSplitViewMinWidth 150.0f
1314
#define kGitSplitViewMaxWidth 300.0f
1415

1516
@class PBViewController, PBGitSidebarController, PBGitCommitController;
1617

1718
// Controls the main repository window from RepositoryWindow.xib
18-
@interface PBGitWindowController : NSWindowController PROTOCOL_10_6(NSWindowDelegate){
19+
@interface PBGitWindowController : NSWindowController PROTOCOL_10_6(NSWindowDelegate,Messages){
1920

2021
PBViewController *contentController;
2122

@@ -33,6 +34,8 @@
3334

3435
NSArray *splitViews;
3536
NSMutableArray *splitViewsSize;
37+
BOOL addRemoteAfterCloneTo;
38+
NSString *remoteURL;
3639
}
3740

3841
@property (strong) PBGitRepository *repository;

0 commit comments

Comments
 (0)