@@ -97,17 +97,18 @@ async def ensure_git_installed() -> None:
9797 """
9898 try :
9999 # Use GitPython to check git availability
100- git .Git ().version ()
100+ git_cmd = git .Git ()
101+ git_cmd .version ()
101102 except git .GitCommandError as exc :
102103 msg = "Git is not installed or not accessible. Please install Git first."
103104 raise RuntimeError (msg ) from exc
104105 except Exception as exc :
105106 msg = "Git is not installed or not accessible. Please install Git first."
106107 raise RuntimeError (msg ) from exc
107-
108+
108109 if sys .platform == "win32" :
109110 try :
110- longpaths_value = git . Git () .config ("core.longpaths" )
111+ longpaths_value = git_cmd .config ("core.longpaths" )
111112 if longpaths_value .lower () != "true" :
112113 logger .warning (
113114 "Git clone may fail on Windows due to long file paths. "
@@ -232,29 +233,29 @@ async def fetch_remote_branches_or_tags(url: str, *, ref_type: str, token: str |
232233 raise ValueError (msg )
233234
234235 await ensure_git_installed ()
235-
236+
236237 # Use GitPython to get remote references
237238 try :
238239 git_cmd = git .Git ()
239-
240+
240241 # Prepare environment with authentication if needed
241242 env = None
242243 if token and is_github_host (url ):
243244 auth_url = _add_token_to_url (url , token )
244245 url = auth_url
245-
246+
246247 fetch_tags = ref_type == "tags"
247248 to_fetch = "tags" if fetch_tags else "heads"
248-
249+
249250 # Build ls-remote command
250- cmd_args = ["ls-remote" , f"--{ to_fetch } " ]
251+ cmd_args = [f"--{ to_fetch } " ]
251252 if fetch_tags :
252253 cmd_args .append ("--refs" ) # Filter out peeled tag objects
253254 cmd_args .append (url )
254-
255- # Run the command
256- output = git_cmd .execute ( cmd_args , env = env )
257-
255+
256+ # Run the command using git_cmd.ls_remote() method
257+ output = git_cmd .ls_remote ( * cmd_args )
258+
258259 # Parse output
259260 return [
260261 line .split (f"refs/{ to_fetch } /" , 1 )[1 ]
@@ -286,14 +287,14 @@ def create_git_repo(local_path: str, url: str, token: str | None = None) -> git.
286287 """
287288 try :
288289 repo = git .Repo (local_path )
289-
290+
290291 # Configure authentication if needed
291292 if token and is_github_host (url ):
292293 auth_header = create_git_auth_header (token , url = url )
293294 # Set the auth header in git config for this repo
294- key , value = auth_header .split ('=' , 1 )
295+ key , value = auth_header .split ("=" , 1 )
295296 repo .git .config (key , value )
296-
297+
297298 return repo
298299 except git .InvalidGitRepositoryError as exc :
299300 msg = f"Invalid git repository at { local_path } "
@@ -364,7 +365,7 @@ async def checkout_partial_clone(config: CloneConfig, token: str | None) -> None
364365 if config .blob :
365366 # Remove the file name from the subpath when ingesting from a file url (e.g. blob/branch/path/file.txt)
366367 subpath = str (Path (subpath ).parent .as_posix ())
367-
368+
368369 try :
369370 repo = create_git_repo (config .local_path , config .url , token )
370371 repo .git .execute (["sparse-checkout" , "set" , subpath ])
@@ -428,16 +429,16 @@ async def _resolve_ref_to_sha(url: str, pattern: str, token: str | None = None)
428429 """
429430 try :
430431 git_cmd = git .Git ()
431-
432+
432433 # Prepare authentication if needed
433434 auth_url = url
434435 if token and is_github_host (url ):
435436 auth_url = _add_token_to_url (url , token )
436-
437+
437438 # Execute ls-remote command
438- output = git_cmd .execute ([ "ls-remote" , auth_url , pattern ] )
439+ output = git_cmd .ls_remote ( auth_url , pattern )
439440 lines = output .splitlines ()
440-
441+
441442 sha = _pick_commit_sha (lines )
442443 if not sha :
443444 msg = f"{ pattern !r} not found in { url } "
@@ -501,18 +502,20 @@ def _add_token_to_url(url: str, token: str) -> str:
501502
502503 """
503504 from urllib .parse import urlparse , urlunparse
504-
505+
505506 parsed = urlparse (url )
506507 # Add token as username in URL (GitHub supports this)
507508 netloc = f"x-oauth-basic:{ token } @{ parsed .hostname } "
508509 if parsed .port :
509510 netloc += f":{ parsed .port } "
510-
511- return urlunparse ((
512- parsed .scheme ,
513- netloc ,
514- parsed .path ,
515- parsed .params ,
516- parsed .query ,
517- parsed .fragment
518- ))
511+
512+ return urlunparse (
513+ (
514+ parsed .scheme ,
515+ netloc ,
516+ parsed .path ,
517+ parsed .params ,
518+ parsed .query ,
519+ parsed .fragment ,
520+ ),
521+ )
0 commit comments