032: fix SyntaxError in git/_base.py — positional after keyword args in run_blocking
7 calls fixed: moved kind and fn to positional to avoid SyntaxError 'positional argument follows keyword argument'.
This commit is contained in:
@@ -98,7 +98,7 @@ class GitServiceBase:
|
||||
if pat and "://" in remote_url:
|
||||
proto, rest = remote_url.split("://", 1)
|
||||
auth_url = f"{proto}://oauth2:{quote(pat, safe='')}@{rest}"
|
||||
repo = await run_blocking(kind='git', fn=Repo.clone_from, auth_url, repo_path)
|
||||
repo = await run_blocking('git', Repo.clone_from, auth_url, repo_path)
|
||||
# Strip PAT from origin URL to prevent credential leakage in .git/config, logs, ps aux
|
||||
repo.git.remote("set-url", "origin", remote_url)
|
||||
return repo
|
||||
@@ -205,9 +205,9 @@ class GitServiceBase:
|
||||
return source_abs
|
||||
await run_blocking(kind='file', fn=Path(target_abs).parent.mkdir, parents=True, exist_ok=True)
|
||||
try:
|
||||
await run_blocking(kind='file', fn=os.replace, source_abs, target_abs)
|
||||
await run_blocking('file', os.replace, source_abs, target_abs)
|
||||
except OSError:
|
||||
await run_blocking(kind='file', fn=shutil.move, source_abs, target_abs)
|
||||
await run_blocking('file', shutil.move, source_abs, target_abs)
|
||||
self._update_repo_local_path(dashboard_id, target_abs)
|
||||
logger.info(
|
||||
f"[_migrate_repo_directory][Coherence:OK] Repository migrated for dashboard {dashboard_id}: {source_abs} -> {target_abs}"
|
||||
@@ -277,12 +277,12 @@ class GitServiceBase:
|
||||
if os.path.exists(repo_path):
|
||||
logger.reason(f"Opening existing repo at {repo_path}", extra={"src": "init_repo"})
|
||||
try:
|
||||
repo = await run_blocking(kind='git', fn=Repo, repo_path)
|
||||
repo = await run_blocking('git', Repo, repo_path)
|
||||
except (InvalidGitRepositoryError, NoSuchPathError):
|
||||
logger.reason(f"Existing path is not a Git repository, recreating: {repo_path}", extra={"src": "init_repo"})
|
||||
stale_path = Path(repo_path)
|
||||
if stale_path.exists():
|
||||
await run_blocking(kind='file', fn=shutil.rmtree, stale_path, ignore_errors=True)
|
||||
await run_blocking('file', shutil.rmtree, stale_path, ignore_errors=True)
|
||||
if stale_path.exists():
|
||||
try:
|
||||
await run_blocking(kind='file', fn=stale_path.unlink)
|
||||
@@ -309,9 +309,9 @@ class GitServiceBase:
|
||||
removed_files = False
|
||||
if os.path.exists(repo_path):
|
||||
if os.path.isdir(repo_path):
|
||||
await run_blocking(kind='file', fn=shutil.rmtree, repo_path)
|
||||
await run_blocking('file', shutil.rmtree, repo_path)
|
||||
else:
|
||||
await run_blocking(kind='file', fn=os.remove, repo_path)
|
||||
await run_blocking('file', os.remove, repo_path)
|
||||
removed_files = True
|
||||
session = SessionLocal()
|
||||
try:
|
||||
@@ -354,7 +354,7 @@ class GitServiceBase:
|
||||
logger.error(f"[EXT:method:get_repo][Coherence:Failed] Repository for dashboard {dashboard_id} does not exist")
|
||||
raise HTTPException(status_code=404, detail=f"Repository for dashboard {dashboard_id} not found")
|
||||
try:
|
||||
return await run_blocking(kind='git', fn=Repo, repo_path)
|
||||
return await run_blocking('git', Repo, repo_path)
|
||||
except Exception as e:
|
||||
logger.error(f"[EXT:method:get_repo][Coherence:Failed] Failed to open repository at {repo_path}: {e}")
|
||||
raise HTTPException(status_code=500, detail="Failed to open local Git repository")
|
||||
|
||||
Reference in New Issue
Block a user