summaryrefslogtreecommitdiff
path: root/git/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'git/util.py')
-rw-r--r--git/util.py29
1 files changed, 20 insertions, 9 deletions
diff --git a/git/util.py b/git/util.py
index 814cd7f4..c96a6b08 100644
--- a/git/util.py
+++ b/git/util.py
@@ -14,14 +14,16 @@ import shutil
import stat
import time
+from functools import wraps
+
from git.compat import is_win
-from gitdb.util import ( # NOQA
+from gitdb.util import ( # NOQA
make_sha,
- LockedFD,
- file_contents_ro,
- LazyMixin,
- to_hex_sha,
- to_bin_sha
+ LockedFD, # @UnusedImport
+ file_contents_ro, # @UnusedImport
+ LazyMixin, # @UnusedImport
+ to_hex_sha, # @UnusedImport
+ to_bin_sha # @UnusedImport
)
import os.path as osp
@@ -32,6 +34,7 @@ from .compat import (
PY3
)
from .exc import InvalidGitRepositoryError
+from unittest.case import SkipTest
# NOTE: Some of the unused imports might be used/imported by others.
@@ -50,13 +53,13 @@ def unbare_repo(func):
"""Methods with this decorator raise InvalidGitRepositoryError if they
encounter a bare repository"""
+ @wraps(func)
def wrapper(self, *args, **kwargs):
if self.repo.bare:
raise InvalidGitRepositoryError("Method '%s' cannot operate on bare repositories" % func.__name__)
# END bare method
return func(self, *args, **kwargs)
# END wrapper
- wrapper.__name__ = func.__name__
return wrapper
@@ -69,7 +72,15 @@ def rmtree(path):
def onerror(func, path, exc_info):
# Is the error an access error ?
os.chmod(path, stat.S_IWUSR)
- func(path) # Will scream if still not possible to delete.
+
+ try:
+ func(path) # Will scream if still not possible to delete.
+ except Exception as ex:
+ from git.test.lib.helper import HIDE_WINDOWS_KNOWN_ERRORS
+ if HIDE_WINDOWS_KNOWN_ERRORS:
+ raise SkipTest("FIXME: fails with: PermissionError\n %s", ex)
+ else:
+ raise
return shutil.rmtree(path, False, onerror)
@@ -240,7 +251,7 @@ class RemoteProgress(object):
# END could not get match
op_code = 0
- remote, op_name, percent, cur_count, max_count, message = match.groups()
+ remote, op_name, percent, cur_count, max_count, message = match.groups() # @UnusedVariable
# get operation id
if op_name == "Counting objects":