From 5fd408c0e154a8e28aeebebedf2125875dd5081e Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Mon, 3 Mar 2014 17:18:18 +0100 Subject: [PATCH] don't allow select in an outdated (+7 days) project and build enable the prj afterwards --- osc-staging.py | 5 +++++ osclib/stagingapi.py | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/osc-staging.py b/osc-staging.py index cd5bb5b7..099d2763 100644 --- a/osc-staging.py +++ b/osc-staging.py @@ -241,6 +241,9 @@ def do_staging(self, subcmd, opts, *args): osclib.accept_command.AcceptCommand(api).perform(api.prj_from_letter(args[1])) elif cmd in ['select', 'unselect']: stprj = api.prj_from_letter(args[1]) + if not api.prj_frozen_enough(stprj): + print "Freeze the prj first" + return False for rq in RequestFinder.find_sr(args[2:], opts.apiurl): if cmd == 'select': api.rq_to_prj(rq, stprj) @@ -248,6 +251,8 @@ def do_staging(self, subcmd, opts, *args): api.rm_from_prj(stprj, request_id=rq) api.add_review(rq, by_group='factory-staging', msg='Please recheck') + api.build_switch_prj(stprj, 'enable') + elif cmd in ['move']: cprj = store_read_project(os.getcwd()) sprj = api.prj_from_letter(opts.from_) if opts.from_ else cprj diff --git a/osclib/stagingapi.py b/osclib/stagingapi.py index 17ee652f..31bf464d 100644 --- a/osclib/stagingapi.py +++ b/osclib/stagingapi.py @@ -742,3 +742,20 @@ class StagingAPI(object): ET.SubElement(prjmeta.find('build'), state) http_PUT(url, data=ET.tostring(prjmeta)) + + def prj_frozen_enough(self, project): + """ + Check if we can and should refreeze the prj" + :param project the project to check + :returns True if we can select into it + """ + + data = self.get_prj_pseudometa(project) + if data['requests']: + return True # already has content + + # young enough + if self.days_since_last_freeze(project) < 6.5: + return True + + return False