def get_vcs(path="."): vcs = vcs_abstraction.get_vcs('git') #Check if there is a git repository in the specified path if vcs.static_detect_presence(path): return vcs(path) raise Exception("Not Found a valid Git Repository")
def test_get_vcs(self): try: backup = vcstools.vcs_abstraction._VCS_TYPES vcstools.vcs_abstraction._VCS_TYPES = {} self.assertEqual([], get_registered_vcs_types()) mock_class = Mock() register_vcs('foo', mock_class) self.assertEqual(mock_class, get_vcs('foo')) self.assertRaises(ValueError, get_vcs, 'bar') finally: vcstools.vcs_abstraction._VCS_TYPES = backup
def get_current_vcs(path="."): for vcs_type in vcs_abstraction.get_registered_vcs_types(): vcs = vcs_abstraction.get_vcs(vcs_type) if vcs.static_detect_presence(path): return vcs(path) raise Exception("Not found a valid VCS repository")