fix: get_file_commits use consistent caching (_cached/_set_cache)
FlowDeck CI / test (push) Failing after 4s
FlowDeck CI / docker (push) Has been skipped

This commit is contained in:
2026-07-13 22:57:46 -04:00
parent b863afab59
commit e04b3a38a4
+14 -7
View File
@@ -387,14 +387,21 @@ class GiteaClient:
del self._cache[k] del self._cache[k]
async def get_file_commits(self, owner: str, repo: str, path: str) -> list[dict]: async def get_file_commits(self, owner: str, repo: str, path: str) -> list[dict]:
"""Get recent commits affecting a specific file.""" """Get recent commits affecting a specific file (cached 5 min)."""
url = f"{self.base}/api/v1/repos/{owner}/{repo}/commits" key = f"commits:{owner}:{repo}:{path}"
params = {"path": path, "limit": 20} cached = self._cached(key)
headers = {"Authorization": f"token {self.token[0] if self.token else ''}", "Accept": "application/json"} if cached:
async with httpx.AsyncClient(timeout=self.timeout) as client: return cached
resp = await client.get(url, params=params, headers=headers) async with httpx.AsyncClient(timeout=15) as client:
resp = await client.get(
f"{self._base}/repos/{owner}/{repo}/commits",
headers=self._headers,
params={"path": path, "limit": 20},
)
if resp.status_code == 200: if resp.status_code == 200:
return resp.json() data = resp.json()
self._set_cache(key, data)
return data
return [] return []