mirror of
https://github.com/openSUSE/osc.git
synced 2025-08-22 22:48:51 +02:00
"osc cat" now auto-expands through link. New option -n to suppress this.
This commit is contained in:
@@ -4527,7 +4527,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
@cmdln.option('-r', '--revision', metavar='rev',
|
||||
help='print out the specified revision')
|
||||
@cmdln.option('-e', '--expand', action='store_true',
|
||||
help='expand linked package')
|
||||
help='force expand linked package. Use with -n')
|
||||
@cmdln.option('-n', '--no-auto-expand', action='store_true',
|
||||
help='expand link only when -e given. Default: try without expansion, then with.')
|
||||
def do_cat(self, subcmd, opts, *args):
|
||||
"""${cmd_name}: Output the content of a file to standard output
|
||||
|
||||
@@ -4562,8 +4564,19 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
if opts.expand:
|
||||
query['rev'] = show_upstream_srcmd5(conf.config['apiurl'], args[0], args[1], expand=True, revision=opts.revision)
|
||||
u = makeurl(conf.config['apiurl'], ['source', args[0], args[1], args[2]], query=query)
|
||||
for data in streamfile(u):
|
||||
sys.stdout.write(data)
|
||||
try:
|
||||
for data in streamfile(u):
|
||||
sys.stdout.write(data)
|
||||
except urllib2.HTTPError, e:
|
||||
if e.code == 404 and not opts.expand and not opts.no_auto_expand:
|
||||
print >>sys.stderr, 'expanding link...'
|
||||
query['rev'] = show_upstream_srcmd5(conf.config['apiurl'], args[0], args[1], expand=True, revision=opts.revision)
|
||||
u = makeurl(conf.config['apiurl'], ['source', args[0], args[1], args[2]], query=query)
|
||||
for data in streamfile(u):
|
||||
sys.stdout.write(data)
|
||||
else:
|
||||
e.osc_msg = 'If linked, try: cat -e'
|
||||
raise e
|
||||
|
||||
|
||||
# helper function to download a file from a specific revision
|
||||
|
Reference in New Issue
Block a user