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

Commite0acb83

Browse files
committed
Added 'insert_kwargs_after' flag for consumption by _call_process.
While at it, all other invocations of .git in remote.py were reviewedFixesgitpython-developers#262
1 parentbfcdf2b commite0acb83

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

‎git/cmd.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,11 +753,23 @@ def _call_process(self, method, *args, **kwargs):
753753
exceptKeyError:
754754
pass
755755

756+
insert_after_this_arg=kwargs.pop('insert_kwargs_after',None)
757+
756758
# Prepare the argument list
757759
opt_args=self.transform_kwargs(**kwargs)
758760
ext_args=self.__unpack_args([aforainargsifaisnotNone])
759761

760-
args=opt_args+ext_args
762+
ifinsert_after_this_argisNone:
763+
args=opt_args+ext_args
764+
else:
765+
try:
766+
index=ext_args.index(insert_after_this_arg)
767+
exceptValueError:
768+
raiseValueError("Couldn't find argument '%s' in args %s to insert kwargs after"
769+
% (insert_after_this_arg,str(ext_args)))
770+
# end handle error
771+
args=ext_args[:index+1]+opt_args+ext_args[index+1:]
772+
# end handle kwargs
761773

762774
defmake_call():
763775
call= [self.GIT_PYTHON_GIT_EXECUTABLE]

‎git/remote.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,9 @@ def create(cls, repo, name, url, **kwargs):
477477
:param kwargs: Additional arguments to be passed to the git-remote add command
478478
:return: New Remote instance
479479
:raise GitCommandError: in case an origin with that name already exists"""
480-
repo.git.remote("add",name,url,**kwargs)
480+
scmd='add'
481+
kwargs['insert_kwargs_after']=scmd
482+
repo.git.remote(scmd,name,url,**kwargs)
481483
returncls(repo,name)
482484

483485
# add is an alias
@@ -517,7 +519,9 @@ def update(self, **kwargs):
517519
Additional arguments passed to git-remote update
518520
519521
:return: self """
520-
self.repo.git.remote("update",self.name,**kwargs)
522+
scmd='update'
523+
kwargs['insert_kwargs_after']=scmd
524+
self.repo.git.remote(scmd,self.name,**kwargs)
521525
returnself
522526

523527
def_get_fetch_info_from_stderr(self,proc,progress):

‎git/test/test_git.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ def test_single_char_git_options_are_passed_to_git(self):
155155
deftest_change_to_transform_kwargs_does_not_break_command_options(self):
156156
self.git.log(n=1)
157157

158+
deftest_insert_after_kwarg_raises(self):
159+
# This isn't a complete add command, which doesn't matter here
160+
self.failUnlessRaises(ValueError,self.git.remote,'add',insert_kwargs_after='foo')
161+
158162
deftest_env_vars_passed_to_git(self):
159163
editor='non_existant_editor'
160164
withmock.patch.dict('os.environ', {'GIT_EDITOR':editor}):

‎git/test/test_remote.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,9 @@ def test_creation_and_removal(self, bare_rw_repo):
486486
# END if deleted remote matches existing remote's name
487487
# END for each remote
488488

489+
# Issue #262 - the next call would fail if bug wasn't fixed
490+
bare_rw_repo.create_remote('bogus','/bogus/path',mirror='push')
491+
489492
deftest_fetch_info(self):
490493
# assure we can handle remote-tracking branches
491494
fetch_info_line_fmt="c437ee5deb8d00cf02f03720693e4c802e99f390not-for-merge%s '0.3' of "

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp