◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
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:
register_surrogateescape()
14 changes: 7 additions & 7 deletions git/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,20 +313,20 @@ def __str__(self):
h %= self.b_blob.path

msg = ''
l = None # temp line
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)
else:
l = "\n%s: None" % n
# END if blob is not None
ll = max(len(l), ll)
msg += l
# END for each blob

# add headline
h += '\n' + '=' * ll

if self.deleted_file:
msg += '\nfile deleted in rhs'
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:
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:
# 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])
yield result
else:
raise ex
Expand Down
2 changes: 1 addition & 1 deletion git/repo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def __exit__(self, exc_type, exc_value, traceback):
def __del__(self):
try:
self.close()
except:
pass

def close(self):
Expand Down
6 changes: 3 additions & 3 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:
log.info("Keeping repo after failure: %s", repo_dir)
repo_dir = None
raise
Expand Down Expand Up @@ -227,7 +227,7 @@ def with_rw_and_rw_remote_repo(working_tree_ref):
Same as with_rw_repo, but also provides a writable remote repository from which the
rw_repo has been forked as well as a handle for a git-daemon that may be started to
run the remote_repo.
The remote repository was cloned as bare repository from the rorepo, whereas
the rw repo has a working tree and was cloned from the remote repository.

remote_repo has two remotes: origin and daemon_origin. One uses a local url,
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:
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
3 changes: 1 addition & 2 deletions git/test/test_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ 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)

# 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
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)

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

l.extend((m1, m2))

self.assertEqual(len(l), 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)

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

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

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

# test exceptions
self.failUnlessRaises(AttributeError, getattr, l, 'something')
self.failUnlessRaises(IndexError, l.__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')
17 changes: 6 additions & 11 deletions git/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,20 +188,15 @@ 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:
winprog_exts = ('.BAT', 'COM', '.EXE')

return winprog_exts


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:
winprog_exts = is_win and ('.BAT', 'COM', '.EXE') or ()

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

#} END utilities
Expand Down
Toggle all file notes Toggle all file annotations