|
7 | 7 |
|
8 | 8 | fromioimportBytesIO |
9 | 9 | importos |
| 10 | +importos.pathasosp |
| 11 | +frompathlibimportPath |
10 | 12 | fromstatimportS_ISLNK,ST_MODE |
11 | | -importtempfile |
12 | | -fromunittestimportskipIf |
13 | 13 | importshutil |
| 14 | +importtempfile |
| 15 | + |
| 16 | +importpytest |
14 | 17 |
|
15 | 18 | fromgitimport ( |
16 | 19 | IndexFile, |
|
28 | 31 | fromgit.index.funimporthook_path |
29 | 32 | fromgit.index.typimportBaseIndexEntry,IndexEntry |
30 | 33 | fromgit.objectsimportBlob |
31 | | -fromtest.libimportTestBase,fixture_path,fixture,with_rw_repo |
32 | | -fromtest.libimportwith_rw_directory |
33 | | -fromgit.utilimportActor,rmtree |
34 | | -fromgit.utilimportHIDE_WINDOWS_KNOWN_ERRORS,hex_to_bin |
| 34 | +fromtest.libimportTestBase,fixture,fixture_path,with_rw_directory,with_rw_repo |
| 35 | +fromgit.utilimportActor,hex_to_bin,rmtree |
35 | 36 | fromgitdb.baseimportIStream |
36 | 37 |
|
37 | | -importos.pathasosp |
38 | | -fromgit.cmdimportGit |
| 38 | +HOOKS_SHEBANG="#!/usr/bin/env sh\n" |
39 | 39 |
|
40 | | -frompathlibimportPath |
41 | 40 |
|
42 | | -HOOKS_SHEBANG="#!/usr/bin/env sh\n" |
| 41 | +def_found_in(cmd,directory): |
| 42 | +"""Check if a command is resolved in a directory (without following symlinks).""" |
| 43 | +path=shutil.which(cmd) |
| 44 | +returnpathandPath(path).parent==Path(directory) |
| 45 | + |
43 | 46 |
|
44 | 47 | is_win_without_bash=is_winandnotshutil.which("bash.exe") |
45 | 48 |
|
| 49 | +is_win_with_wsl_bash=is_winand_found_in( |
| 50 | +cmd="bash.exe", |
| 51 | +directory=Path(os.getenv("WINDIR"))/"System32", |
| 52 | +) |
| 53 | + |
46 | 54 |
|
47 | 55 | def_make_hook(git_dir,name,content,make_exec=True): |
48 | 56 | """A helper to create a hook""" |
@@ -422,14 +430,6 @@ def _count_existing(self, repo, files): |
422 | 430 |
|
423 | 431 | # END num existing helper |
424 | 432 |
|
425 | | -@skipIf( |
426 | | -HIDE_WINDOWS_KNOWN_ERRORSandGit.is_cygwin(), |
427 | | -"""FIXME: File "C:\\projects\\gitpython\\git\\test\\test_index.py", line 642, in test_index_mutation |
428 | | - self.assertEqual(fd.read(), link_target) |
429 | | - AssertionError: '!<symlink>\xff\xfe/\x00e\x00t\x00c\x00/\x00t\x00h\x00a\x00t\x00\x00\x00' |
430 | | - != '/etc/that' |
431 | | - """, |
432 | | - ) |
433 | 433 | @with_rw_repo("0.1.6") |
434 | 434 | deftest_index_mutation(self,rw_repo): |
435 | 435 | index=rw_repo.index |
@@ -910,7 +910,11 @@ def test_pre_commit_hook_fail(self, rw_repo): |
910 | 910 | else: |
911 | 911 | raiseAssertionError("Should have caught a HookExecutionError") |
912 | 912 |
|
913 | | -@skipIf(HIDE_WINDOWS_KNOWN_ERRORS,"TODO: fix hooks execution on Windows: #703") |
| 913 | +@pytest.mark.xfail( |
| 914 | +is_win_without_bashoris_win_with_wsl_bash, |
| 915 | +reason="Specifically seems to fail on WSL bash (in spite of #1399)", |
| 916 | +raises=AssertionError, |
| 917 | + ) |
914 | 918 | @with_rw_repo("HEAD",bare=True) |
915 | 919 | deftest_commit_msg_hook_success(self,rw_repo): |
916 | 920 | commit_message="commit default head by Frèderic Çaufl€" |
|