if len(args) == 0 || (len(args) == 1 && args[0] == "all") {
for _, v := range xsa.SupportedVersions {
// Check to see if the branch exists
- if hasPatches && !xsa.RepoHasPatches(v) {
+ if hasPatches && !xsa.HasRecipe(v) {
// FIXME: Should this be "break" instead?
continue
}
return &r
}
-func (m *XSAMeta) RepoHasPatches(v XenVersion) bool {
+// Return 'true' if there's a recipe (even empty)
+func (m *XSAMeta) HasRecipe(v XenVersion) bool {
+ return m.GetRecipe(v) != nil
+}
+
+// Return 'true' if:
+// * There's a recipe for this version and it's empty
+// * There are no patches in the target branch
+func (m *XSAMeta) NeedsBackport(v XenVersion) bool {
r := m.GetRecipe(v)
- if r == nil {
+ if r == nil || r.HasPatches() {
return false
}
- return r.HasPatchBranch("xsa") == nil
+ return !r.RepoHasPatches("xsa")
}
func getXSAPath(xsanum int) string {
return
}
+// Return 'true' if all repo branches are valid, and contain patches
+func (r *Recipe) RepoHasPatches(prefix string) (bool) {
+ _, baseline, branch := r.branchName(prefix)
+
+ err := r.ForEachTree(func(tree Tree) error {
+ xr := G.repos.GetRepoNC(tree)
+
+ branchHash, err := xr.ParseRef(branch)
+ if err != nil {
+ return err
+ }
+
+ baseHash, err := xr.ParseRef(baseline)
+ if err != nil {
+ return err
+ }
+
+ if branchHash == "" || baseHash == "" {
+ return fmt.Errorf("Branch missing")
+ }
+
+ if branchHash == baseHash {
+ return fmt.Errorf("No patches between base and branch")
+ }
+
+ return nil
+ })
+
+ return err == nil
+}
+
func (r *Recipe) MakePatches(prefix string, sync bool) (count int, err error) {
_, baseline, branch := r.branchName(prefix)
for _, to := range xsa.SupportedVersions {
fmt.Printf("Checking version %v...", to)
if to == XenVersionMaster ||
- xsa.RepoHasPatches(to) {
- fmt.Printf("already done\n", to)
+ !xsa.NeedsBackport(to) {
+ fmt.Printf("already done\n")
from = to
continue
}