Added --force option for repa group
authorEd Bartosh <eduard.bartosh@intel.com>
Tue, 18 Mar 2014 18:45:05 +0000 (20:45 +0200)
committerEduard Bartosh <eduard.bartosh@intel.com>
Wed, 19 Mar 2014 13:21:46 +0000 (15:21 +0200)
By default repa now checks if binary packages exist in submission and
doesn't allow grouping submissions without binary packages.

--force option allows to bypass this check, i.e. allows to group failed
submissions. This can be useful for grouping failed submissions to
reject them as a group.

Fixes: #1707
Change-Id: Ieb66718839e19b63de5039757a2bbc63d02016c6
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
repa.1
repa/group.py

diff --git a/repa.1 b/repa.1
index 89176acebcb415b9fa0324f5aadfde381eb5040e..d7d522f16feec7751e7ef3dd8f0d54356b0f4789 100644 (file)
--- a/repa.1
+++ b/repa.1
@@ -220,6 +220,12 @@ Target project name. Mandatory option.
 Add  comment to created submit group. It will be shown by list command.
 .RE
 
+.PP
+\-f, \-\-force
+.RS 2
+Force group creation for submissions without binary packages. Useful when grouping failed submissions for rejection.
+.RE
+
 .\"
 .\" The "rmgroup" command description
 .\"
index fd8669b0a1166586f6763d713786b8cd26fe3073..aede33c158f3952626f88745627584b55783e11e 100755 (executable)
@@ -64,16 +64,20 @@ def check_build_results(bresults):
             # target project: for pkg, status in res['packages'] ...
 
 
-def check_common_pkgs(obs, submissions):
-    """Check if submissions have common packages"""
+def check_binary_pkgs(obs, submissions, force=False):
+    """
+    Check if submissions have common binary packages.
+    Check if binary packages exist.
+    """
     binaries = {}
     for submission, data in submissions.iteritems():
         pkgs = list(obs.get_binary_packages(data['project']))
         # check if submission has binary packages
         for repo, bins in pkgs:
-            #if not bins:
-            #    raise RepaException('No binary packages found in %s %s/%s' % \
-            #                            (submission, repo[0], repo[1]))
+            # Check if binary packages exist
+            if not force and not bins:
+                raise RepaException('No binary packages found in %s %s/%s' % \
+                                    (submission, repo[0], repo[1]))
             # check if submissions have common packages
             for subm, info in binaries.iteritems():
                 if repo == info['repo']:
@@ -118,7 +122,7 @@ def aggregate(obs, bresults, gproject):
     return aggregated
 
 
-def group_submissions(obs, submissions, target, comment):
+def group_submissions(obs, submissions, target, comment, force=False):
     """Group multiple submissions into one group."""
     # find correspondent prerelease projects
     info = {}
@@ -133,7 +137,7 @@ def group_submissions(obs, submissions, target, comment):
                  for subm, data in info.iteritems()]
     check_build_results(bresults)
 
-    check_common_pkgs(obs, info)
+    check_binary_pkgs(obs, info, force)
 
     # create group project
     name, gproject = create_group_project(obs, info.keys(),
@@ -161,13 +165,15 @@ class Group(object):
         parser.add_argument('-p', '--project', help='target project',
                             required=True)
         parser.add_argument('-c', '--comment', help='comment', default='')
+        parser.add_argument('-f', '--force', help='force group creation',
+                            default=False)
 
     @staticmethod
     def run(argv):
         """Command line entry point. Called from [sub_]main."""
         obs = OBS(argv.apiurl, argv.apiuser, argv.apipasswd)
         return group_submissions(obs, argv.submission, argv.project,
-                                 argv.comment)
+                                 argv.comment, argv.force)
 
 
 if __name__ == '__main__':