@@ -19,27 +19,30 @@ + (NSArray *) commandsForSubmodule:(PBGitSubmodule *) submodule inRepository:(PB
19
19
NSString *repoPath = [repository workingDirectory ];
20
20
NSString *path = [repoPath stringByAppendingPathComponent: [submodule path ]];
21
21
22
- // open
23
- PBOpenDocumentCommand *command = [[PBOpenDocumentCommand alloc ] initWithDocumentAbsolutePath: path];
24
- command.commandTitle = command.displayName ;
25
- command.commandDescription = @" Opening document" ;
26
- command.canBeFired = ([submodule path ] && [submodule submoduleState ] != PBGitSubmoduleStateNotInitialized);
27
- [commands addObject: command];
22
+ if ([submodule submoduleState ] != PBGitSubmoduleStateNotInitialized) {
23
+ // open
24
+ PBOpenDocumentCommand *command = [[PBOpenDocumentCommand alloc ] initWithDocumentAbsolutePath: path];
25
+ command.commandTitle = command.displayName ;
26
+ command.commandDescription = @" Opening document" ;
27
+ [commands addObject: command];
28
+ }
28
29
29
30
// update
30
31
NSString *submodulePath = [submodule path ];
31
- NSArray *params = [NSArray arrayWithObjects: @" submodule" , @" update" , nil ];
32
- PBCommand *updateCmd = [[PBCommand alloc ] initWithDisplayName: @" Update submodule " parameters: params repository: repository];
32
+ NSArray *params = [NSArray arrayWithObjects: @" submodule" , @" update" , submodulePath, nil ];
33
+ PBCommand *updateCmd = [[PBCommand alloc ] initWithDisplayName: @" Update" parameters: params repository: repository];
33
34
updateCmd.commandTitle = updateCmd.displayName ;
34
- updateCmd.commandDescription = @" Updating submodule" ;
35
+ updateCmd.commandDescription = [ NSString stringWithFormat: @" Updating submodule %@ " , submodulePath] ;
35
36
[commands addObject: updateCmd];
36
37
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];
38
+ if ([[submodule submodules ] count ] > 0 ) {
39
+ // update recursively
40
+ NSArray *recursiveUpdate = [NSArray arrayWithObjects: @" submodule" , @" update" , @" --recursive" , submodulePath, nil ];
41
+ PBCommand *updateRecursively = [[PBCommand alloc ] initWithDisplayName: @" Update recursively" parameters: recursiveUpdate repository: repository];
42
+ updateRecursively.commandTitle = updateRecursively.displayName ;
43
+ updateRecursively.commandDescription = [NSString stringWithFormat: @" Updating submodule %@ (recursively)" , submodulePath];
44
+ [commands addObject: updateRecursively];
45
+ }
43
46
44
47
return commands;
45
48
}
0 commit comments