From ccafb430b81cf387b8071abf28c0a93fc5d084b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Tue, 7 Mar 2017 15:07:44 +0100 Subject: [PATCH] support operation in checked out package for cat/less/blame --- NEWS | 1 + osc/commandline.py | 29 ++++++++++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index 63bb3ae7..1bf0e7cd 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ - add blame command (requires OBS 2.9) - results: show multibuild results by default - getbinaries: make .AppImage files executable + - support operation in checked out package for cat/less/blame 0.156 - highlight scheduled jobs with dispatch problems (due to constraints) diff --git a/osc/commandline.py b/osc/commandline.py index d1c7c650..9f49e038 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -7940,11 +7940,18 @@ Please submit there instead, or use --nodevelproject to force direct submission. """${cmd_name}: Output the content of a file to standard output Examples: + osc cat file osc cat project package file osc cat project/package/file osc cat http://api.opensuse.org/build/.../_log osc cat http://api.opensuse.org/source/../_link + osc less file + osc less project package file + + osc blame file + osc blame project package file + ${cmd_usage} ${cmd_option_list} """ @@ -7957,11 +7964,19 @@ Please submit there instead, or use --nodevelproject to force direct submission. opts.file = None return self.do_api('list', opts, *args) - - args = slash_split(args) - if len(args) != 3: + project = package = filename = None + if len(args) == 3: + project = args[0] + package = args[1] + filename = args[2] + elif len(args) == 1 and is_package_dir(os.getcwd()): + project = store_read_project(os.curdir) + package = store_read_package(os.curdir) + filename = args[0] + else: raise oscerr.WrongArgs('Wrong number of arguments.') + rev, dummy = parseRevisionOption(opts.revision) apiurl = self.get_api_url() @@ -7973,8 +7988,8 @@ Please submit there instead, or use --nodevelproject to force direct submission. if opts.revision: query['rev'] = opts.revision if opts.expand: - query['rev'] = show_upstream_srcmd5(apiurl, args[0], args[1], expand=True, revision=opts.revision, meta=opts.meta) - u = makeurl(apiurl, ['source', args[0], args[1], args[2]], query=query) + query['rev'] = show_upstream_srcmd5(apiurl, project, package, expand=True, revision=opts.revision, meta=opts.meta) + u = makeurl(apiurl, ['source', project, package, filename], query=query) try: if subcmd == 'less': f = http_GET(u) @@ -7985,8 +8000,8 @@ Please submit there instead, or use --nodevelproject to force direct submission. except HTTPError as e: if e.code == 404 and not opts.expand and not opts.unexpand: print('expanding link...', file=sys.stderr) - query['rev'] = show_upstream_srcmd5(apiurl, args[0], args[1], expand=True, revision=opts.revision) - u = makeurl(apiurl, ['source', args[0], args[1], args[2]], query=query) + query['rev'] = show_upstream_srcmd5(apiurl, project, package, expand=True, revision=opts.revision) + u = makeurl(apiurl, ['source', project, package, filename], query=query) if subcmd == "less": f = http_GET(u) run_pager(''.join(f.readlines()))