devel-importer: handle cases where remotes or factory branch not main

This commit is contained in:
Adam Majer 2024-09-18 13:51:52 +02:00
parent 530318a35b
commit c955811373

View File

@ -240,13 +240,20 @@ func main() {
}
// check that nothing is broken with the update
out = git.GitExecWithOutputOrPanic(pkgName, "rev-list", "factory")
if slices.Contains(remotes, "factory") {
head_branch := "factory"
out, err = git.GitExecWithOutput(pkgName, "rev-list", head_branch)
if err != nil {
head_branch = "HEAD"
out = git.GitExecWithOutputOrPanic(pkgName, "rev-list", "HEAD")
}
old_revs := strings.Split(out, "\n")
out = git.GitExecWithOutputOrPanic(pkgName, "rev-list", "factory", "^factory/factory")
added_revs := strings.Split(out, "\n")
added_revs := []string{}
out = git.GitExecWithOutputOrPanic(pkgName, "rev-list", head_branch, "^factory/factory")
added_revs = strings.Split(out, "\n")
added_rpm_revs := []string{}
if slices.Contains(remotes, "rpm") {
out = git.GitExecWithOutputOrPanic(pkgName, "rev-list", "factory", "^rpm/factory")
out = git.GitExecWithOutputOrPanic(pkgName, "rev-list", head_branch, "^rpm/factory")
added_rpm_revs = strings.Split(out, "\n")
}
if len(added_revs) == len(old_revs) && len(added_rpm_revs) == len(old_revs) {
@ -254,12 +261,13 @@ func main() {
reposOK = false
}
}
}
args := make([]string, 4, len(develProjectPackages)+4)
args[0] = "-p"
args[1] = prj
args[2] = "-r"
args[4] = git.GitPath
args[3] = git.GitPath
args = append(args, develProjectPackages...)
cmd = exec.Command("./git-importer", args...)
out, err = cmd.CombinedOutput()