Skip to content

Commit 779f153

Browse files
authored
Merge pull request #5353 from charles-chenzz/git_submodule
git submodule need origin
2 parents 852739c + 60d7ee6 commit 779f153

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

api/internal/git/cloner.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,16 @@ func ClonerUsingGitExec(repoSpec *RepoSpec) error {
2222
if err = r.run("init"); err != nil {
2323
return err
2424
}
25+
// git relative submodule need origin, see https://github.com/kubernetes-sigs/kustomize/issues/5131
26+
if err = r.run("remote", "add", "origin", repoSpec.CloneSpec()); err != nil {
27+
return err
28+
}
2529
ref := "HEAD"
2630
if repoSpec.Ref != "" {
2731
ref = repoSpec.Ref
2832
}
33+
// we use repoSpec.CloneSpec() instead of origin because on error,
34+
// the prior prints the actual repo url for the user.
2935
if err = r.run("fetch", "--depth=1", repoSpec.CloneSpec(), ref); err != nil {
3036
return err
3137
}

api/krusty/remoteloader_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ resources:
205205
resources:
206206
- file://$ROOT/with-submodule.git/submodule?ref=relative-submodule
207207
`,
208-
// TODO(annasong): Replace with simpleBuild once #5131 is fixed.
209-
err: `failed to run '\S+/git submodule update --init --recursive'`,
208+
209+
expected: simpleBuild,
210210
},
211211
{
212212
name: "has timeout",

0 commit comments

Comments
 (0)