#1484 comps: Preserve default arg on groupid
Merged 3 years ago by lsedlar. Opened 3 years ago by lsedlar.
lsedlar/pungi preserve-group-default  into  master

file modified
+9 -10
@@ -325,9 +325,8 @@ 

              group_node.appendChild(packagelist)

  

          for category in self.comps.categories:

-             groups = set(x.name for x in category.group_ids) & set(

-                 self.get_comps_groups()

-             )

+             group_ids = set(self.get_comps_groups())

+             groups = set(g for g in category.group_ids if g.name in group_ids)

              if not groups:

                  continue

              cat_node = doc.createElement("category")
@@ -341,7 +340,7 @@ 

              append_grouplist(doc, cat_node, groups)

  

          for environment in sorted(self.comps.environments, key=attrgetter("id")):

-             groups = set(x.name for x in environment.group_ids)

+             groups = set(environment.group_ids)

              if not groups:

                  continue

              env_node = doc.createElement("environment")
@@ -356,10 +355,7 @@ 

  

              if environment.option_ids:

                  append_grouplist(

-                     doc,

-                     env_node,

-                     (x.name for x in environment.option_ids),

-                     "optionlist",

+                     doc, env_node, set(environment.option_ids), "optionlist",

                  )

  

          if self.comps.langpacks:
@@ -460,8 +456,11 @@ 

  

  def append_grouplist(doc, parent, groups, elem="grouplist"):

      grouplist_node = doc.createElement(elem)

-     for groupid in sorted(groups):

-         append(doc, grouplist_node, "groupid", groupid)

+     for groupid in sorted(groups, key=lambda x: x.name):

+         kwargs = {}

+         if groupid.default:

+             kwargs["default"] = "true"

+         append(doc, grouplist_node, "groupid", groupid.name, **kwargs)

      parent.appendChild(grouplist_node)

  

  

When the wrapper processes comps file, it wasn't emitting "default" argument for groupid element. The default is false and most entries are actually using the default, so let's only emit it if set to true.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1882358

rebased onto b6a5d7de2aa418ab7779b987cb15bd14c835da92

3 years ago

Do items in self.get_comps_groups() have member .name? It seems to me that this intersection mixes different data formats.

That's a very good point. get_comps_groups returns list of IDs only (based on <group> elements). The group_ids is an iterable of objects with .name and .default attributes.

I updated the code to match that. Interestingly enough it didn't crash even before on my local tests.

rebased onto 9ea1098

3 years ago

I like your fix. And even more - you removed overloaded operator for the intersection (I see it rarely).
Btw, what happened with Jenkins tests in Pagure? Currently, I have to run my tests manually.

I'm wondering if it could be due to an expired certificate in Jenkins: https://pagure.io/fedora-infrastructure/issue/9596
But I don't know for sure.

Ah, thanks! I closed the one I opened as a duplicate.

Pull-Request has been merged by lsedlar

3 years ago
Metadata