@@ -115,6 +115,12 @@ func (sf *CommitSubModuleFile) RefID() string {
115
115
return sf .refID
116
116
}
117
117
118
+ // SubModuleCommit submodule name and commit from a repository
119
+ type SubModuleCommit struct {
120
+ Name string
121
+ Commit string
122
+ }
123
+
118
124
// GetSubmoduleCommits Returns a list of active submodules in the repository
119
125
func GetSubmoduleCommits (ctx context.Context , repoPath string ) []SubModuleCommit {
120
126
stdoutReader , stdoutWriter := io .Pipe ()
@@ -164,8 +170,7 @@ func GetSubmoduleCommits(ctx context.Context, repoPath string) []SubModuleCommit
164
170
}
165
171
166
172
// If no commit was found for the module skip it
167
- commit , _ , err := NewCommand (ctx , "submodule" , "status" , name ).
168
- RunStdString (& RunOpts {Dir : repoPath })
173
+ commit , _ , err := NewCommand (ctx , "submodule" , "status" ).AddDynamicArguments (name ).RunStdString (& RunOpts {Dir : repoPath })
169
174
if err != nil {
170
175
log .Debug ("Submodule %s skipped because it has no commit" , name )
171
176
continue
@@ -198,7 +203,7 @@ func GetSubmoduleCommits(ctx context.Context, repoPath string) []SubModuleCommit
198
203
// AddSubmoduleIndexes Adds the given submodules to the git index. Requires the .gitmodules file to be already present.
199
204
func AddSubmoduleIndexes (ctx context.Context , repoPath string , submodules []SubModuleCommit ) error {
200
205
for _ , submodule := range submodules {
201
- if stdout , _ , err := NewCommand (ctx , "update-index" , "--add" , "--cacheinfo" , "160000" , submodule .Commit , submodule .Name ).
206
+ if stdout , _ , err := NewCommand (ctx , "update-index" , "--add" , "--cacheinfo" , "160000" ). AddDynamicArguments ( submodule .Commit , submodule .Name ).
202
207
RunStdString (& RunOpts {Dir : repoPath }); err != nil {
203
208
log .Error ("Unable to add %s as submodule to repo %s: stdout %s\n Error: %v" , submodule .Name , repoPath , stdout , err )
204
209
return err
0 commit comments