#1476 Allow taginfo cli to use tag IDs; fixed Inheritance printing bug
Merged 2 years ago by mikem. Opened 2 years ago by jmolet.
jmolet/koji taginfo-with-id  into  master

file modified
+8 -3
@@ -4759,8 +4759,13 @@ 

      for tag in args:

          info = session.getTag(tag, **event_opts)

          if info is None:

-             print("No such tag: %s" % tag)

-             sys.exit(1)

+             try:

+                 info = session.getTag(int(tag), **event_opts)

+             except ValueError:

+                 info = None

+             if info is None:

+                 print("No such tag: %s" % tag)

+                 sys.exit(1)

          tags.append(info)

  

      for n, info in enumerate(tags):
@@ -4814,7 +4819,7 @@ 

              for rinfo in external_repos:

                  print("  %(priority)3i %(external_repo_name)s (%(url)s)" % rinfo)

          print("Inheritance:")

-         for parent in session.getInheritanceData(tag, **event_opts):

+         for parent in session.getInheritanceData(info['id'], **event_opts):

              flags = ''

              for code,expr in (

                      ('M',parent['maxdepth'] is not None),

It would be useful to be able to use the koji cli's taginfo with tag IDs and not just the tag name since the python library allows for this. Also there is a bug where Inheritance always uses the value of the last tag queried for.

Old behavior (ID bug):

❯❯❯ koji taginfo 6438
No such tag: 6438

Old behavior (Inheritance bug):

❯❯❯ koji taginfo rawhide f31 
Tag: rawhide [197]
Arches: aarch64 armv7hl i686 ppc64 ppc64le s390x x86_64
Groups: appliance-build, build, livecd-build, livemedia-build, srpm-build
LOCKED
Tag options:
Inheritance:
                                      <<<<< inheritance missing/incorrect

Tag: f31 [6438]
Arches: None
Groups: appliance-build, build, livecd-build, livemedia-build, srpm-build
Required permission: 'autosign'
Tag options:
  mock.new_chroot : 0
  mock.package_manager : 'dnf'
Inheritance:

New behavior:

❯❯❯ koji taginfo rawhide 6438        
Tag: rawhide [197]
Arches: aarch64 armv7hl i686 ppc64 ppc64le s390x x86_64
Groups: appliance-build, build, livecd-build, livemedia-build, srpm-build
LOCKED
Tag options:
Inheritance:
  0    .... f31 [6438]

Tag: f31 [6438]
Arches: None
Groups: appliance-build, build, livecd-build, livemedia-build, srpm-build
Required permission: 'autosign'
Tag options:
  mock.new_chroot : 0
  mock.package_manager : 'dnf'
Inheritance:

While it would be highly dubious to create a tag whose name is a valid integer, it is possible. In such a case, this would make it difficult to get info about said tag.

Perhaps it would make sense to only check for an integer if session.getTag fails for the string value.

rebased onto 1abce11fef2dc4cdd4e6d8ee9e3626cca1d0d931

2 years ago

@mikem Good thought. I've updated this with those changes.

Maybe less lines with

    except ValueError:
        info = None`
    if info is None:
        print("No such tag: %s" % tag)
        sys.exit(1)

block only once?

rebased onto d87cdc4

2 years ago

Thanks!

I've filed an issue for the inheritance display issue just for tracking purposes.

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

Commit 6c0c45d fixes this pull-request

Pull-Request has been merged by mikem

2 years ago