diff options
| author | Liz Prucka <lizprucka@google.com> | 2022-08-08 17:52:00 +0000 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2022-08-11 09:51:10 +0200 |
| commit | 787ed7e0bfb3cf1da3025aff0c7770717a993667 (patch) | |
| tree | bc6a3c9d63c323c4da897167d4db5220e07db064 /pkg/vcs/git.go | |
| parent | a6201f1167d158d5a0538c3d29bc3b2bebb0a4fd (diff) | |
pkg/vcs/git.go: fixed error in initializing submodules
Adding a remote origin if one has not been initialized.
Diffstat (limited to 'pkg/vcs/git.go')
| -rw-r--r-- | pkg/vcs/git.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/pkg/vcs/git.go b/pkg/vcs/git.go index 63901b850..f6f6ee276 100644 --- a/pkg/vcs/git.go +++ b/pkg/vcs/git.go @@ -103,7 +103,12 @@ func (git *git) CheckoutBranch(repo, branch string) (*Commit, error) { return nil, err } repoHash := hash.String([]byte(repo)) - // Ignore error as we can double add the same remote and that will fail. + // Because the HEAD is detached, submodules assumes "origin" to be the default + // remote when initializing. + // This sets "origin" to be the current remote. + // Ignore errors as we can double add or remove the same remote and that will fail. + git.git("remote", "rm", "origin") + git.git("remote", "add", "origin", repo) git.git("remote", "add", repoHash, repo) _, err := git.git("fetch", "--force", repoHash, branch) if err != nil { |
