Skip to content

Commit be0716a

Browse files
committed
Adding code to do "git svn fetch/rebase/dcommit"
1 parent 042289a commit be0716a

File tree

2 files changed

+47
-5
lines changed

2 files changed

+47
-5
lines changed

PBGitRepository.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) {
7070
- (BOOL) deleteRef:(PBGitRef *)ref;
7171

7272
- (BOOL) hasSvnRemote;
73+
- (NSArray*) svnRemotes;
7374
- (BOOL) svnFetch:(NSString*)remoteName;
7475
- (BOOL) svnRebase:(NSString*)remoteName;
7576
- (BOOL) svnDcommit:(NSString*)commitURL;

PBGitRepository.m

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -891,13 +891,30 @@ - (BOOL) deleteRef:(PBGitRef *)ref
891891
determines if the current repository has a git-svn configured remote
892892
*/
893893
- (BOOL) hasSvnRemote
894+
{
895+
NSArray* remotes = [self svnRemotes];
896+
return remotes && [remotes count] > 0;
897+
}
898+
899+
/**
900+
get a list of the svn remotes configured on this repository
901+
*/
902+
- (NSArray*) svnRemotes
894903
{
895904
NSDictionary* configValues = [config listConfigValuesInDir:[self workingDirectory]];
905+
NSMutableArray* remotes = [NSMutableArray array];
896906

897907
for (NSString* key in configValues) {
898-
if ([key hasPrefix:@"svn-remote."]) return YES;
908+
NSArray* components = [key componentsSeparatedByString:@"."];
909+
if ([components count] == 3 &&
910+
[[components objectAtIndex:0] isEqualToString:@"svn-remote"] &&
911+
[[components objectAtIndex:2] isEqualToString:@"url"]) {
912+
913+
NSString* remoteName = [components objectAtIndex:1];
914+
[remotes addObject:remoteName];
915+
}
899916
}
900-
return NO;
917+
return [NSArray arrayWithArray:remotes];
901918
}
902919

903920
/**
@@ -907,7 +924,15 @@ - (BOOL) hasSvnRemote
907924
*/
908925
- (BOOL) svnFetch:(NSString*)remoteName
909926
{
910-
return YES;
927+
int retval = 1;
928+
NSArray* args = [NSArray arrayWithObjects:@"svn", @"fetch", remoteName, nil];
929+
930+
NSString *description = [NSString stringWithFormat:@"Fetching all tracking branches from %@", remoteName ? remoteName : @"<default>"];
931+
NSString *title = @"Fetching from svn remote";
932+
[PBRemoteProgressSheet beginRemoteProgressSheetForArguments:args title:title description:description inRepository:self];
933+
retval = 0;
934+
935+
return retval == 0;
911936
}
912937

913938
/**
@@ -917,7 +942,15 @@ - (BOOL) svnFetch:(NSString*)remoteName
917942
*/
918943
- (BOOL) svnRebase:(NSString*)remoteName
919944
{
920-
return YES;
945+
int retval = 1;
946+
NSArray* args = [NSArray arrayWithObjects:@"svn", @"rebase", remoteName, nil];
947+
948+
NSString *description = [NSString stringWithFormat:@"Rebasing all tracking branches from %@", remoteName ? remoteName : @"<default>"];
949+
NSString *title = @"Pulling from svn remote (Rebase)";
950+
[PBRemoteProgressSheet beginRemoteProgressSheetForArguments:args title:title description:description inRepository:self];
951+
retval = 0;
952+
953+
return retval == 0;
921954
}
922955

923956
/**
@@ -927,7 +960,15 @@ - (BOOL) svnRebase:(NSString*)remoteName
927960
*/
928961
- (BOOL) svnDcommit:(NSString*)commitURL
929962
{
930-
return YES;
963+
int retval = 1;
964+
NSArray* args = [NSArray arrayWithObjects:@"svn", @"dcommit", commitURL, nil];
965+
966+
NSString *description = [NSString stringWithFormat:@"Pushing commits to svn remote %@", commitURL ? commitURL : @"<default>"];
967+
NSString *title = @"Pushing to svn remote (Dcommit)";
968+
[PBRemoteProgressSheet beginRemoteProgressSheetForArguments:args title:title description:description inRepository:self];
969+
retval = 0;
970+
971+
return retval == 0;
931972
}
932973

933974
#pragma mark GitX Scripting

0 commit comments

Comments
 (0)