mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-28 05:02:11 +01:00
- sort output of 'status' (unknown files first, filenames alphabetically)
- fix the unit tests for the above change, and for api changes
This commit is contained in:
parent
fb9d9495e9
commit
9a944edfeb
@ -386,15 +386,27 @@ usage: osc st
|
|||||||
# no files given as argument? Take all files in current dir
|
# no files given as argument? Take all files in current dir
|
||||||
if not p.todo:
|
if not p.todo:
|
||||||
p.todo = p.filenamelist + p.filenamelist_unvers
|
p.todo = p.filenamelist + p.filenamelist_unvers
|
||||||
|
p.todo.sort()
|
||||||
|
|
||||||
|
lines = []
|
||||||
for filename in p.todo:
|
for filename in p.todo:
|
||||||
if filename in p.excluded:
|
if filename in p.excluded:
|
||||||
continue
|
continue
|
||||||
s = p.status(filename)
|
s = p.status(filename)
|
||||||
if s == 'F':
|
if s == 'F':
|
||||||
print statfrmt('!', pathjoin(p.dir, filename))
|
lines.append(statfrmt('!', pathjoin(p.dir, filename)))
|
||||||
elif s != ' ':
|
elif s != ' ':
|
||||||
print statfrmt(s, pathjoin(p.dir, filename))
|
lines.append(statfrmt(s, pathjoin(p.dir, filename)))
|
||||||
|
# for -v (later)
|
||||||
|
#else:
|
||||||
|
# lines.append(statfrmt(s, pathjoin(p.dir, filename)))
|
||||||
|
|
||||||
|
# arrange the lines in order: unknown files first
|
||||||
|
# filenames are already sorted
|
||||||
|
lines = [line for line in lines if line[0] == '?'] \
|
||||||
|
+ [line for line in lines if line[0] != '?']
|
||||||
|
if lines:
|
||||||
|
print '\n'.join(lines)
|
||||||
|
|
||||||
|
|
||||||
def add(args):
|
def add(args):
|
||||||
|
10
tests.py
10
tests.py
@ -92,7 +92,7 @@ class TestOsc(unittest.TestCase):
|
|||||||
def testMetaPac(self):
|
def testMetaPac(self):
|
||||||
self.out, self.err = runosc('meta Apache apache2')
|
self.out, self.err = runosc('meta Apache apache2')
|
||||||
self.assertEqual(self.err, '')
|
self.assertEqual(self.err, '')
|
||||||
self.assert_('<package project="Apache" name="apache2">' in self.out)
|
self.assert_('<package name="apache2" project="Apache">' in self.out)
|
||||||
|
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
@ -107,7 +107,7 @@ class TestOsc(unittest.TestCase):
|
|||||||
def testPlatformsPac(self):
|
def testPlatformsPac(self):
|
||||||
self.out, self.err = runosc('platforms Apache')
|
self.out, self.err = runosc('platforms Apache')
|
||||||
self.assertEqual(self.err, '')
|
self.assertEqual(self.err, '')
|
||||||
self.assert_('SUSE_Linux_Factory' in self.out)
|
self.assert_('openSUSE_Factory' in self.out)
|
||||||
|
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
@ -181,17 +181,17 @@ Transmitting file data
|
|||||||
self.out, self.err = runosc('add foo2')
|
self.out, self.err = runosc('add foo2')
|
||||||
self.out, self.err = runosc('st')
|
self.out, self.err = runosc('st')
|
||||||
self.assertEqual(self.err, '')
|
self.assertEqual(self.err, '')
|
||||||
self.assertEqual(self.out, 'A foo2\n? onlyinwc\n')
|
self.assertEqual(self.out, '? onlyinwc\nA foo2\n')
|
||||||
|
|
||||||
# status with an absolute directory as argument
|
# status with an absolute directory as argument
|
||||||
self.out, self.err = runosc('st %s' % os.getcwd())
|
self.out, self.err = runosc('st %s' % os.getcwd())
|
||||||
self.assertEqual(self.err, '')
|
self.assertEqual(self.err, '')
|
||||||
self.assertEqual(self.out, 'A %s/foo2\n? %s/onlyinwc\n' % (os.getcwd(), os.getcwd()))
|
self.assertEqual(self.out, '? %s/onlyinwc\nA %s/foo2\n' % (os.getcwd(), os.getcwd()))
|
||||||
|
|
||||||
# status with an absolute directory as argument
|
# status with an absolute directory as argument
|
||||||
self.out, self.err = runosc('st %s' % os.getcwd())
|
self.out, self.err = runosc('st %s' % os.getcwd())
|
||||||
self.assertEqual(self.err, '')
|
self.assertEqual(self.err, '')
|
||||||
self.assertEqual(self.out, 'A %s/foo2\n? %s/onlyinwc\n' % (os.getcwd(), os.getcwd()))
|
self.assertEqual(self.out, '? %s/onlyinwc\nA %s/foo2\n' % (os.getcwd(), os.getcwd()))
|
||||||
|
|
||||||
# status with a single file as argument
|
# status with a single file as argument
|
||||||
reldir = os.path.basename(os.getcwd())
|
reldir = os.path.basename(os.getcwd())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user