mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-10 06:46:15 +01:00
add run_pager() and make osc log/diff work like git log/diff
Added new function run_pager() to get 'osc log/diff' work like 'git log/diff' which send the output to PAGER (which is by default: less or what's defined in the environment). Signed-off-by: Danny Kukawka <danny.kukawka@web.de>
This commit is contained in:
parent
e89e61380b
commit
5a19362570
@ -1894,7 +1894,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
diff += server_diff(pac.apiurl, pac.prjname, pac.name, rev1,
|
||||
pac.prjname, pac.name, rev2, not opts.plain, opts.missingok)
|
||||
if len(diff) > 0:
|
||||
print diff
|
||||
run_pager(diff)
|
||||
|
||||
|
||||
@cmdln.option('--oldprj', metavar='OLDPRJ',
|
||||
@ -3699,7 +3699,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
if opts.xml:
|
||||
format = 'xml'
|
||||
|
||||
print '\n'.join(get_commitlog(apiurl, project, package, rev, format))
|
||||
log = '\n'.join(get_commitlog(apiurl, project, package, rev, format))
|
||||
run_pager(log)
|
||||
|
||||
@cmdln.option('-f', '--failed', action='store_true',
|
||||
help='rebuild all failed packages')
|
||||
|
17
osc/core.py
17
osc/core.py
@ -2480,6 +2480,23 @@ def read_meta_from_spec(specfile, *args):
|
||||
|
||||
return spec_data
|
||||
|
||||
def run_pager(message):
|
||||
import tempfile
|
||||
|
||||
tmpfile = None
|
||||
|
||||
if tmpfile is None:
|
||||
tmpfile = tempfile.NamedTemporaryFile()
|
||||
|
||||
tmpfile.write(message)
|
||||
tmpfile.flush()
|
||||
pager = os.getenv('PAGER', default='less')
|
||||
subprocess.call('%s %s' % (pager, tmpfile.name), shell=True)
|
||||
|
||||
if tmpfile is not None:
|
||||
tmpfile.close()
|
||||
|
||||
|
||||
def run_editor(filename):
|
||||
if sys.platform[:3] != 'win':
|
||||
editor = os.getenv('EDITOR', default='vim')
|
||||
|
Loading…
Reference in New Issue
Block a user