Skip to content

Commit d9193b8

Browse files
submodule update depth made configurable (#161)
* Update dependencies * New input created and wired in * Append --depth only if greater than 0 * Tests updated * step.yml updated
1 parent 0cfb786 commit d9193b8

File tree

353 files changed

+23196
-14064
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

353 files changed

+23196
-14064
lines changed

gitclone/gitclone.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package gitclone
22

33
import (
44
"fmt"
5-
65
"github.com/bitrise-io/envman/envman"
76
"github.com/bitrise-io/go-steputils/tools"
87
"github.com/bitrise-io/go-utils/command/git"
@@ -23,12 +22,12 @@ type Config struct {
2322
PRMergeBranch string `env:"pull_request_merge_branch"`
2423
PRHeadBranch string `env:"pull_request_head_branch"`
2524

26-
ResetRepository bool `env:"reset_repository,opt[Yes,No]"`
27-
CloneDepth int `env:"clone_depth"`
28-
FetchTags bool `env:"fetch_tags,opt[yes,no]"`
29-
LimitSubmoduleUpdateDepth bool `env:"limit_submodule_update_depth,opt[yes,no]"`
30-
ShouldMergePR bool `env:"merge_pr,opt[yes,no]"`
31-
SparseDirectories []string `env:"sparse_directories,multiline"`
25+
ResetRepository bool `env:"reset_repository,opt[Yes,No]"`
26+
CloneDepth int `env:"clone_depth"`
27+
FetchTags bool `env:"fetch_tags,opt[yes,no]"`
28+
SubmoduleUpdateDepth int `env:"submodule_update_depth"`
29+
ShouldMergePR bool `env:"merge_pr,opt[yes,no]"`
30+
SparseDirectories []string `env:"sparse_directories,multiline"`
3231

3332
BuildURL string `env:"build_url"`
3433
BuildAPIToken string `env:"build_api_token"`
@@ -93,7 +92,14 @@ func checkoutState(gitCmd git.Git, cfg Config, patch patchSource) error {
9392
}
9493

9594
func updateSubmodules(gitCmd git.Git, cfg Config) error {
96-
if err := runner.Run(gitCmd.SubmoduleUpdate(cfg.LimitSubmoduleUpdateDepth, jobsFlag)); err != nil {
95+
var opts []string
96+
opts = append(opts, jobsFlag)
97+
98+
if cfg.SubmoduleUpdateDepth > 0 {
99+
opts = append(opts, fmt.Sprintf("--depth=%d", cfg.SubmoduleUpdateDepth))
100+
}
101+
102+
if err := runner.Run(gitCmd.SubmoduleUpdate(opts...)); err != nil {
97103
return newStepError(
98104
updateSubmodelFailedTag,
99105
fmt.Errorf("submodule update: %v", err),

gitclone/gitclone_test.go

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -648,19 +648,35 @@ var submoduleTestCases = [...]struct {
648648
wantCmds []string
649649
}{
650650
{
651-
name: "Limiting submodule depth",
652-
cfg: Config{
653-
LimitSubmoduleUpdateDepth: true,
654-
},
651+
name: "Given submodule update depth is 1 when the submodules are updated then expect the --depth=1 flag on the command",
652+
cfg: Config{SubmoduleUpdateDepth: 1},
655653
wantCmds: []string{
656654
`git "submodule" "update" "--init" "--recursive" "--jobs=10" "--depth=1"`,
657655
},
658656
},
659657
{
660-
name: "Not limiting submodule depth",
661-
cfg: Config{
662-
LimitSubmoduleUpdateDepth: false,
658+
name: "Given submodule update depth is 10 when the submodules are updated then expect the --depth=10 flag on the command",
659+
cfg: Config{SubmoduleUpdateDepth: 10},
660+
wantCmds: []string{
661+
`git "submodule" "update" "--init" "--recursive" "--jobs=10" "--depth=10"`,
662+
},
663+
},
664+
{
665+
name: "Given no submodule update depth is provided when the submodules are updated then expect the --depth flag missing from the command",
666+
wantCmds: []string{
667+
`git "submodule" "update" "--init" "--recursive" "--jobs=10"`,
668+
},
669+
},
670+
{
671+
name: "Given submodule update depth is 0 when the submodules are updated then expect the --depth flag missing from the command",
672+
cfg: Config{SubmoduleUpdateDepth: 0},
673+
wantCmds: []string{
674+
`git "submodule" "update" "--init" "--recursive" "--jobs=10"`,
663675
},
676+
},
677+
{
678+
name: "Given submodule update depth is -1 when the submodules are updated then expect the --depth flag missing from the command",
679+
cfg: Config{SubmoduleUpdateDepth: -1},
664680
wantCmds: []string{
665681
`git "submodule" "update" "--init" "--recursive" "--jobs=10"`,
666682
},

go.mod

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@ require (
66
github.com/bitrise-io/bitrise-init v0.0.0-20201117094539-a984f01dd477
77
github.com/bitrise-io/envman v0.0.0-20200512105748-919e33f391ee
88
github.com/bitrise-io/go-steputils v0.0.0-20210324082442-21a1b8f2b237
9-
github.com/bitrise-io/go-utils v0.0.0-20210505130606-6269c7fd64f3
9+
github.com/bitrise-io/go-utils v0.0.0-20210517140706-aa64fd88ca49
1010
github.com/bitrise-io/goinp v0.0.0-20190611131639-bd18a8681e27 // indirect
1111
github.com/bitrise-steplib/bitrise-step-export-universal-apk v0.0.0-20200729103519-a582681d23d6
12-
github.com/stretchr/testify v1.6.1
13-
golang.org/x/crypto v0.0.0-20201116153603-4be66e5b6582 // indirect
14-
golang.org/x/sys v0.0.0-20201116194326-cc9327a14d48 // indirect
15-
gopkg.in/yaml.v2 v2.3.0 // indirect
12+
github.com/stretchr/testify v1.7.0
1613
)

go.sum

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,63 @@ github.com/bitrise-io/go-steputils v0.0.0-20210324082442-21a1b8f2b237/go.mod h1:
77
github.com/bitrise-io/go-utils v0.0.0-20200629150542-0c47c16813a4/go.mod h1:tTEsKvbz1LbzuN/KpVFHXnLtcAPdEgIdM41s0lL407s=
88
github.com/bitrise-io/go-utils v0.0.0-20210505130606-6269c7fd64f3 h1:3FuE7AhshWPDc/jJ37+AE6UFBhIQM7cGjf86nS6+uaU=
99
github.com/bitrise-io/go-utils v0.0.0-20210505130606-6269c7fd64f3/go.mod h1:nhdaDQFvaMny1CugVV6KjK92/q97ENo0RuKSW5I4fbA=
10+
github.com/bitrise-io/go-utils v0.0.0-20210517140706-aa64fd88ca49 h1:du0kI1TU7cv/Hr8U3plyAlMtyOf2kUj4CA4ku5bz20Y=
11+
github.com/bitrise-io/go-utils v0.0.0-20210517140706-aa64fd88ca49/go.mod h1:DRx7oFuAqk0dbKpAKCqWl0TgrowfJUb/MqYPRscxJOQ=
1012
github.com/bitrise-io/goinp v0.0.0-20190611131639-bd18a8681e27 h1:NuGIfwKcZvdR1RT4sQ32kE8h35w9XQjQrrCJPJqS4ek=
1113
github.com/bitrise-io/goinp v0.0.0-20190611131639-bd18a8681e27/go.mod h1:G0M1sK06a1l0KAg4rQei7q5dDKC/JrZoaXFqak91osU=
1214
github.com/bitrise-steplib/bitrise-step-export-universal-apk v0.0.0-20200729103519-a582681d23d6 h1:7UWHsApY8/iIGw1jVbDiL3FMnI70Y/t0BxG9nQupHhI=
1315
github.com/bitrise-steplib/bitrise-step-export-universal-apk v0.0.0-20200729103519-a582681d23d6/go.mod h1:WBGpmu+FXynGkpED0re/InExsBaRG7Y2tMabxnFgSuA=
1416
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1517
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
1618
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
19+
github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM=
20+
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
21+
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
22+
github.com/hashicorp/go-retryablehttp v0.6.6 h1:HJunrbHTDDbBb/ay4kxa1n+dLmttUlnP3V9oNE4hmsM=
23+
github.com/hashicorp/go-retryablehttp v0.6.6/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY=
1724
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
1825
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1926
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
2027
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
2128
github.com/stretchr/objx v0.3.0 h1:NGXK3lHquSN08v5vWalVI/L8XU9hdzE/G6xsrze47As=
2229
github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
30+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
2331
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
2432
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
2533
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
2634
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
35+
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
36+
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
2737
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
2838
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
2939
golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
3040
golang.org/x/crypto v0.0.0-20201116153603-4be66e5b6582 h1:0WDrJ1E7UolDk1KhTXxxw3Fc8qtk5x7dHP431KHEJls=
3141
golang.org/x/crypto v0.0.0-20201116153603-4be66e5b6582/go.mod h1:tCqSYrHVcf3i63Co2FzBkTCo2gdF6Zak62921dSfraU=
42+
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a h1:kr2P4QFmQr29mSLA43kwrOcgcReGTfbE9N577tCTuBc=
43+
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
3244
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
3345
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
3446
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
3547
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
48+
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
3649
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
3750
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
3851
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
3952
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
4053
golang.org/x/sys v0.0.0-20200219091948-cb0a6d8edb6c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
4154
golang.org/x/sys v0.0.0-20201116194326-cc9327a14d48 h1:AYCWBZhgIw6XobZ5CibNJr0Rc4ZofGGKvWa1vcx2IGk=
4255
golang.org/x/sys v0.0.0-20201116194326-cc9327a14d48/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
56+
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
57+
golang.org/x/sys v0.0.0-20210511113859-b0526f3d8744 h1:yhBbb4IRs2HS9PPlAg6DMC6mUOKexJBNsLf4Z+6En1Q=
58+
golang.org/x/sys v0.0.0-20210511113859-b0526f3d8744/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
4359
golang.org/x/term v0.0.0-20201113234701-d7a72108b828 h1:htWEtQEuEVJ4tU/Ngx7Cd/4Q7e3A5Up1owgyBtVsTwk=
4460
golang.org/x/term v0.0.0-20201113234701-d7a72108b828/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
61+
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
62+
golang.org/x/term v0.0.0-20210503060354-a79de5458b56 h1:b8jxX3zqjpqb2LklXPzKSGJhzyxCOZSz8ncv8Nv+y7w=
63+
golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY=
4564
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
65+
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
66+
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
4667
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
4768
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
4869
golang.org/x/tools v0.0.0-20200220224806-8a925fa4c0df/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
@@ -53,6 +74,10 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
5374
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
5475
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
5576
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
77+
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
78+
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
5679
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
5780
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ=
5881
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
82+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
83+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

step.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,13 @@ inputs:
112112
description: |-
113113
Limit fetching to the specified number of commits.
114114
The value should be a decimal number, for example `10`.
115-
- limit_submodule_update_depth: "yes"
115+
- submodule_update_depth:
116116
opts:
117117
category: "Checkout options"
118-
title: "Shallow update submodules"
119-
summary: "Should submodules be shallow cloned with a history truncated to the latest revisions."
120-
value_options:
121-
- "yes"
122-
- "no"
118+
title: "Submodule update depth"
119+
description: |-
120+
Truncate the history to the specified number of revisions.
121+
The value should be a decimal number, for example `10`.
123122
- merge_pr: "yes"
124123
opts:
125124
category: "Checkout options"

vendor/github.com/bitrise-io/go-utils/command/git/commands.go

Lines changed: 1 addition & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/bitrise-io/go-utils/pathutil/path_filter.go

Lines changed: 143 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/bitrise-io/go-utils/pathutil/pathutil.go

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)