@@ -143,14 +143,29 @@ def gix_fetch(info: ACBSSourceInfo, source_location: str, name: str) -> Optional
143
143
else :
144
144
logging .info ('Updating repository with gix...' )
145
145
# 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 )
148
162
os .remove (os .path .join (full_path , "index" ))
149
163
subprocess .check_call (
150
164
['gix' , 'fetch' , 'origin' , '+refs/heads/*:refs/heads/*' ], cwd = full_path )
151
165
info .source_location = full_path
152
166
return info
153
167
168
+
154
169
def git_processor (package : ACBSPackageInfo , index : int , source_name : str ) -> None :
155
170
info = package .source_uri [index ]
156
171
if not info .revision :
0 commit comments