Ejemplo n.º 1
0
def test_is_commit_needed_no_change():
    tmp = maketemp()
    repo = os.path.join(tmp, 'repo')
    os.mkdir(repo)
    commands.init_bare(repo)
    index = os.path.join(tmp, 'index')
    sha_foo = commands.write_object(repo=repo, content='FOO')
    commands.update_index(
        repo=repo,
        index=index,
        files=[
            dict(
                object=sha_foo,
                path='quux/foo',
                ),
            ],
        )
    tree = commands.write_tree(
        repo=repo,
        index=index,
        )
    got = commands.is_commit_needed(
        repo=repo,
        tree=tree,
        parents=[],
        )
    eq(got, True)
Ejemplo n.º 2
0
def test_write_tree():
    tmp = maketemp()
    repo = os.path.join(tmp, 'repo')
    os.mkdir(repo)
    commands.init_bare(repo)
    index = os.path.join(tmp, 'index')
    sha_foo = commands.write_object(repo=repo, content='FOO')
    sha_bar = commands.write_object(repo=repo, content='BAR')
    commands.update_index(
        repo=repo,
        index=index,
        files=[
            dict(
                object=sha_foo,
                path='quux/foo',
                ),
            dict(
                object=sha_bar,
                path='bar',
                ),
            ],
        )

    tree = commands.write_tree(
        repo=repo,
        index=index,
        )
    eq(tree, 'e8abc9dd8c483a4e27598521674ae7a357d2c825')

    g = commands.ls_tree(repo=repo, treeish=tree)
    eq(
        g.next(),
        dict(
            mode='100644',
            type='blob',
            object='add8373108657cb230a5379a6fcdaab73f330642',
            path='bar',
            ),
        )
    eq(
        g.next(),
        dict(
            mode='040000',
            type='tree',
            object='d513b699a47153aad2f0cb7ea2cb9fde8c177428',
            path='quux',
            ),
        )
    assert_raises(StopIteration, g.next)
Ejemplo n.º 3
0
def test_is_commit_needed_root_empty():
    tmp = maketemp()
    repo = os.path.join(tmp, 'repo')
    os.mkdir(repo)
    commands.init_bare(repo)
    index = os.path.join(tmp, 'index')
    tree = commands.write_tree(
        repo=repo,
        index=index,
        )
    got = commands.is_commit_needed(
        repo=repo,
        tree=tree,
        parents=[],
        )
    eq(got, False)
Ejemplo n.º 4
0
 def __exit__(self, type_, value, traceback):
     if type_ is None and value is None and traceback is None:
         # no exception -> write tree
         self.tree = commands.write_tree(repo=self.repo, index=self.index)
     maybe_unlink(self.index)