Skip to content

Commit 43adbe4

Browse files
author
Robert Kyriakis
committed
changeRemoteURL changed on Parameter PBGitRef
1 parent 21bb70a commit 43adbe4

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

PBChangeRemoteUrlSheet.m

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
#import "PBChangeRemoteUrlSheet.h"
1010
#import "PBGitWindowController.h"
11-
//#import "PBRepositoryDocumentController.h"
12-
//#import "PBGitDefaults.h"
1311

1412
@interface PBChangeRemoteUrlSheet ()
1513
- (void)showChangeRemoteUrlSheetAtRefish:(id <PBGitRefish>)ref inRepository:(PBGitRepository *)repo;
@@ -59,9 +57,8 @@ - (IBAction)changeOperation:(id)sender
5957

6058
NSString *currentPath = [RemoteUrlTextField stringValue];
6159
NSURL *newUrl = [NSURL URLWithString:[currentPath stringByAddingPercentEscapesUsingEncoding:NSStringEncodingConversionExternalRepresentation]];
62-
NSString *remoteName = [self.startRefish shortName];
6360

64-
[self.repository changeRemote:remoteName toURL:newUrl];
61+
[self.repository changeRemote:(PBGitRef*)self.startRefish toURL:newUrl];
6562
}
6663
}
6764

PBGitRepository.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ dispatch_queue_t PBGetWorkQueue();
156156
+(bool)isLocalBranch:(NSString *)branch branchNameInto:(NSString **)name;
157157

158158
- (NSString*) remoteUrl:(NSString*)remoteName;
159-
- (void) changeRemote:(NSString*)remoteName toURL:(NSURL*)newUrl;
159+
- (void) changeRemote:(PBGitRef *)ref toURL:(NSURL*)newUrl;
160160

161161

162162
@property (assign) BOOL hasChanged;

PBGitRepository.m

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -793,29 +793,34 @@ - (NSString*) remoteUrl:(NSString*)remoteName
793793
}
794794

795795

796-
- (void) changeRemote:(NSString*)remoteName toURL:(NSURL*)newUrl
796+
- (void) changeRemote:(PBGitRef *)ref toURL:(NSURL*)newUrl;
797797
{
798-
int gitRetValue = 1;
798+
if ((!ref) || (![ref isRemote]))
799+
{
800+
return;
801+
}
802+
803+
int gitRetValue = 1;
799804
NSArray *arguments;
800805
NSString *output;
801806

802807
// remember the current vaild remote URL to set back, if an error occurs
803-
NSString *currentRemoteURL = [self remoteUrl:remoteName];
808+
NSString *currentRemoteURL = [self remoteUrl:[ref remoteName]];
804809

805810
// Change the URL of the remote
806-
arguments = [NSArray arrayWithObjects:@"remote", @"set-url", remoteName, [newUrl path], nil];
811+
arguments = [NSArray arrayWithObjects:@"remote", @"set-url",[ref remoteName], [newUrl path], nil];
807812
output = [self outputInWorkdirForArguments:arguments retValue:&gitRetValue];
808813

809814
// Check if the new URL is valid with fetching it
810-
arguments = [NSArray arrayWithObjects:@"fetch", remoteName, nil];
815+
arguments = [NSArray arrayWithObjects:@"fetch",[ref remoteName], nil];
811816
output = [self outputInWorkdirForArguments:arguments retValue:&gitRetValue];
812817
if (gitRetValue)
813818
{
814-
NSString *message = [NSString stringWithFormat:@"There was an error changing URL from Remote %@ to %@.",remoteName,[newUrl path]];
819+
NSString *message = [NSString stringWithFormat:@"There was an error changing URL from Remote %@ to %@.",[ref remoteName],[newUrl path]];
815820
[self.windowController showErrorSheetTitle:@"URL was not changed!" message:message arguments:arguments output:output];
816821

817822
// Change the URL of the remote back
818-
arguments = [NSArray arrayWithObjects:@"remote", @"set-url", remoteName, currentRemoteURL, nil];
823+
arguments = [NSArray arrayWithObjects:@"remote", @"set-url",[ref remoteName], currentRemoteURL, nil];
819824
output = [self outputInWorkdirForArguments:arguments retValue:&gitRetValue];
820825
}
821826
}

0 commit comments

Comments
 (0)