Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

BF (codename "happy travis"): trying to address lints etc to make Travis green again#702

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Byron merged 14 commits intogitpython-developers:masterfromyarikoptic:bf-happy-travis
Dec 11, 2017
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
14 commits
Select commitHold shift + click to select a range
6ee08fc
RF: primarily flake8 lints + minor RF to reduce duplication in PATHEXT
yarikopticNov 28, 2017
086af07
BF(PY26): {} -> {0}, i.e. explicit index for .format()
yarikopticNov 28, 2017
e1aea3a
BF: crazy tests ppl pass an object for status... uff -- catch TypeErr…
yarikopticNov 28, 2017
c352dba
RF: last of flake8 fails - avoid using temp variable in a test
yarikopticNov 28, 2017
42e89cc
RF(+BF?): refactor hooks creation in a test, and may be make it compa…
yarikopticNov 28, 2017
d723148
ENH: add appveyor recipe to establish rdesktop login into the test box
yarikopticNov 28, 2017
dcfe242
ENH: also report where on sh, and echo msg when entering on_finish
yarikopticNov 28, 2017
0a67f25
RF: no "need" for custom shebang on windows since just does not work
yarikopticNov 28, 2017
6253625
Disable (but keep for future uses commented out) hook into appveyor s…
yarikopticNov 28, 2017
91b9bc4
RF(TST): skip all tests dealing with hooks on windows
yarikopticNov 28, 2017
b4459ca
BF(WIN): use where instead of which while looking for git
yarikopticNov 28, 2017
cc34077
RF: use HIDE_WINDOWS_KNOWN_ERRORS instead of is_win to skip hooks tests
yarikopticNov 28, 2017
4d851a6
BF(WIN): where could report multiple hits, so choose first
yarikopticNov 28, 2017
f48d087
to keep travis busy - adding myself to AUTHORS
yarikopticDec 1, 2017
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
10 changes: 9 additions & 1 deletion.appveyor.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,7 +46,7 @@ install:
echo %PATH%
uname -a
git --version
where git git-daemon python pip pip3 pip34
where git git-daemon python pip pip3 pip34 sh
python --version
python -c "import struct; print(struct.calcsize('P') * 8)"

Expand DownExpand Up@@ -91,3 +91,11 @@ test_script:

on_success:
- IF "%PYTHON_VERSION%" == "3.5" IF NOT "%IS_CYGWIN%" == "yes" (codecov)

# Enable this to be able to login to the build worker. You can use the
# `remmina` program in Ubuntu, use the login information that the line below
# prints into the log.
#on_finish:
# - |
# echo "Running on_finish to establish connection back to the instance"
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
1 change: 1 addition & 0 deletionsAUTHORS
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,5 +25,6 @@ Contributors are:
-Piotr Babij <piotr.babij _at_ gmail.com>
-Mikuláš Poul <mikulaspoul _at_ gmail.com>
-Charles Bouchard-Légaré <cblegare.atl _at_ ntis.ca>
-Yaroslav Halchenko <debian _at_ onerussian.com>

Portions derived from other open source works and are clearly marked.
2 changes: 1 addition & 1 deletiongit/compat.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -309,5 +309,5 @@ def register_surrogateescape():

try:
b"100644 \x9f\0aaa".decode(defenc, "surrogateescape")
except:
except Exception:
register_surrogateescape()
14 changes: 7 additions & 7 deletionsgit/diff.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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
line = None # temp line
line_length = 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)
line = "\n%s: %o | %s" % (n, b.mode, b.hexsha)
else:
l = "\n%s: None" % n
line = "\n%s: None" % n
# END if blob is not None
ll = max(len(l),ll)
msg +=l
line_length = max(len(line),line_length)
msg +=line
# END for each blob

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

if self.deleted_file:
msg += '\nfile deleted in rhs'
Expand Down
2 changes: 1 addition & 1 deletiongit/exc.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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 (ValueError, TypeError):
s = safe_decode(str(status))
status = u"'%s'" % s if isinstance(status, string_types) else s

Expand Down
2 changes: 1 addition & 1 deletiongit/refs/log.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionsgit/remote.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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
2 changes: 1 addition & 1 deletiongit/repo/base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -203,7 +203,7 @@ def __exit__(self, exc_type, exc_value, traceback):
def __del__(self):
try:
self.close()
except:
except Exception:
pass

def close(self):
Expand Down
6 changes: 3 additions & 3 deletionsgit/test/lib/helper.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -139,7 +139,7 @@ def repo_creator(self):
try:
try:
return func(self, rw_repo)
except:
except: # noqa E722
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

How aboutexcept Exception: like elsewhere?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We could. But at this out-most level of handling execution, I thought to remain as "greedy" as possible. May be someone (among used dependencies) still manages to raise non-Exception "exceptions" up the chain from somewhere/somehow -- so I thought to remain catching them as well. In the other places it was more "specific" to not expect some complete weird stuff being thrown up. But if you insist, we could have it Exception here as well

log.info("Keeping repo after failure: %s", repo_dir)
repo_dir = None
raise
Expand DownExpand 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 therorepo, whereas
The remote repository was cloned as bare repository from thero repo, 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 DownExpand 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: # noqa E722
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

How aboutexcept Exception: like elsewhere?

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 deletionsgit/test/test_commit.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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)
self.assertEqual(len(next(stoptraverse)),2)

# ignore self
self.assertEqual(next(start.traverse(ignore_self=False)),start)
Expand Down
5 changes: 4 additions & 1 deletiongit/test/test_git.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,6 +37,8 @@
except ImportError:
import mock

from git.compat import is_win


class TestGit(TestBase):

Expand DownExpand Up@@ -177,7 +179,8 @@ def test_refresh(self):
self.assertRaises(GitCommandNotFound, refresh, "yada")

# test a good path refresh
path = os.popen("which git").read().strip()
which_cmd = "where" if is_win else "which"
path = os.popen("{0} git".format(which_cmd)).read().strip().split('\n')[0]
refresh(path)

def test_options_are_passed_to_git(self):
Expand Down
72 changes: 39 additions & 33 deletionsgit/test/test_index.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -54,6 +54,22 @@
import os.path as osp
from git.cmd import Git

HOOKS_SHEBANG = "#!/usr/bin/env sh\n"


@skipIf(HIDE_WINDOWS_KNOWN_ERRORS, "TODO: fix hooks execution on Windows: #703")
def _make_hook(git_dir, name, content, make_exec=True):
"""A helper to create a hook"""
hp = hook_path(name, git_dir)
hpd = osp.dirname(hp)
if not osp.isdir(hpd):
os.mkdir(hpd)
with open(hp, "wt") as fp:
fp.write(HOOKS_SHEBANG + content)
if make_exec:
os.chmod(hp, 0o744)
return hp


class TestIndex(TestBase):

Expand DownExpand Up@@ -834,25 +850,21 @@ def test_add_a_file_with_wildcard_chars(self, rw_dir):
@with_rw_repo('HEAD', bare=True)
def test_pre_commit_hook_success(self, rw_repo):
index = rw_repo.index
hp = hook_path('pre-commit', index.repo.git_dir)
hpd = osp.dirname(hp)
if not osp.isdir(hpd):
os.mkdir(hpd)
with open(hp, "wt") as fp:
fp.write("#!/usr/bin/env sh\nexit 0")
os.chmod(hp, 0o744)
_make_hook(
index.repo.git_dir,
'pre-commit',
"exit 0"
)
index.commit("This should not fail")

@with_rw_repo('HEAD', bare=True)
def test_pre_commit_hook_fail(self, rw_repo):
index = rw_repo.index
hp = hook_path('pre-commit', index.repo.git_dir)
hpd = osp.dirname(hp)
if not osp.isdir(hpd):
os.mkdir(hpd)
with open(hp, "wt") as fp:
fp.write("#!/usr/bin/env sh\necho stdout; echo stderr 1>&2; exit 1")
os.chmod(hp, 0o744)
hp = _make_hook(
index.repo.git_dir,
'pre-commit',
"echo stdout; echo stderr 1>&2; exit 1"
)
try:
index.commit("This should fail")
except HookExecutionError as err:
Expand All@@ -869,35 +881,29 @@ def test_pre_commit_hook_fail(self, rw_repo):
self.assertEqual(err.stderr, "\n stderr: 'stderr\n'")
assert str(err)
else:
raise AssertionError("Should havecought a HookExecutionError")
raise AssertionError("Should havecaught a HookExecutionError")

@with_rw_repo('HEAD', bare=True)
def test_commit_msg_hook_success(self, rw_repo):
index = rw_repo.index
commit_message = u"commit default head by Frèderic Çaufl€"
from_hook_message = u"from commit-msg"

hp = hook_path('commit-msg', index.repo.git_dir)
hpd = osp.dirname(hp)
if not osp.isdir(hpd):
os.mkdir(hpd)
with open(hp, "wt") as fp:
fp.write('#!/usr/bin/env sh\necho -n " {}" >> "$1"'.format(from_hook_message))
os.chmod(hp, 0o744)

index = rw_repo.index
_make_hook(
index.repo.git_dir,
'commit-msg',
'echo -n " {0}" >> "$1"'.format(from_hook_message)
)
new_commit = index.commit(commit_message)
self.assertEqual(new_commit.message, u"{} {}".format(commit_message, from_hook_message))
self.assertEqual(new_commit.message, u"{0} {1}".format(commit_message, from_hook_message))

@with_rw_repo('HEAD', bare=True)
def test_commit_msg_hook_fail(self, rw_repo):
index = rw_repo.index
hp = hook_path('commit-msg', index.repo.git_dir)
hpd = osp.dirname(hp)
if not osp.isdir(hpd):
os.mkdir(hpd)
with open(hp, "wt") as fp:
fp.write("#!/usr/bin/env sh\necho stdout; echo stderr 1>&2; exit 1")
os.chmod(hp, 0o744)
hp = _make_hook(
index.repo.git_dir,
'commit-msg',
"echo stdout; echo stderr 1>&2; exit 1"
)
try:
index.commit("This should fail")
except HookExecutionError as err:
Expand Down
2 changes: 1 addition & 1 deletiongit/test/test_submodule.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionsgit/test/test_util.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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)
ilist = IterableList(name, prefix)

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

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

self.assertEqual(len(l), 2)
self.assertEqual(len(ilist), 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,ilist)
self.assertIn(name2,ilist)
self.assertIn(m2,ilist)
self.assertIn(m2,ilist)
self.assertNotIn('invalid',ilist)

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

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

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

# test exceptions
self.failUnlessRaises(AttributeError, getattr,l, 'something')
self.failUnlessRaises(IndexError,l.__getitem__, 'something')
self.failUnlessRaises(AttributeError, getattr,ilist, 'something')
self.failUnlessRaises(IndexError,ilist.__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,ilist.__delitem__, 'something')
del(ilist[name2])
self.assertEqual(len(ilist), 1)
self.assertNotIn(name2,ilist)
self.assertIn(name1,ilist)
del(ilist[0])
self.assertNotIn(name1,ilist)
self.assertEqual(len(ilist), 0)

self.failUnlessRaises(IndexError,ilist.__delitem__, 0)
self.failUnlessRaises(IndexError,ilist.__delitem__, 'something')
17 changes: 6 additions & 11 deletionsgit/util.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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
PATHEXT = os.environ.get('PATHEXT', None)
return tuple(p.upper() for p in PATHEXT.split(os.pathsep)) \
if PATHEXT \
else (('.BAT', 'COM', '.EXE') if is_win else ())


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 ()
winprog_exts = _get_exe_extensions()

def is_exec(fpath):
return osp.isfile(fpath) and os.access(fpath, os.X_OK) and (
Expand DownExpand 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:
except Exception:
return None

#} END utilities
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp