Skip to content

Commit caa0ea7

Browse files
committed
Merge branch 'cygwin' of https://github.com/ankostis/GitPython into ankostis-cygwin
2 parents afcd64e + cc77e6b commit caa0ea7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+961
-686
lines changed

.appveyor.yml

+24-19
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,17 @@ environment:
2121
IS_CONDA: "yes"
2222
GIT_PATH: "%GIT_DAEMON_PATH%"
2323

24-
# ## Cygwin
25-
# #
26-
# - PYTHON: "C:\\Miniconda-x64"
27-
# PYTHON_VERSION: "2.7"
28-
# IS_CONDA: "yes"
29-
# GIT_PATH: "%CYGWIN_GIT_PATH%"
30-
# - PYTHON: "C:\\Python34-x64"
31-
# PYTHON_VERSION: "3.4"
32-
# GIT_PATH: "%CYGWIN_GIT_PATH%"
33-
# - PYTHON: "C:\\Python35-x64"
34-
# PYTHON_VERSION: "3.5"
35-
# GIT_PATH: "%CYGWIN64_GIT_PATH%"
24+
## Cygwin
25+
#
26+
- PYTHON: "C:\\Miniconda-x64"
27+
PYTHON_VERSION: "2.7"
28+
IS_CONDA: "yes"
29+
IS_CYGWIN: "yes"
30+
GIT_PATH: "%CYGWIN_GIT_PATH%"
31+
- PYTHON: "C:\\Python35-x64"
32+
PYTHON_VERSION: "3.5"
33+
GIT_PATH: "%CYGWIN64_GIT_PATH%"
34+
IS_CYGWIN: "yes"
3635

3736

3837
install:
@@ -48,14 +47,12 @@ install:
4847
python --version
4948
python -c "import struct; print(struct.calcsize('P') * 8)"
5049
51-
- IF "%IS_CONDA%"=="yes" (
50+
- IF "%IS_CONDA%" == "yes" (
5251
conda info -a &
5352
conda install --yes --quiet pip
5453
)
55-
- pip install nose ddt wheel codecov
56-
- IF "%PYTHON_VERSION%"=="2.7" (
57-
pip install mock
58-
)
54+
- pip install -r test-requirements.txt
55+
- pip install codecov
5956

6057
## Copied from `init-tests-after-clone.sh`.
6158
#
@@ -79,7 +76,15 @@ install:
7976
build: false
8077

8178
test_script:
82-
- IF "%PYTHON_VERSION%"=="3.5" (nosetests -v --with-coverage) ELSE (nosetests -v)
79+
- IF "%IS_CYGWIN%" == "yes" (
80+
nosetests -v
81+
) ELSE (
82+
IF "%PYTHON_VERSION%" == "3.5" (
83+
nosetests -v --with-coverage
84+
) ELSE (
85+
nosetests -v
86+
)
87+
)
8388

8489
on_success:
85-
- IF "%PYTHON_VERSION%"=="3.5" (codecov)
90+
- IF "%PYTHON_VERSION%" == "3.5" IF NOT "%IS_CYGWIN%" == "yes" (codecov)

.travis.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
language: python
22
python:
3-
- "2.6"
43
- "2.7"
54
- "3.3"
65
- "3.4"
76
- "3.5"
87
# - "pypy" - won't work as smmap doesn't work (see gitdb/.travis.yml for details)
9-
matrix:
10-
allow_failures:
11-
- python: "2.6"
128
git:
139
# a higher depth is needed for most of the tests - must be high enough to not actually be shallow
1410
# as we clone our own repository in the process
@@ -17,7 +13,8 @@ install:
1713
- python --version; git --version
1814
- git submodule update --init --recursive
1915
- git fetch --tags
20-
- pip install codecov flake8 ddt sphinx
16+
- pip install -r test-requirements.txt
17+
- pip install codecov sphinx
2118

2219
# generate some reflog as git-python tests need it (in master)
2320
- ./init-tests-after-clone.sh

git/__init__.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66
# flake8: noqa
77
#@PydevCodeAnalysisIgnore
8+
import inspect
89
import os
910
import sys
10-
import inspect
11+
12+
import os.path as osp
13+
1114

1215
__version__ = 'git'
1316

@@ -16,7 +19,7 @@
1619
def _init_externals():
1720
"""Initialize external projects by putting them into the path"""
1821
if __version__ == 'git':
19-
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'ext', 'gitdb'))
22+
sys.path.insert(0, osp.join(osp.dirname(__file__), 'ext', 'gitdb'))
2023

2124
try:
2225
import gitdb

git/cmd.py

+21-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
)
3232
from git.exc import CommandError
3333
from git.odict import OrderedDict
34+
from git.util import is_cygwin_git, cygpath
3435

3536
from .exc import (
3637
GitCommandError,
@@ -191,8 +192,26 @@ def __setstate__(self, d):
191192
USE_SHELL = False
192193

193194
@classmethod
194-
def polish_url(cls, url):
195-
return url.replace("\\\\", "\\").replace("\\", "/")
195+
def is_cygwin(cls):
196+
return is_cygwin_git(cls.GIT_PYTHON_GIT_EXECUTABLE)
197+
198+
@classmethod
199+
def polish_url(cls, url, is_cygwin=None):
200+
if is_cygwin is None:
201+
is_cygwin = cls.is_cygwin()
202+
203+
if is_cygwin:
204+
url = cygpath(url)
205+
else:
206+
"""Remove any backslahes from urls to be written in config files.
207+
208+
Windows might create config-files containing paths with backslashed,
209+
but git stops liking them as it will escape the backslashes.
210+
Hence we undo the escaping just to be sure.
211+
"""
212+
url = url.replace("\\\\", "\\").replace("\\", "/")
213+
214+
return url
196215

197216
class AutoInterrupt(object):
198217
"""Kill/Interrupt the stored process instance once this instance goes out of scope. It is

git/config.py

+20-16
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,13 @@
66
"""Module containing module parser implementation able to properly read and write
77
configuration files"""
88

9-
import re
10-
try:
11-
import ConfigParser as cp
12-
except ImportError:
13-
# PY3
14-
import configparser as cp
9+
import abc
10+
from functools import wraps
1511
import inspect
1612
import logging
17-
import abc
1813
import os
14+
import re
1915

20-
from functools import wraps
21-
22-
from git.odict import OrderedDict
23-
from git.util import LockFile
2416
from git.compat import (
2517
string_types,
2618
FileType,
@@ -29,6 +21,18 @@
2921
with_metaclass,
3022
PY3
3123
)
24+
from git.odict import OrderedDict
25+
from git.util import LockFile
26+
27+
import os.path as osp
28+
29+
30+
try:
31+
import ConfigParser as cp
32+
except ImportError:
33+
# PY3
34+
import configparser as cp
35+
3236

3337
__all__ = ('GitConfigParser', 'SectionConstraint')
3438

@@ -408,15 +412,15 @@ def read(self):
408412
if self._has_includes():
409413
for _, include_path in self.items('include'):
410414
if include_path.startswith('~'):
411-
include_path = os.path.expanduser(include_path)
412-
if not os.path.isabs(include_path):
415+
include_path = osp.expanduser(include_path)
416+
if not osp.isabs(include_path):
413417
if not file_ok:
414418
continue
415419
# end ignore relative paths if we don't know the configuration file path
416-
assert os.path.isabs(file_path), "Need absolute paths to be sure our cycle checks will work"
417-
include_path = os.path.join(os.path.dirname(file_path), include_path)
420+
assert osp.isabs(file_path), "Need absolute paths to be sure our cycle checks will work"
421+
include_path = osp.join(osp.dirname(file_path), include_path)
418422
# end make include path absolute
419-
include_path = os.path.normpath(include_path)
423+
include_path = osp.normpath(include_path)
420424
if include_path in seen or not os.access(include_path, os.R_OK):
421425
continue
422426
seen.add(include_path)

git/db.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
"""Module with our own gitdb implementation - it uses the git command"""
2+
from git.util import bin_to_hex, hex_to_bin
23
from gitdb.base import (
34
OInfo,
45
OStream
56
)
6-
from gitdb.util import (
7-
bin_to_hex,
8-
hex_to_bin
9-
)
107
from gitdb.db import GitDB # @UnusedImport
118
from gitdb.db import LooseObjectDB
129

git/diff.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66
import re
77

8-
from gitdb.util import hex_to_bin
8+
from git.cmd import handle_process_output
9+
from git.compat import (
10+
defenc,
11+
PY3
12+
)
13+
from git.util import finalize_process, hex_to_bin
914

1015
from .compat import binary_type
1116
from .objects.blob import Blob
1217
from .objects.util import mode_str_to_int
1318

14-
from git.compat import (
15-
defenc,
16-
PY3
17-
)
18-
from git.cmd import handle_process_output
19-
from git.util import finalize_process
2019

2120
__all__ = ('Diffable', 'DiffIndex', 'Diff', 'NULL_TREE')
2221

0 commit comments

Comments
 (0)