@@ -78,10 +78,8 @@ def test_init_repo_object(self, rw_dir):
7878 self .assertEqual (repo .refs [active_branch .name ], repo .heads [active_branch .name ]) # .refs provides all refs...
7979
8080 if "TRAVIS" not in os .environ :
81- remote_head = repo .remotes .origin .refs .HEAD .reference
82- self .assertEqual (
83- repo .refs [remote_head .name ], repo .remotes .origin .refs [remote_head .remote_head ]
84- ) # ...remotes...
81+ remote_branch = next (ref for ref in repo .remotes .origin .refs if ref .remote_head != "HEAD" )
82+ self .assertEqual (repo .refs [remote_branch .name ], remote_branch ) # ...remotes...
8583 self .assertEqual (repo .refs ["0.3.5" ], repo .tags ["0.3.5" ]) # ... and tags.
8684 # ![8-test_init_repo_object]
8785
@@ -147,9 +145,9 @@ def update(self, op_code, cur_count, max_count=None, message=""):
147145 assert origin .exists ()
148146 for fetch_info in origin .fetch (progress = MyProgressPrinter ()):
149147 print ("Updated %s to %s" % (fetch_info .ref , fetch_info .commit ))
150- # Create a local branch at the remote's default branch .
151- remote_default_branch = origin .refs . HEAD . reference
152- bare_branch = bare_repo .create_head (remote_default_branch .remote_head , remote_default_branch )
148+ # Create a local branch at one of the remote's branches .
149+ remote_branch = next ( ref for ref in origin .refs if ref . remote_head != " HEAD" )
150+ bare_branch = bare_repo .create_head (remote_branch .remote_head , remote_branch )
153151 bare_repo .head .set_reference (bare_branch )
154152 assert not bare_repo .delete_remote (origin ).exists ()
155153 # push and pull behave very similarly.
0 commit comments