def backup_db_as_csv_to_github_(repo_path, exclude=None): repo_path = Path(repo_path) for csv_file in repo_path.glob('*.csv'): csv_file.unlink() export_db_to_csv_files(repo_path, exclude) gitb.commit(repo_path) gitb.push(repo_path)
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
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)
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
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
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
def test_default_message(repo_dirty): repo = repo_dirty folder = repo.working_tree_dir gitb.commit(folder) assert 'commit all' == repo.head.commit.message
def test_nonexistent_path(nonexistent_path): """assert exception is raised for nonexistent path """ with pytest.raises(ValueError): gitb.commit(nonexistent_path)
def backup_db_to_github_(repo_path): gitb.commit(repo_path) gitb.push(repo_path)