#2555 hub: [listBuilds] add nvr glob pattern support
Merged a year ago by tkopecek. Opened 2 years ago by julian8628.
julian8628/koji list-builds-pattern  into  master

file modified
+8 -2
@@ -3009,6 +3009,7 @@ 

      parser.add_option("--task", help=_("List builds for this task"))

      parser.add_option("--type", help=_("List builds of this type."))

      parser.add_option("--prefix", help=_("Only builds starting with this prefix"))

+     parser.add_option("--pattern", help=_("Only list builds matching this GLOB pattern"))

      parser.add_option("--source", help=_("Only builds where the source field matches "

                                           "(glob pattern)"))

      parser.add_option("--owner", help=_("List builds built by this owner"))
@@ -3024,7 +3025,7 @@ 

          parser.error(_("This command takes no arguments"))

      ensure_connection(session)

      opts = {}

-     for key in ('type', 'prefix'):

+     for key in ('type', 'prefix', 'pattern'):

          value = getattr(options, key)

          if value is not None:

              opts[key] = value
@@ -3105,7 +3106,12 @@ 

      else:

          # Check filter exists

          if any(opts):

-             data = session.listBuilds(**opts)

+             try:

+                 data = session.listBuilds(**opts)

+             except koji.ParameterError as e:

+                 if e.args[0].endswith("'pattern'"):

+                     parser.error(_("The hub doesn't support the 'pattern' argument, please try"

+                                    " filtering the result on your local instead."))

          else:

              parser.error(_("Filter must be provided for list"))

      if not options.sort_key:

file modified
+6 -1
@@ -11173,7 +11173,7 @@ 

                     volumeID=None, source=None,

                     createdBefore=None, createdAfter=None,

                     completeBefore=None, completeAfter=None, type=None, typeInfo=None,

-                    queryOpts=None):

+                    queryOpts=None, pattern=None):

          """Return a list of builds that match the given parameters

  

          Filter parameters
@@ -11184,6 +11184,7 @@ 

              - volumeID: only builds stored on the given volume (numeric id)

              - source: only builds where the source field matches (glob pattern)

              - prefix: only builds whose package name starts with that prefix

+             - pattern: only builds whose nvr matches the glob pattern

              - state: only builds in the given state (numeric value)

  

          Timestamp filter parameters
@@ -11287,6 +11288,10 @@ 

              clauses.append('build.source ilike %(source)s')

          if prefix:

              clauses.append("package.name ilike %(prefix)s || '%%'")

+         if pattern:

+             pattern = self._prepareSearchTerms(pattern, 'glob')

+             clauses.append("package.name || '-' || build.version || '-' || build.release"

+                            " ilike %(pattern)s")

          if state is not None:

              clauses.append('build.state = %(state)i')

          if createdBefore:

fixes: #2554

--pattern is also added in list-builds command

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

2 years ago

@julian8628 Maybe for older hub, it should be in try/except + local pattern matching or denying to use this parameter?

Metadata Update from @mfilip:
- Pull-request untagged with: testing-ready

2 years ago

The testing ready tag was removed temporarily because of conflict with other PR.

@julian8628 There is one more thing for fix:

koji list-builds --pattern=kojitest-dummyrpm-o1y2n
2020-11-10 10:34:38,407 [ERROR] koji: Fault: <Fault 1: "<class 'TypeError'>: unsupported operand type(s) for -: 'str' and 'str'">

koji list-builds --pattern=kojitest
2020-11-10 10:35:46,503 [ERROR] koji: Fault: <Fault 1: "<class 'TypeError'>: unsupported operand type(s) for -: 'str' and 'str'">

Metadata Update from @mfilip:
- Pull-request tagged with: testing-ready

2 years ago

Metadata Update from @jcupova:
- Pull-request untagged with: testing-ready

2 years ago

rebased onto 3f57163

2 years ago

1 new commit added

  • fix typo of quote
2 years ago

added a simple try/except for old hub, and fixed the typo @jcupova found

pretty please pagure-ci rebuild

2 years ago

Metadata Update from @jcupova:
- Pull-request tagged with: testing-ready

2 years ago

Metadata Update from @jcupova:
- Pull-request tagged with: testing-done

2 years ago

Commit 838c378 fixes this pull-request

Pull-Request has been merged by tkopecek

a year ago

Metadata Update from @mfilip:
- Pull-request untagged with: testing-ready

a year ago

The testing ready tag was removed temporarily because of conflict with other PR.

Metadata Update from @mfilip:
- Pull-request tagged with: testing-ready

a year ago