@@ -367,6 +367,7 @@ func (executor *Executor) CloneRepository(env map[string]string) bool {
367
367
branch := env ["CIRRUS_BRANCH" ]
368
368
pr_number , is_pr := env ["CIRRUS_PR" ]
369
369
tag , is_tag := env ["CIRRUS_TAG" ]
370
+ _ , is_clone_modules := env ["CIRRUS_CLONE_SUBMODULES" ]
370
371
371
372
clone_url := env ["CIRRUS_REPO_CLONE_URL" ]
372
373
if _ , has_clone_token := env ["CIRRUS_REPO_CLONE_TOKEN" ]; has_clone_token {
@@ -498,6 +499,32 @@ func (executor *Executor) CloneRepository(env map[string]string) bool {
498
499
return false
499
500
}
500
501
502
+ if is_clone_modules {
503
+ logUploader .Write ([]byte ("\n Updating submodules..." ))
504
+
505
+ workTree , err := repo .Worktree ()
506
+ if err != nil {
507
+ logUploader .Write ([]byte (fmt .Sprintf ("\n Failed to get work tree: %s!" , err )))
508
+ return false
509
+ }
510
+
511
+ submodules , err := workTree .Submodules ()
512
+ if err != nil {
513
+ logUploader .Write ([]byte (fmt .Sprintf ("\n Failed to get submodules: %s!" , err )))
514
+ return false
515
+ }
516
+
517
+ if err := submodules .Update (& git.SubmoduleUpdateOptions {
518
+ Init : true ,
519
+ RecurseSubmodules : git .DefaultSubmoduleRecursionDepth ,
520
+ }); err != nil {
521
+ logUploader .Write ([]byte (fmt .Sprintf ("\n Failed to update submodules: %s!" , err )))
522
+ return false
523
+ }
524
+
525
+ logUploader .Write ([]byte ("\n Sucessfully updated submodules!" ))
526
+ }
527
+
501
528
if ref .Hash () != plumbing .NewHash (change ) {
502
529
logUploader .Write ([]byte (fmt .Sprintf ("\n HEAD is at %s." , ref .Hash ())))
503
530
logUploader .Write ([]byte (fmt .Sprintf ("\n Hard resetting to %s..." , change )))
0 commit comments