File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -374,10 +374,14 @@ def commit(self, commit_message: str):
374374
375375 self ._repo .index .commit (commit_message , author = author , committer = author )
376376
377- def push (self , remote : Optional [str ] = None ) -> Iterable [PushInfo ]:
377+ def push (
378+ self , remote : Optional [str ] = None , version : Optional [str ] = None
379+ ) -> Iterable [PushInfo ]:
378380 if not remote :
379381 remote = "origin"
380- return self ._repo .remote (remote ).push ()
382+ if not version :
383+ version = self ._default_version ()
384+ return self ._repo .remote (remote ).push (version )
381385
382386 def reset (self , working_tree : bool = False ):
383387 self ._repo .head .reset (working_tree = working_tree )
Original file line number Diff line number Diff line change @@ -166,3 +166,17 @@ def test_gitrepo_reset(tmp_path: Path):
166166 r .reset (working_tree = True )
167167
168168 assert not r .repo .is_dirty ()
169+
170+
171+ def test_gitrepo_push_empty_remote (tmp_path : Path ):
172+ git .Repo .init (tmp_path / "remote.git" , mkdir = True , bare = True )
173+ r = gitrepo .GitRepo (
174+ f"file:///{ tmp_path } /remote.git" , tmp_path / "local" , force_init = True
175+ )
176+
177+ testf = r .working_tree_dir / "test.txt"
178+ with open (testf , "w" ) as f :
179+ f .write ("Hello, world!\n " )
180+ r .stage_all ()
181+ r .commit ("Initial commit" )
182+ r .push ()
You can’t perform that action at this time.
0 commit comments