This commit is contained in:
Adam Majer 2024-09-29 23:11:51 +02:00
parent 4692cfbe6f
commit 7234811edc

View File

@ -248,6 +248,7 @@ func verifyProjectState(git *common.GitHandler, orgName string, config *common.A
nextSubmodule:
for sub, commitID := range submodules {
log.Println(" + checking", sub, commitID)
submoduleName := sub
if n := strings.LastIndex(sub, "/"); n != -1 {
submoduleName = sub[n+1:]
@ -268,6 +269,18 @@ nextSubmodule:
}
// not found in past, check if we should advance the branch label ... pull the submodule
git.GitExecOrPanic(config.GitProjectName, "submodule", "update", "--init", "--filter", "blob:none", "--", sub)
subDir := path.Join(config.GitProjectName, sub)
newCommits := git.GitExecWithOutputOrPanic(subDir, "rev-list", "^origin/"+config.Branch, commitID)
if len(common.SplitStringNoEmpty(newCommits, "\n")) >= 1 {
sshUrl, err := git.translateHttpsToSshUrl(git.SubmoduleUrl(config.GitProjectName), sub)
if err != nil {
return fmt.Errorf("Cannot traslate HTTPS git URL to SSH_URL. %w", err)
}
git.GitExecOrPanic(subDir, "checkout", "-B", config.Branch, commitID)
git.GitExecOrPanic(subDir, "remote", "add", "update", sshUrl)
git.GitExecOrPanic(subDir, "push", "update", config.Branch)
}
}
// forward any package-gits referred by the project git, but don't go back
@ -289,7 +302,9 @@ func checkRepos() {
log.Println("Faield to allocate GitHandler:", err)
return
}
if !DebugMode {
defer git.Close()
}
if err := verifyProjectState(git, org, config, configs); err != nil {
log.Printf(" *** verification failed, org: `%s`, err: %#v\n", org, err)
}