#1951 add strict to getChangelogEntries
Merged 4 years ago by tkopecek. Opened 4 years ago by tkopecek.
tkopecek/koji issue1147  into  master

file modified
+11 -2
@@ -10474,7 +10474,8 @@ 

  

      addArchiveType = staticmethod(add_archive_type)

  

-     def getChangelogEntries(self, buildID=None, taskID=None, filepath=None, author=None, before=None, after=None, queryOpts=None):

+     def getChangelogEntries(self, buildID=None, taskID=None, filepath=None, author=None,

+                             before=None, after=None, queryOpts=None, strict=False):

          """Get changelog entries for the build with the given ID,

             or for the rpm generated by the given task at the given path

  
@@ -10486,6 +10487,7 @@ 

                   (a datetime object, a string in the 'YYYY-MM-DD HH24:MI:SS format, or integer seconds

                    since the epoch)

          - queryOpts: query options used by the QueryProcessor

+         - strict: if srpm doesn't exist raise an error, otherwise return empty list

  

          If "order" is not specified in queryOpts, results will be returned in reverse chronological

          order.
@@ -10502,9 +10504,13 @@ 

          if buildID:

              build_info = get_build(buildID)

              if not build_info:

+                 if strict:

+                     raise koji.GenericError("Build %s doesn't exist" % buildID)

                  return _applyQueryOpts([], queryOpts)

              srpms = self.listRPMs(buildID=build_info['id'], arches='src')

              if not srpms:

+                 if strict:

+                     raise koji.GenericError("Build %s doesn't have srpms" % buildID)

                  return _applyQueryOpts([], queryOpts)

              srpm_info = srpms[0]

              srpm_path = joinpath(koji.pathinfo.build(build_info), koji.pathinfo.rpm(srpm_info))
@@ -10520,7 +10526,10 @@ 

              raise koji.GenericError('either buildID or taskID and filepath must be specified')

  

          if not os.path.exists(srpm_path):

-             return _applyQueryOpts([], queryOpts)

+             if strict:

+                 raise koji.GenericError("SRPM %s doesn't exist" % srpm_path)

+             else:

+                 return _applyQueryOpts([], queryOpts)

  

          if before:

              if isinstance(before, datetime.datetime):

If srpm doesn't exist and strict is specified, raise GenericError
instead of returning empty list.

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

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

4 years ago

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

4 years ago

rebased onto 15d68bd

4 years ago

updated to handle all cases

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

4 years ago

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

4 years ago

Commit c60c623 fixes this pull-request

Pull-Request has been merged by tkopecek

4 years ago
Metadata