hashicorp / go-getter

Package for downloading things from a string URL using a variety of protocols.
Mozilla Public License 2.0
1.64k stars 230 forks source link

Submodule Update #500

Open Tynukua opened 1 month ago

Tynukua commented 1 month ago

GitGetter.update fails if repo contains submodule

package main

import (
    "github.com/hashicorp/go-getter"
    "log"
    "os"
)

func main() {
    repoURL := "git@github.com:mayraamaral/submodule-father.git" // repo contains submodule
    destDir := "repo"
    for i := 0; i < 2; i++ {
        err := getter.GetAny(destDir, repoURL) // fails when i == 1
        if err != nil {
            log.Println(err)
        }
    }
}
Tynukua commented 1 month ago

problem caused by rm .git but submodules have own .git modules the solution cud be

  1. recursive removing all submodules, including all directory with files
  2. actually update repo but not removing .git folder f.e. git pull --rebase
  3. stop using update method and instead rm all dir and use clone method again