def detect_hg_repository(self, path=None): if path is None: path = getcwd() hg_repository = is_hg_installed() and get_vcs_root(path) is not None self.hg_manifest.setEnabled(hg_repository) if not hg_repository and self.hg_manifest.isChecked(): self.custom_dir.setChecked(True)
def find_files_in_hg_manifest(self): p = programs.run_shell_command('hg manifest', cwd=self.rootpath) hgroot = get_vcs_root(self.rootpath) self.pathlist = [hgroot] for path in p.stdout.read().decode().splitlines(): with QMutexLocker(self.mutex): if self.stopped: return False dirname = osp.dirname(path) try: if re.search(self.exclude, dirname+os.sep): continue filename = osp.basename(path) if re.search(self.exclude, filename): continue if re.search(self.include, filename): self.filenames.append(osp.join(hgroot, path)) except re.error: self.error_flag = _("invalid regular expression") return False return True
def test_git_revision(): root = get_vcs_root(osp.dirname(__file__)) assert get_git_revision(osp.dirname(__file__)) == (None, None) assert all([isinstance(x, str) for x in get_git_revision(root)])
def test_vcs_root(tmpdir): directory = tmpdir.mkdir('foo') assert get_vcs_root(str(directory)) == None assert get_vcs_root(osp.dirname(__file__)) != None
import os.path as osp import sys # Test library imports from spyder.utils import programs import pytest # Local imports from spyder.utils.vcs import (ActionToolNotFound, get_git_refs, get_git_remotes, get_git_revision, get_vcs_root, remote_to_url, run_vcs_tool) HERE = os.path.abspath(os.path.dirname(__file__)) skipnogit = pytest.mark.skipif(not(get_vcs_root(HERE)), reason="Not running from a git repo") @skipnogit @pytest.mark.skipif(os.environ.get('CI', None) is None, reason="Not to be run outside of CIs") def test_vcs_tool(): if not os.name == 'nt': with pytest.raises(ActionToolNotFound): run_vcs_tool(osp.dirname(__file__), 'browse') else: assert run_vcs_tool(osp.dirname(__file__), 'browse') assert run_vcs_tool(osp.dirname(__file__), 'commit')