]> xenbits.xensource.com Git - people/gdunlap/xsatool.git/commitdiff
recipe: Refactor temporary branch creation
authorGeorge Dunlap <george.dunlap@citrix.com>
Wed, 7 Nov 2018 17:00:30 +0000 (17:00 +0000)
committerGeorge Dunlap <george.dunlap@citrix.com>
Wed, 7 Nov 2018 17:00:30 +0000 (17:00 +0000)
The two paths are identical except for the branch name and the error
message; just use a variable for the branch name and call the branch
creation code once.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
recipe.go

index 651cef7c184891885915f686fef9b2627351709b..332832667fdecb55f46692d8d5e228cfc2641399 100644 (file)
--- a/recipe.go
+++ b/recipe.go
@@ -553,18 +553,18 @@ func (r *Recipe) Build(prefix string) (err error) {
 
        /* Always check out a temporary branch for xen */
        tmpBranch := "xsa/tmp"
-       if tr, prs := r.Recipes[TreeXen]; prs && tr.HasPatches() {
-               err = xenrepo.MakeBranch(tmpBranch, branch)
-               if err != nil {
-                       return fmt.Errorf("Checking out xen.git branch %s: %v\n",
-                               branch, err)
-               }
-       } else {
-               err = xenrepo.MakeBranch(tmpBranch, XenStableBranch(r.XenVersion))
-               if err != nil {
-                       return fmt.Errorf("Making tempbranch %s for xenversion %v: %v\n",
-                               tmpBranch, r.XenVersion, err)
-               }
+
+       // If the recipe has Xen patches, use the recipe branch name;
+       // otherwise, use the stable branch for that Xen version
+       wtbranch := branch
+       if tr, prs := r.Recipes[TreeXen]; !(prs && tr.HasPatches()) {
+               wtbranch = XenStableBranch(r.XenVersion)
+       }
+
+       err = xenrepo.MakeBranch(tmpBranch, wtbranch)
+       if err != nil {
+               return fmt.Errorf("Making tempbranch %s from %v for xenversion %v: %v\n",
+                       tmpBranch, branch, r.XenVersion, err)
        }
 
        // Make .config file with path to repos