sync: Use git reset --hard --recurse-submodule
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
nemunaire 2022-01-22 08:10:53 +01:00
parent d4a81aa660
commit 86748b36c8

View File

@ -104,7 +104,7 @@ func (i GitImporter) Sync() error {
}
}
cmdreset := exec.Command("git", "-C", i.li.Base, "reset", "--hard", "origin/master")
cmdreset := exec.Command("git", "-C", i.li.Base, "reset", "--hard", "--recurse-submodule", "origin/master")
stdout, err = cmdreset.CombinedOutput()
if err != nil {
log.Printf("Local git repository reset failed: %s\n%s", err, stdout)
@ -113,20 +113,6 @@ func (i GitImporter) Sync() error {
if _, err := os.Stat(path.Join(i.li.Base, ".gitmodules")); !errors.Is(err, os.ErrNotExist) {
// Treat submodules
cmdsubreset := exec.Command("git", "-C", i.li.Base, "submodule", "foreach", "--recursive", "git", "reset", "--hard")
stdout, err = cmdsubreset.CombinedOutput()
if err != nil {
log.Printf("Local git repository submodule reset failed: %s\n%s", err, stdout)
return fmt.Errorf("%w:\n%s", err, stdout)
}
cmdsubupdate := exec.Command("git", "-C", i.li.Base, "submodule", "update", "--init", "--recursive")
stdout, err = cmdsubupdate.CombinedOutput()
if err != nil {
log.Printf("Local git repository submodule update failed: %s\n%s", err, stdout)
return fmt.Errorf("%w:\n%s", err, stdout)
}
cmdsublfs := exec.Command("git", "-C", i.li.Base, "submodule", "foreach", "--recursive", "git", "lfs", "pull")
stdout, err = cmdsublfs.CombinedOutput()
if err != nil {