def test_check_path(name, cmd_result, expectation): with patch("dfetch.project.svn.run_on_cmdline") as run_on_cmdline_mock: run_on_cmdline_mock.side_effect = cmd_result assert SvnRepo.check_path() == expectation
def _get_repo(path: str, project: ProjectEntry) -> VCS: """Get the repo type from the project.""" if not os.path.exists(project.destination): raise RuntimeError( "You cannot generate a diff of a project that was never fetched") main_project_dir = os.path.dirname(path) if GitLocalRepo(main_project_dir).is_git(): return GitRepo(project) if SvnRepo.check_path(main_project_dir): return SvnRepo(project) raise RuntimeError("Can only create patch in SVN or Git repo", )
def _import_projects() -> Sequence[ProjectEntry]: """Find out what type of VCS is used and import projects.""" if GitRepo.check_path(): projects = _import_from_git() elif SvnRepo.check_path(): projects = _import_from_svn() else: raise RuntimeError( "Only git or SVN projects can be imported.", "Run this command within either a git or SVN repository", ) return projects