def test_for_each_ref_sort(): tmp = maketemp() commands.init_bare(tmp) commands.fast_import( repo=tmp, commits=[ dict( message='one', committer='John Doe <*****@*****.**>', commit_time='1216235872 +0300', files=[ dict( path='foo', content='FOO', ), ], ), ], ) commands.update_ref( repo=tmp, ref='refs/heads/quux', newvalue='HEAD', oldvalue=40*'0', ) got = commands.for_each_ref( repo=tmp, sort='-refname', ) got = iter(got) eq(got.next(), dict(refname='refs/heads/quux')) eq(got.next(), dict(refname='refs/heads/master')) assert_raises(StopIteration, got.next)
def test_for_each_ref_fields(): tmp = maketemp() commands.init_bare(tmp) commands.fast_import( repo=tmp, commits=[ dict( message='one', committer='John Doe <*****@*****.**>', commit_time='1216235872 +0300', files=[ dict( path='foo', content='FOO', ), ], ), dict( message='two', committer='Jack Smith <*****@*****.**>', commit_time='1216235940 +0300', files=[ dict( path='foo', content='FOO', ), dict( path='bar', content='BAR', ), ], ), ], ) commands.update_ref( repo=tmp, ref='refs/heads/quux', newvalue='HEAD~1', oldvalue=40*'0', ) got = commands.for_each_ref( repo=tmp, fields=['refname', 'objecttype', 'objectname'], ) got = iter(got) eq( got.next(), dict( refname='refs/heads/master', objecttype='commit', objectname='27f952fd48ce824454457b9f28bb97091bc5422e', ), ) eq( got.next(), dict( refname='refs/heads/quux', objecttype='commit', objectname='e1b2f3253b18e7bdbd38db0cf295e6b3b608bb27', ), ) assert_raises(StopIteration, got.next)