#2704 Unite add-tag-inheritance --force with hub
Closed 3 years ago by jcupova. Opened 3 years ago by jcupova.
jcupova/koji issue2614  into  master

file modified
+1 -1
@@ -5201,7 +5201,7 @@ 

      new_data['pkg_filter'] = options.pkg_filter or ''

  

      inheritanceData.append(new_data)

-     session.setInheritanceData(tag['id'], inheritanceData)

+     session.setInheritanceData(tag['id'], inheritanceData, force=options.force)

  

  

  def handle_edit_tag_inheritance(goptions, session, args):

file modified
+7 -6
@@ -675,13 +675,13 @@ 

      return data

  

  

- def writeInheritanceData(tag_id, changes, clear=False):

+ def writeInheritanceData(tag_id, changes, clear=False, force=False):

      """Add or change inheritance data for a tag"""

      context.session.assertPerm('tag')

-     _writeInheritanceData(tag_id, changes, clear)

+     _writeInheritanceData(tag_id, changes, clear, force=force)

  

  

- def _writeInheritanceData(tag_id, changes, clear=False):

+ def _writeInheritanceData(tag_id, changes, clear=False, force=False):

      """Add or change inheritance data for a tag"""

      fields = ('parent_id', 'priority', 'maxdepth', 'intransitive', 'noconfig', 'pkg_filter')

      if isinstance(changes, dict):
@@ -696,7 +696,7 @@ 

              if f not in link:

                  raise koji.GenericError("No value for %s" % f)

          parent_id = link['parent_id']

-         if parent_id in parent_ids:

+         if parent_id in parent_ids and not force:

              raise koji.GenericError("Changes should not contain duplicated"

                                      " parent_id(%i)" % parent_id)

          else:
@@ -11463,7 +11463,7 @@ 

          tag = get_tag_id(tag, strict=True)

          return readInheritanceData(tag, event)

  

-     def setInheritanceData(self, tag, data, clear=False):

+     def setInheritanceData(self, tag, data, clear=False, force=False):

          """

          Set inheritance relationships for a tag.

  
@@ -11479,11 +11479,12 @@ 

          :param bool clear: Wipe out all existing inheritance rules and only

                             apply the ones you submit here. If unspecified,

                             this defaults to False.

+         :param bool force: override inheritance relationship for tag

          """

          # verify existence of tag and/or convert name to id

          tag = get_tag_id(tag, strict=True)

          context.session.assertPerm('tag')

-         return writeInheritanceData(tag, data, clear=clear)

+         return writeInheritanceData(tag, data, clear=clear, force=force)

  

      def getFullInheritance(self, tag, event=None, reverse=False, stops=None, jumps=None):

          """

Added force argument to API call setTagInheritance and calls related to
this call.

Fixes: https://pagure.io/koji/issue/2614

I think we might need a bit more discussion in #2614 before we settle on a fix

Issue will be fixed by other way after discussion in #2614 . I am closing this PR.

Pull-Request has been closed by jcupova

3 years ago