This should preserve the pre-existing behavior, where if latest is set
to True, only the latest builds in a tag are returned, and if latest is
set to False, all the builds in a tag are returned.

The new behavior is a kind of middleground, where you can set latest=3,
and only the latest three builds for each package in a tag are returned.

We want this ultimately for mashing rawhide so we can create a downgrade
path for people if new builds break them.
https://bugzilla.redhat.com/show_bug.cgi?id=1082830

Discussed and revised:
https://lists.fedoraproject.org/pipermail/buildsys/2015-February/004541.html
---
 hub/kojihub.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/hub/kojihub.py b/hub/kojihub.py
index f794d5d..62c6b95 100644
--- a/hub/kojihub.py
+++ b/hub/kojihub.py
@@ -1125,6 +1125,7 @@ def 
readTaggedBuilds(tag,event=None,inherit=False,latest=False,package=None,owne
     set inherit=True to follow inheritance
     set event to query at a time in the past
     set latest=True to get only the latest build per package
+    set latest=N to get only the N latest tagged RPMs
 
     If type is not None, restrict the list to builds of the given type.  
Currently the supported
     types are 'maven', 'win', and 'image'.
@@ -1206,10 +1207,10 @@ def 
readTaggedBuilds(tag,event=None,inherit=False,latest=False,package=None,owne
                 # list should take priority
                 continue
             if latest:
-                if seen.has_key(pkgid):
+                if (latest is True and seen.has_key(pkgid)) or seen.get(pkgid, 
0) >= latest:
                     #only take the first (note ordering in query above)
                     continue
-                seen[pkgid] = 1
+                seen[pkgid] = seen.get(pkgid, 0) + 1
             builds.append(build)
 
     return builds
@@ -1220,6 +1221,7 @@ def readTaggedRPMS(tag, package=None, arch=None, 
event=None,inherit=False,latest
     set inherit=True to follow inheritance
     set event to query at a time in the past
     set latest=False to get all tagged RPMS (not just from the latest builds)
+    set latest=N to get only the N latest tagged RPMs
 
     If type is not None, restrict the list to rpms from builds of the given 
type.  Currently the
     supported types are 'maven' and 'win'.
@@ -1309,6 +1311,7 @@ def readTaggedArchives(tag, package=None, event=None, 
inherit=False, latest=True
     set inherit=True to follow inheritance
     set event to query at a time in the past
     set latest=False to get all tagged archives (not just from the latest 
builds)
+    set latest=N to get only the N latest tagged RPMs
 
     If type is not None, restrict the listing to archives of the given type.  
Currently
     the supported types are 'maven' and 'win'.
-- 
2.1.0

--
buildsys mailing list
[email protected]
https://admin.fedoraproject.org/mailman/listinfo/buildsys

Reply via email to