Ejemplo n.º 1
0
def test_non_empty_folder(folder):
    """assert a repo initialized and files committed
    """
    gitb.commit(folder)
    repo = git.Repo(folder)
    assert not repo.is_dirty(untracked_files=True)
    ncommits = len(list(repo.iter_commits()))
    assert 1 == ncommits
Ejemplo n.º 2
0
def test_empty_folder(tmpdir_factory):
    """assert empty folder won't be initialized as a repo
    """
    folder = Path(tmpdir_factory.mktemp('git'))
    with warnings.catch_warnings(record=True) as w:
        gitb.commit(folder)
    assert len(w) == 1
    assert not gitb.is_git_repo(folder)
Ejemplo n.º 3
0
def test_dirty_repo(repo_dirty):
    """assert all changes commit
    """
    repo = repo_dirty
    folder = repo.working_tree_dir
    gitb.commit(folder)
    assert not repo.is_dirty(untracked_files=True)
    ncommits = len(list(repo.iter_commits()))
    assert 2 == ncommits
Ejemplo n.º 4
0
def test_clean_repo(repo):
    """assert no empty commit is made
    """
    folder = repo.working_tree_dir
    with warnings.catch_warnings(record=True) as w:
        gitb.commit(folder)
    assert len(w) == 1
    assert not repo.is_dirty(untracked_files=True)
    ncommits = len(list(repo.iter_commits()))
    assert 1 == ncommits
Ejemplo n.º 5
0
def test_default_message(repo_dirty):
    repo = repo_dirty
    folder = repo.working_tree_dir
    gitb.commit(folder)
    assert 'commit all' == repo.head.commit.message
Ejemplo n.º 6
0
def test_nonexistent_path(nonexistent_path):
    """assert exception is raised for nonexistent path
    """
    with pytest.raises(ValueError):
        gitb.commit(nonexistent_path)
Ejemplo n.º 7
0
def test_custom_message(repo_dirty):
    repo = repo_dirty
    folder = repo.working_tree_dir
    gitb.commit(folder, 'custom message')
    assert 'custom message' == repo.head.commit.message