Skip to content

Commit f383103

Browse files
Submodules can be updated/updated recursively
1 parent 7570afe commit f383103

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

Commands/PBRemoteCommandFactory.m

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,30 @@ + (NSArray *) commandsForSubmodule:(PBGitSubmodule *) submodule inRepository:(PB
1717
NSMutableArray *commands = [[NSMutableArray alloc] init];
1818

1919
NSString *repoPath = [repository workingDirectory];
20-
2120
NSString *path = [repoPath stringByAppendingPathComponent:[submodule path]];
2221

22+
// open
2323
PBOpenDocumentCommand *command = [[PBOpenDocumentCommand alloc] initWithDocumentAbsolutePath:path];
2424
command.commandTitle = command.displayName;
2525
command.commandDescription = @"Opening document";
26+
command.canBeFired = ([submodule path] && [submodule submoduleState] != PBGitSubmoduleStateNotInitialized);
2627
[commands addObject:command];
27-
28+
29+
// update
30+
NSString *submodulePath = [submodule path];
31+
NSArray *params = [NSArray arrayWithObjects:@"submodule", @"update", nil];
32+
PBCommand *updateCmd = [[PBCommand alloc] initWithDisplayName:@"Update submodule" parameters:params repository:repository];
33+
updateCmd.commandTitle = updateCmd.displayName;
34+
updateCmd.commandDescription = @"Updating submodule";
35+
[commands addObject:updateCmd];
36+
37+
// update recursively
38+
NSArray *recursiveUpdate = [NSArray arrayWithObjects:@"submodule", @"update", @"--recursive", nil];
39+
PBCommand *updateRecursively = [[PBCommand alloc] initWithDisplayName:@"Update submodule recursively" parameters:recursiveUpdate repository:repository];
40+
updateRecursively.commandTitle = updateRecursively.displayName;
41+
updateRecursively.commandDescription = [NSString stringWithFormat:@"Updating submodule %@ (recursively)", submodulePath];
42+
[commands addObject:updateRecursively];
43+
2844
return commands;
2945
}
3046

0 commit comments

Comments
 (0)