@@ -143,14 +143,29 @@ def gix_fetch(info: ACBSSourceInfo, source_location: str, name: str) -> Optional
143143 else :
144144 logging .info ('Updating repository with gix...' )
145145 # gix doesn't have the --prune option yet.
146- # FIXME: reset HEAD to master to fix gix can't second fetch src issue.
147- subprocess .check_call (['git' , 'symbolic-ref' , 'HEAD' ], cwd = full_path )
146+ # FIXME: reset HEAD to the first valid branch to fix gix can't second fetch src issue.
147+ subprocess .check_call (
148+ ['git' , 'symbolic-ref' , 'HEAD' , 'refs/heads/HEAD' ], cwd = full_path )
149+ valid_branches : list (str ) = subprocess .check_output (
150+ ['git' , 'branch' ], cwd = full_path , encoding = 'utf-8' ).splitlines ()
151+ for word in valid_branches :
152+ word = word .strip ()
153+ if len (word ) > 0 :
154+ valid_branches : str = word
155+ break
156+ if isinstance (valid_branches , list ):
157+ logging .warn (
158+ 'No valid branches found. Falling back to traditional git.' )
159+ raise ValueError ('No valid branches found' )
160+ subprocess .check_call (
161+ ['git' , 'symbolic-ref' , 'HEAD' , 'refs/heads/' + valid_branches ], cwd = full_path )
148162 os .remove (os .path .join (full_path , "index" ))
149163 subprocess .check_call (
150164 ['gix' , 'fetch' , 'origin' , '+refs/heads/*:refs/heads/*' ], cwd = full_path )
151165 info .source_location = full_path
152166 return info
153167
168+
154169def git_processor (package : ACBSPackageInfo , index : int , source_name : str ) -> None :
155170 info = package .source_uri [index ]
156171 if not info .revision :
0 commit comments