Skip to content

Update versions #706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ nbproject
.DS_Store
/*egg-info
/.tox
.idea
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ If it is not in your `PATH`, you can help GitPython find it by setting
the `GIT_PYTHON_GIT_EXECUTABLE=<path/to/git>` environment variable.

* Git (1.7.x or newer)
* Python 2.7 to 3.5, while python 2.6 is supported on a *best-effort basis*.
* Python 2.7 to 3.6, while python 2.6 is supported on a *best-effort basis*.

The list of dependencies are listed in `./requirements.txt` and `./test-requirements.txt`.
The installer takes care of installing them for you.
Expand Down Expand Up @@ -125,7 +125,7 @@ Please have a look at the [contributions file][contributing].

### How to verify a release

Please only use releases from `pypi` as you can verify the respective source
Please only use releases from `pypi` as you can verify the respective source
tarballs.

This script shows how to verify the tarball was indeed created by the authors of
Expand Down
2 changes: 1 addition & 1 deletion git/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,5 +309,5 @@ def register_surrogateescape():

try:
b"100644 \x9f\0aaa".decode(defenc, "surrogateescape")
except:
except Exception:
register_surrogateescape()
10 changes: 5 additions & 5 deletions git/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,16 +313,16 @@ def __str__(self):
h %= self.b_blob.path

msg = ''
l = None # temp line
temp_line = None
ll = 0 # line length
for b, n in zip((self.a_blob, self.b_blob), ('lhs', 'rhs')):
if b:
l = "\n%s: %o | %s" % (n, b.mode, b.hexsha)
temp_line = "\n%s: %o | %s" % (n, b.mode, b.hexsha)
else:
l = "\n%s: None" % n
temp_line = "\n%s: None" % n
# END if blob is not None
ll = max(len(l), ll)
msg += l
ll = max(len(temp_line), ll)
msg += temp_line
# END for each blob

# add headline
Expand Down
2 changes: 1 addition & 1 deletion git/exc.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, command, status=None, stderr=None, stdout=None):
else:
try:
status = u'exit code(%s)' % int(status)
except:
except Exception:
s = safe_decode(str(status))
status = u"'%s'" % s if isinstance(status, string_types) else s

Expand Down
2 changes: 1 addition & 1 deletion git/refs/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def to_file(self, filepath):
try:
self._serialize(fp)
lfd.commit()
except:
except Exception:
# on failure it rolls back automatically, but we make it clear
lfd.rollback()
raise
Expand Down
8 changes: 5 additions & 3 deletions git/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,9 +542,11 @@ def urls(self):
if ' Push URL:' in line:
yield line.split(': ')[-1]
except GitCommandError as ex:
if any([msg in str(ex) for msg in ['correct access rights','cannot run ssh']]):
# If ssh is not setup to access this repository, see issue 694
result = Git().execute(['git','config','--get','remote.%s.url' % self.name])
if any([msg in str(ex) for msg in ['correct access rights',
'cannot run ssh']]):
# If ssh is not setup to access this repository, see issue 694
result = Git().execute(['git', 'config', '--get',
'remote.%s.url' % self.name])
yield result
else:
raise ex
Expand Down
12 changes: 3 additions & 9 deletions git/repo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import logging
import os
import re
import sys
import warnings

from git.cmd import (
Expand Down Expand Up @@ -40,11 +39,6 @@

log = logging.getLogger(__name__)

DefaultDBType = GitCmdObjectDB
if sys.version_info[:2] < (2, 5): # python 2.4 compatibility
DefaultDBType = GitCmdObjectDB
# END handle python 2.4

BlameEntry = namedtuple('BlameEntry', ['commit', 'linenos', 'orig_path', 'orig_linenos'])


Expand Down Expand Up @@ -88,7 +82,7 @@ class Repo(object):
# Subclasses may easily bring in their own custom types by placing a constructor or type here
GitCommandWrapperType = Git

def __init__(self, path=None, odbt=DefaultDBType, search_parent_directories=False, expand_vars=True):
def __init__(self, path=None, odbt=GitCmdObjectDB, search_parent_directories=False, expand_vars=True):
"""Create a new Repo instance

:param path:
Expand Down Expand Up @@ -203,7 +197,7 @@ def __exit__(self, exc_type, exc_value, traceback):
def __del__(self):
try:
self.close()
except:
except Exception:
pass

def close(self):
Expand Down Expand Up @@ -869,7 +863,7 @@ def blame(self, rev, file, incremental=False, **kwargs):
return blames

@classmethod
def init(cls, path=None, mkdir=True, odbt=DefaultDBType, expand_vars=True, **kwargs):
def init(cls, path=None, mkdir=True, odbt=GitCmdObjectDB, expand_vars=True, **kwargs):
"""Initialize a git repository at the given path if specified

:param path:
Expand Down
4 changes: 2 additions & 2 deletions git/test/lib/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def repo_creator(self):
try:
try:
return func(self, rw_repo)
except:
except Exception:
log.info("Keeping repo after failure: %s", repo_dir)
repo_dir = None
raise
Expand Down Expand Up @@ -296,7 +296,7 @@ def remote_repo_creator(self):
with cwd(rw_repo.working_dir):
try:
return func(self, rw_repo, rw_daemon_repo)
except:
except Exception:
log.info("Keeping repos after failure: \n rw_repo_dir: %s \n rw_daemon_repo_dir: %s",
rw_repo_dir, rw_daemon_repo_dir)
rw_repo_dir = rw_daemon_repo_dir = None
Expand Down
4 changes: 2 additions & 2 deletions git/test/test_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ def test_traversal(self):
# at some point, both iterations should stop
self.assertEqual(list(bfirst)[-1], first)
stoptraverse = self.rorepo.commit("254d04aa3180eb8b8daf7b7ff25f010cd69b4e7d").traverse(as_edge=True)
l = list(stoptraverse)
self.assertEqual(len(l[0]), 2)
traverse_list = list(stoptraverse)
self.assertEqual(len(traverse_list[0]), 2)

# ignore self
self.assertEqual(next(start.traverse(ignore_self=False)), start)
Expand Down
2 changes: 1 addition & 1 deletion git/test/test_submodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,4 +920,4 @@ class Repo(object):
submodule_path = 'D:\\submodule_path'
relative_path = Submodule._to_relative_path(super_repo, submodule_path)
msg = '_to_relative_path should be "submodule_path" but was "%s"' % relative_path
assert relative_path == 'submodule_path', msg
assert relative_path == 'submodule_path', msg
54 changes: 27 additions & 27 deletions git/test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,49 +217,49 @@ def test_actor(self):
@ddt.data(('name', ''), ('name', 'prefix_'))
def test_iterable_list(self, case):
name, prefix = case
l = IterableList(name, prefix)
iter_list = IterableList(name, prefix)

name1 = "one"
name2 = "two"
m1 = TestIterableMember(prefix + name1)
m2 = TestIterableMember(prefix + name2)

l.extend((m1, m2))
iter_list.extend((m1, m2))

self.assertEqual(len(l), 2)
self.assertEqual(len(iter_list), 2)

# contains works with name and identity
self.assertIn(name1, l)
self.assertIn(name2, l)
self.assertIn(m2, l)
self.assertIn(m2, l)
self.assertNotIn('invalid', l)
self.assertIn(name1, iter_list)
self.assertIn(name2, iter_list)
self.assertIn(m2, iter_list)
self.assertIn(m2, iter_list)
self.assertNotIn('invalid', iter_list)

# with string index
self.assertIs(l[name1], m1)
self.assertIs(l[name2], m2)
self.assertIs(iter_list[name1], m1)
self.assertIs(iter_list[name2], m2)

# with int index
self.assertIs(l[0], m1)
self.assertIs(l[1], m2)
self.assertIs(iter_list[0], m1)
self.assertIs(iter_list[1], m2)

# with getattr
self.assertIs(l.one, m1)
self.assertIs(l.two, m2)
self.assertIs(iter_list.one, m1)
self.assertIs(iter_list.two, m2)

# test exceptions
self.failUnlessRaises(AttributeError, getattr, l, 'something')
self.failUnlessRaises(IndexError, l.__getitem__, 'something')
self.failUnlessRaises(AttributeError, getattr, iter_list, 'something')
self.failUnlessRaises(IndexError, iter_list.__getitem__, 'something')

# delete by name and index
self.failUnlessRaises(IndexError, l.__delitem__, 'something')
del(l[name2])
self.assertEqual(len(l), 1)
self.assertNotIn(name2, l)
self.assertIn(name1, l)
del(l[0])
self.assertNotIn(name1, l)
self.assertEqual(len(l), 0)

self.failUnlessRaises(IndexError, l.__delitem__, 0)
self.failUnlessRaises(IndexError, l.__delitem__, 'something')
self.failUnlessRaises(IndexError, iter_list.__delitem__, 'something')
del(iter_list[name2])
self.assertEqual(len(iter_list), 1)
self.assertNotIn(name2, iter_list)
self.assertIn(name1, iter_list)
del(iter_list[0])
self.assertNotIn(name1, iter_list)
self.assertEqual(len(iter_list), 0)

self.failUnlessRaises(IndexError, iter_list.__delitem__, 0)
self.failUnlessRaises(IndexError, iter_list.__delitem__, 'something')
6 changes: 3 additions & 3 deletions git/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def assure_directory_exists(path, is_file=False):
def _get_exe_extensions():
try:
winprog_exts = tuple(p.upper() for p in os.environ['PATHEXT'].split(os.pathsep))
except:
except Exception:
winprog_exts = ('.BAT', 'COM', '.EXE')

return winprog_exts
Expand All @@ -200,7 +200,7 @@ def py_where(program, path=None):
# From: http://stackoverflow.com/a/377028/548792
try:
winprog_exts = tuple(p.upper() for p in os.environ['PATHEXT'].split(os.pathsep))
except:
except Exception:
winprog_exts = is_win and ('.BAT', 'COM', '.EXE') or ()

def is_exec(fpath):
Expand Down Expand Up @@ -347,7 +347,7 @@ def expand_path(p, expand_vars=True):
if expand_vars:
p = osp.expandvars(p)
return osp.normpath(osp.abspath(p))
except:
except Exception:
return None

#} END utilities
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def _stamp_version(filename):
package_data={'git.test': ['fixtures/*']},
package_dir={'git': 'git'},
license="BSD License",
python_requires='>=2.6, !=3.0.*, !=3.1.*, !=3.2.*',
requires=['gitdb2 (>=2.0.0)'],
install_requires=install_requires,
test_requirements=test_requires + install_requires,
Expand Down