Skip to content

Commit b948127

Browse files
Added command for initializing submodules
1 parent 81bb83a commit b948127

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Commands/PBRemoteCommandFactory.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ + (NSArray *) commandsForSubmodule:(PBGitSubmodule *) submodule inRepository:(PB
1818

1919
NSString *repoPath = [repository workingDirectory];
2020
NSString *path = [repoPath stringByAppendingPathComponent:[submodule path]];
21+
NSString *submodulePath = [submodule path];
2122

2223
if ([submodule submoduleState] != PBGitSubmoduleStateNotInitialized) {
2324
// open
@@ -27,8 +28,15 @@ + (NSArray *) commandsForSubmodule:(PBGitSubmodule *) submodule inRepository:(PB
2728
[commands addObject:command];
2829
}
2930

31+
if ([submodule submoduleState] == PBGitSubmoduleStateNotInitialized) {
32+
NSArray *params = [NSArray arrayWithObjects:@"submodule", @"init", submodulePath, nil];
33+
PBCommand *initCmd = [[PBCommand alloc] initWithDisplayName:@"Init" parameters:params repository:repository];
34+
initCmd.commandTitle = initCmd.displayName;
35+
initCmd.commandDescription = [NSString stringWithFormat:@"Initializing submodule %@", submodulePath];
36+
[commands addObject:initCmd];
37+
}
38+
3039
// update
31-
NSString *submodulePath = [submodule path];
3240
NSArray *params = [NSArray arrayWithObjects:@"submodule", @"update", submodulePath, nil];
3341
PBCommand *updateCmd = [[PBCommand alloc] initWithDisplayName:@"Update" parameters:params repository:repository];
3442
updateCmd.commandTitle = updateCmd.displayName;

0 commit comments

Comments
 (0)