diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2016-10-22 11:11:25 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2016-10-22 11:11:25 +0200 |
commit | caa0ea7a0893fe90ea043843d4e6ad407126d7b8 (patch) | |
tree | 2f688eb182f2e76091134c47c4a327681c12e15b /git/test/test_repo.py | |
parent | afcd64ebbb770908bd2a751279ff070dea5bb97c (diff) | |
parent | cc77e6b2862733a211c55cf29cc7a83c36c27919 (diff) | |
download | gitpython-caa0ea7a0893fe90ea043843d4e6ad407126d7b8.tar.gz |
Merge branch 'cygwin' of https://github.com/ankostis/GitPython into ankostis-cygwin
Diffstat (limited to 'git/test/test_repo.py')
-rw-r--r-- | git/test/test_repo.py | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/git/test/test_repo.py b/git/test/test_repo.py index a0a6a5b0..8b644f7f 100644 --- a/git/test/test_repo.py +++ b/git/test/test_repo.py @@ -50,10 +50,9 @@ from git.test.lib import ( assert_true, raises ) -from git.util import HIDE_WINDOWS_KNOWN_ERRORS +from git.util import HIDE_WINDOWS_KNOWN_ERRORS, cygpath from git.test.lib import with_rw_directory -from git.util import join_path_native, rmtree, rmfile -from gitdb.util import bin_to_hex +from git.util import join_path_native, rmtree, rmfile, bin_to_hex from unittest import SkipTest import functools as fnt @@ -203,8 +202,8 @@ class TestRepo(TestBase): prev_cwd = os.getcwd() os.chdir(tempfile.gettempdir()) git_dir_rela = "repos/foo/bar.git" - del_dir_abs = os.path.abspath("repos") - git_dir_abs = os.path.abspath(git_dir_rela) + del_dir_abs = osp.abspath("repos") + git_dir_abs = osp.abspath(git_dir_rela) try: # with specific path for path in (git_dir_rela, git_dir_abs): @@ -212,7 +211,7 @@ class TestRepo(TestBase): self.assertIsInstance(r, Repo) assert r.bare is True assert not r.has_separate_working_tree() - assert os.path.isdir(r.git_dir) + assert osp.isdir(r.git_dir) self._assert_empty_repo(r) @@ -306,16 +305,16 @@ class TestRepo(TestBase): def test_is_dirty_with_path(self, rwrepo): assert rwrepo.is_dirty(path="git") is False - with open(os.path.join(rwrepo.working_dir, "git", "util.py"), "at") as f: + with open(osp.join(rwrepo.working_dir, "git", "util.py"), "at") as f: f.write("junk") assert rwrepo.is_dirty(path="git") is True assert rwrepo.is_dirty(path="doc") is False - rwrepo.git.add(os.path.join("git", "util.py")) + rwrepo.git.add(Git.polish_url(osp.join("git", "util.py"))) assert rwrepo.is_dirty(index=False, path="git") is False assert rwrepo.is_dirty(path="git") is True - with open(os.path.join(rwrepo.working_dir, "doc", "no-such-file.txt"), "wt") as f: + with open(osp.join(rwrepo.working_dir, "doc", "no-such-file.txt"), "wt") as f: f.write("junk") assert rwrepo.is_dirty(path="doc") is False assert rwrepo.is_dirty(untracked_files=True, path="doc") is True @@ -412,6 +411,14 @@ class TestRepo(TestBase): self.assertEqual(len(res), 1) self.assertEqual(len(res[0][1]), 83, "Unexpected amount of parsed blame lines") + @skipIf(HIDE_WINDOWS_KNOWN_ERRORS and Git.is_cygwin(), + """FIXME: File "C:\projects\gitpython\git\cmd.py", line 671, in execute + raise GitCommandError(command, status, stderr_value, stdout_value) + GitCommandError: Cmd('git') failed due to: exit code(128) + cmdline: git add 1__��ava verb��ten 1_test _myfile 1_test_other_file + 1_��ava-----verb��ten + stderr: 'fatal: pathspec '"1__çava verböten"' did not match any files' + """) @with_rw_repo('HEAD', bare=False) def test_untracked_files(self, rwrepo): for run, (repo_add, is_invoking_git) in enumerate(( @@ -494,10 +501,10 @@ class TestRepo(TestBase): ph = os.environ.get('HOME') try: os.environ['HOME'] = rw_dir - Repo.init(os.path.join('~', 'test.git'), bare=True) + Repo.init(osp.join('~', 'test.git'), bare=True) os.environ['FOO'] = rw_dir - Repo.init(os.path.join('$FOO', 'test.git'), bare=True) + Repo.init(osp.join('$FOO', 'test.git'), bare=True) finally: if ph: os.environ['HOME'] = ph @@ -785,7 +792,7 @@ class TestRepo(TestBase): @with_rw_repo('HEAD') def test_git_file(self, rwrepo): # Move the .git directory to another location and create the .git file. - real_path_abs = os.path.abspath(join_path_native(rwrepo.working_tree_dir, '.real')) + real_path_abs = osp.abspath(join_path_native(rwrepo.working_tree_dir, '.real')) os.rename(rwrepo.git_dir, real_path_abs) git_file_path = join_path_native(rwrepo.working_tree_dir, '.git') with open(git_file_path, 'wb') as fp: @@ -793,13 +800,13 @@ class TestRepo(TestBase): # Create a repo and make sure it's pointing to the relocated .git directory. git_file_repo = Repo(rwrepo.working_tree_dir) - self.assertEqual(os.path.abspath(git_file_repo.git_dir), real_path_abs) + self.assertEqual(osp.abspath(git_file_repo.git_dir), real_path_abs) # Test using an absolute gitdir path in the .git file. with open(git_file_path, 'wb') as fp: fp.write(('gitdir: %s\n' % real_path_abs).encode('ascii')) git_file_repo = Repo(rwrepo.working_tree_dir) - self.assertEqual(os.path.abspath(git_file_repo.git_dir), real_path_abs) + self.assertEqual(osp.abspath(git_file_repo.git_dir), real_path_abs) @skipIf(HIDE_WINDOWS_KNOWN_ERRORS and PY3, "FIXME: smmp fails with: TypeError: Can't convert 'bytes' object to str implicitly") @@ -840,7 +847,7 @@ class TestRepo(TestBase): # It's expected to not be able to access a tree self.failUnlessRaises(ValueError, r.tree) - new_file_path = os.path.join(rw_dir, "new_file.ext") + new_file_path = osp.join(rw_dir, "new_file.ext") touch(new_file_path) r.index.add([new_file_path]) r.index.commit("initial commit\nBAD MESSAGE 1\n") @@ -901,9 +908,6 @@ class TestRepo(TestBase): for i, j in itertools.permutations([c1, 'ffffff', ''], r=2): self.assertRaises(GitCommandError, repo.is_ancestor, i, j) - # @skipIf(HIDE_WINDOWS_KNOWN_ERRORS, - # "FIXME: helper.wrapper fails with: PermissionError: [WinError 5] Access is denied: " - # "'C:\\Users\\appveyor\\AppData\\Local\\Temp\\1\\test_work_tree_unsupportedryfa60di\\master_repo\\.git\\objects\\pack\\pack-bc9e0787aef9f69e1591ef38ea0a6f566ec66fe3.idx") # noqa E501 @with_rw_directory def test_work_tree_unsupported(self, rw_dir): git = Git(rw_dir) @@ -913,6 +917,8 @@ class TestRepo(TestBase): rw_master = self.rorepo.clone(join_path_native(rw_dir, 'master_repo')) rw_master.git.checkout('HEAD~10') worktree_path = join_path_native(rw_dir, 'worktree_repo') + if Git.is_cygwin(): + worktree_path = cygpath(worktree_path) try: rw_master.git.worktree('add', worktree_path, 'master') except Exception as ex: |