From c9558113733eef88a84843d24a788c3271c49f47097c6da3f47bd06ba816bfec Mon Sep 17 00:00:00 2001 From: Adam Majer Date: Wed, 18 Sep 2024 13:51:52 +0200 Subject: [PATCH] devel-importer: handle cases where remotes or factory branch not main --- devel-importer/main.go | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/devel-importer/main.go b/devel-importer/main.go index af18780..0069012 100644 --- a/devel-importer/main.go +++ b/devel-importer/main.go @@ -240,18 +240,26 @@ func main() { } // check that nothing is broken with the update - out = git.GitExecWithOutputOrPanic(pkgName, "rev-list", "factory") - old_revs := strings.Split(out, "\n") - out = git.GitExecWithOutputOrPanic(pkgName, "rev-list", "factory", "^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") - added_rpm_revs = strings.Split(out, "\n") - } - if len(added_revs) == len(old_revs) && len(added_rpm_revs) == len(old_revs) { - log.Printf("Something is wrong with rev-ist for (len %d): %s\n", len(added_revs), pkgName) - reposOK = false + 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") + 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", 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) { + log.Printf("Something is wrong with rev-ist for (len %d): %s\n", len(added_revs), pkgName) + reposOK = false + } } } @@ -259,7 +267,7 @@ func main() { 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()