summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKostis Anagnostopoulos <ankostis@gmail.com>2016-10-01 12:12:19 +0200
committerKostis Anagnostopoulos <ankostis@gmail.com>2016-10-01 12:26:07 +0200
commit13d399f4460ecb17cecc59d7158a4159010b2ac5 (patch)
tree7d21abf15454194b1c86599f17b960c6d4ba1670
parentd84b960982b5bad0b3c78c4a680638824924004b (diff)
downloadgitpython-13d399f4460ecb17cecc59d7158a4159010b2ac5.tar.gz
ci: restore ci log-level to normal, coverage on Win-Appveyor
+ Extract util-method to delete lock-files, also on Windows (will be needed by TCs).
-rw-r--r--.appveyor.yml2
-rw-r--r--.travis.yml2
-rw-r--r--git/test/test_config.py8
-rw-r--r--git/util.py53
4 files changed, 34 insertions, 31 deletions
diff --git a/.appveyor.yml b/.appveyor.yml
index f349d1ff..47bd1f0b 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -77,7 +77,7 @@ install:
build: false
test_script:
- - nosetests -vvvs --logging-level=DEBUG
+ - nosetests --with-coverage
#on_success:
# - IF "%PYTHON_VERSION%"=="3.4" (coveralls)
diff --git a/.travis.yml b/.travis.yml
index 63686011..ab766e7c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -31,7 +31,7 @@ script:
# Make sure we limit open handles to see if we are leaking them
- ulimit -n 96
- ulimit -n
- - nosetests -vvvs --with-coverage --logging-level=DEBUG
+ - nosetests --with-coverage
- if [ "$TRAVIS_PYTHON_VERSION" == '3.4' ]; then flake8; fi
- if [ "$TRAVIS_PYTHON_VERSION" == '3.5' ]; then cd doc && make html; fi
-
diff --git a/git/test/test_config.py b/git/test/test_config.py
index b807413b..bd2bad0a 100644
--- a/git/test/test_config.py
+++ b/git/test/test_config.py
@@ -12,8 +12,7 @@ from git import (
GitConfigParser
)
from git.compat import (
- string_types,
- is_win,)
+ string_types)
from git.config import cp
from git.test.lib import (
TestCase,
@@ -22,6 +21,7 @@ from git.test.lib import (
from git.test.lib import with_rw_directory
import os.path as osp
+from git.util import rmfile
_tc_lock_fpaths = osp.join(osp.dirname(__file__), 'fixtures/*.lock')
@@ -29,9 +29,7 @@ _tc_lock_fpaths = osp.join(osp.dirname(__file__), 'fixtures/*.lock')
def _rm_lock_files():
for lfp in glob.glob(_tc_lock_fpaths):
- if is_win and osp.isfile(lfp):
- os.chmod(lfp, 0o777)
- os.remove(lfp)
+ rmfile(lfp)
class TestBase(TestCase):
diff --git a/git/util.py b/git/util.py
index f6f6dea9..87ef38d3 100644
--- a/git/util.py
+++ b/git/util.py
@@ -5,37 +5,39 @@
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
from __future__ import unicode_literals
+import getpass
+import logging
import os
+import platform
import re
-import time
-import stat
import shutil
-import platform
-import getpass
-import logging
+import stat
+import time
-# NOTE: Some of the unused imports might be used/imported by others.
-# Handle once test-cases are back up and running.
-from .exc import InvalidGitRepositoryError
+from git.compat import is_win
+from gitdb.util import ( # NOQA
+ make_sha,
+ LockedFD,
+ file_contents_ro,
+ LazyMixin,
+ to_hex_sha,
+ to_bin_sha
+)
+
+import os.path as osp
from .compat import (
MAXSIZE,
defenc,
PY3
)
+from .exc import InvalidGitRepositoryError
+
+# NOTE: Some of the unused imports might be used/imported by others.
+# Handle once test-cases are back up and running.
# Most of these are unused here, but are for use by git-python modules so these
# don't see gitdb all the time. Flake of course doesn't like it.
-from gitdb.util import (# NOQA
- make_sha,
- LockedFD,
- file_contents_ro,
- LazyMixin,
- to_hex_sha,
- to_bin_sha
-)
-from git.compat import is_win
-
__all__ = ("stream_copy", "join_path", "to_native_path_windows", "to_native_path_linux",
"join_path_native", "Stats", "IndexFileSHA1Writer", "Iterable", "IterableList",
"BlockingLockFile", "LockFile", 'Actor', 'get_user_id', 'assure_directory_exists',
@@ -72,6 +74,14 @@ def rmtree(path):
return shutil.rmtree(path, False, onerror)
+def rmfile(path):
+ """Ensure file deleted also on *Windows* where read-only files need special treatment."""
+ if osp.isfile(path):
+ if is_win:
+ os.chmod(path, 0o777)
+ os.remove(path)
+
+
def stream_copy(source, destination, chunk_size=512 * 1024):
"""Copy all data from the source stream into the destination stream in chunks
of size chunk_size
@@ -585,12 +595,7 @@ class LockFile(object):
# instead of failing, to make it more usable.
lfp = self._lock_file_path()
try:
- # on bloody windows, the file needs write permissions to be removable.
- # Why ...
- if is_win:
- os.chmod(lfp, 0o777)
- # END handle win32
- os.remove(lfp)
+ rmfile(lfp)
except OSError:
pass
self._owns_lock = False