sync: It the repository is on the wrong branch and shallow, update the config
This commit is contained in:
parent
904ef661ba
commit
0b04185933
@ -326,8 +326,17 @@ func (i GitImporter) IsRepositoryUptodate(repopath string) (*GitSubmoduleStatus,
|
||||
cmdsubmodule = exec.Command("git", "-C", path.Join(i.li.Base, repopath), "show", "-q", "--oneline", "origin/"+i.Branch)
|
||||
stdout, err = cmdsubmodule.CombinedOutput()
|
||||
if err != nil {
|
||||
log.Printf("Git repository submodule status failed: %s\n%s", err, stdout)
|
||||
return nil, fmt.Errorf("%w:\n%s", err, stdout)
|
||||
cmdconfig := exec.Command("git", "-C", path.Join(i.li.Base, repopath), "config", "remote.origin.fetch")
|
||||
if cfg, err2 := cmdconfig.CombinedOutput(); err2 == nil && !strings.Contains(string(cfg), "+refs/heads/*:refs/remotes/origin/*") {
|
||||
cmdsubmodule := exec.Command("git", "-C", path.Join(i.li.Base, repopath), "config", "remote.origin.fetch", "+refs/heads/*:refs/remotes/origin/*")
|
||||
if stdout, err = cmdsubmodule.CombinedOutput(); err != nil {
|
||||
log.Printf("Git repository submodule config failed: %s\n%s", err, stdout)
|
||||
return nil, fmt.Errorf("%w:\n%s", err, stdout)
|
||||
}
|
||||
} else {
|
||||
log.Printf("Git repository submodule status failed: %s\n%s", err, stdout)
|
||||
return nil, fmt.Errorf("%w:\n%s", err, stdout)
|
||||
}
|
||||
}
|
||||
|
||||
flds := strings.SplitN(string(stdout), " ", 2)
|
||||
|
Loading…
x
Reference in New Issue
Block a user