From f6d2d01624e59f69d9da7e55067d3cb12e18d035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCdepohl?= <lorenz.huedepohl@rzg.mpg.de> Date: Fri, 11 Jan 2019 13:52:10 +0100 Subject: [PATCH] Make mpcdf_push work also when no sources have been changed --- mpcdf_push.py | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/mpcdf_push.py b/mpcdf_push.py index b93b426..2ffb953 100644 --- a/mpcdf_push.py +++ b/mpcdf_push.py @@ -88,16 +88,27 @@ def do_mpcdf_push(self, subcmd, opts, *args): "Configure the enabled repositories first, with `osc mpcdf_enable_repositories`", file=sys.stderr) raise SystemExit(1) - req_id = osc.core.create_submit_request(api_url, from_project, package, dst_project=to_project, - message="Update {0} from {1}".format(package, from_project) if not opts.message else opts.message) - print("Submitted package {0} to {1} in request {2}".format(package, to_project, req_id)) - if not opts.batch: - print("\nPLEASE review the request by 'osc request show {0} --diff', or in the web interface\n".format(req_id)) - print("Press Ctrl-C to abort, any key to continue", end="") - input() - result = osc.core.change_request_state(api_url, req_id, 'accepted', "Accepted on the command line via 'osc mpcdf_push'") - print(" Accepting request {0}:".format(req_id), result) + req_id = None + try: + req_id = osc.core.create_submit_request(api_url, from_project, package, dst_project=to_project, + message="Update {0} from {1}".format(package, from_project) if not opts.message else opts.message) + except osc.core.HTTPError as e: + if e.code == 400: + if "The request contains no actions" in e.read(): + print("No source changes found, submit request not necessary") + else: + raise e + + if req_id: + print("Submitted package {0} to {1} in request {2}".format(package, to_project, req_id)) + if not opts.batch: + print("\nPLEASE review the request by 'osc request show {0} --diff', or in the web interface\n".format(req_id)) + print("Press Ctrl-C to abort, any key to continue", end="") + input() + result = osc.core.change_request_state(api_url, req_id, 'accepted', "Accepted on the command line via 'osc mpcdf_push'") + print(" Accepting request {0}:".format(req_id), result) + if not opts.batch: user = osc.conf.get_apiurl_usr(api_url) if user not in existing_maintainers: print("Adding you to the list of maintainers for this package") -- GitLab