Skip to content

Commit

Permalink
Merge pull request #5353 from charles-chenzz/git_submodule
Browse files Browse the repository at this point in the history
git submodule need origin
  • Loading branch information
k8s-ci-robot committed Oct 7, 2023
2 parents 852739c + 60d7ee6 commit 779f153
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions api/internal/git/cloner.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ func ClonerUsingGitExec(repoSpec *RepoSpec) error {
if err = r.run("init"); err != nil {
return err
}
// git relative submodule need origin, see https://github.com/kubernetes-sigs/kustomize/issues/5131
if err = r.run("remote", "add", "origin", repoSpec.CloneSpec()); err != nil {
return err
}
ref := "HEAD"
if repoSpec.Ref != "" {
ref = repoSpec.Ref
}
// we use repoSpec.CloneSpec() instead of origin because on error,
// the prior prints the actual repo url for the user.
if err = r.run("fetch", "--depth=1", repoSpec.CloneSpec(), ref); err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions api/krusty/remoteloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ resources:
resources:
- file://$ROOT/with-submodule.git/submodule?ref=relative-submodule
`,
// TODO(annasong): Replace with simpleBuild once #5131 is fixed.
err: `failed to run '\S+/git submodule update --init --recursive'`,

expected: simpleBuild,
},
{
name: "has timeout",
Expand Down

0 comments on commit 779f153

Please sign in to comment.