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

Commit0ddbe4b

Browse files
committed
Added test forsshkey context manager.
It verifies that the script is actually called.Interestingly, the shell script version works within an msysgit environmenton windows.Fixesgitpython-developers#234
1 parent5ad07f7 commit0ddbe4b

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

‎git/repo/base.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ def _expand_path(p):
7575

7676

7777
classRepo(object):
78-
7978
"""Represents a git repository and allows you to query references,
8079
gather commit information, generate diffs, create and clone repositories query
8180
the log.
@@ -758,7 +757,7 @@ def init(cls, path=None, mkdir=True, **kwargs):
758757
# git command automatically chdir into the directory
759758
git=Git(path)
760759
git.init(**kwargs)
761-
returnRepo(path)
760+
returncls(path)
762761

763762
@classmethod
764763
def_clone(cls,git,url,path,odb_default_type,progress,**kwargs):

‎git/test/test_docs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def test_references_and_objects(self, rw_dir):
440440
# [32-test_references_and_objects]
441441
private_key_file=os.path.join(rw_dir,'id_rsa_deployment_key')
442442
withrepo.git.sshkey(private_key_file):
443-
# Note that we don't actually make the call here, as our test-setup doesn't permit it to
443+
# Note that we don't actually make the call here, as our test-setup doesn't permit it to
444444
# succeed.
445445
# It will in your case :)
446446
repo.remotes.origin.fetch

‎git/test/test_git.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,26 @@ def test_environment(self, rw_dir):
181181
assertnew_env== {'VARKEY':'VARVALUE'}
182182
assertself.git.environment()== {}
183183

184-
rw_repo=Repo.init(os.path.join(rw_dir,'repo'))
184+
classTestRepo(Repo):
185+
classGitCommandWrapperType(Git):
186+
def_sshkey_script_path(self):
187+
path=os.path.join(rw_dir,'failing-script.sh')
188+
stream=open(path,'wt')
189+
stream.write("#!/usr/bin/env sh\n"+
190+
"echo FOO\n")
191+
stream.close()
192+
os.chmod(path,0o555)
193+
returnpath
194+
# end Git
195+
# end Repo
196+
197+
rw_repo=TestRepo.init(os.path.join(rw_dir,'repo'))
185198
remote=rw_repo.create_remote('ssh-origin',"ssh://git@server/foo")
186199

187200
withrw_repo.git.sshkey('doesntexist.key'):
188-
remote.fetch()
201+
try:
202+
remote.fetch()
203+
exceptGitCommandErroraserr:
204+
assert'FOO'instr(err)
205+
# end
189206
# end
190-
191-

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp