fix: detect Gitea issues with null pull request metadata
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import Annotated
|
||||
|
||||
@@ -30,6 +31,8 @@ def main(
|
||||
ctx: typer.Context,
|
||||
config: Annotated[Path, typer.Option("--config", "-c", help="Path to YAML config.")] = Path("config.yaml"),
|
||||
) -> None:
|
||||
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(name)s: %(message)s")
|
||||
logging.getLogger("httpx").setLevel(logging.WARNING)
|
||||
ctx.obj = CliContext(config)
|
||||
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ class GiteaClient:
|
||||
response.raise_for_status()
|
||||
issues: list[GiteaIssue] = []
|
||||
for item in response.json():
|
||||
if "pull_request" in item:
|
||||
if item.get("pull_request"):
|
||||
continue
|
||||
issues.append(
|
||||
GiteaIssue(
|
||||
|
||||
@@ -2,6 +2,7 @@ from __future__ import annotations
|
||||
|
||||
import socket
|
||||
import time
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
from .agents import CommandRunner, read_report, render_command, write_prompt
|
||||
@@ -21,6 +22,9 @@ from .state import validate_transition
|
||||
from .workspace import WorkspaceManager, safe_branch_name
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def sync_repositories(db: Database, config: AppConfig, client: GiteaClient) -> list[RepositoryRecord]:
|
||||
synced: list[RepositoryRecord] = []
|
||||
discovered = client.list_owned_repositories()
|
||||
@@ -89,10 +93,19 @@ class TaskRunner:
|
||||
|
||||
def worker_loop(self) -> None:
|
||||
while True:
|
||||
sync_repositories(self.db, self.config, self.gitea)
|
||||
scan_issues(self.db, self.config, self.gitea)
|
||||
task = self.run_once()
|
||||
if task is None:
|
||||
try:
|
||||
repos = sync_repositories(self.db, self.config, self.gitea)
|
||||
logger.info("synced %d repositories", len(repos))
|
||||
task_ids = scan_issues(self.db, self.config, self.gitea)
|
||||
logger.info("created %d tasks from issue scan", len(task_ids))
|
||||
task = self.run_once()
|
||||
if task is None:
|
||||
logger.info("no task available; sleeping %d seconds", self.config.scheduler.interval_seconds)
|
||||
time.sleep(self.config.scheduler.interval_seconds)
|
||||
else:
|
||||
logger.info("task %d finished in state %s", task.id, task.state.value)
|
||||
except Exception:
|
||||
logger.exception("worker iteration failed")
|
||||
time.sleep(self.config.scheduler.interval_seconds)
|
||||
|
||||
def run_claimed(self, task: TaskRecord) -> TaskRecord:
|
||||
|
||||
Reference in New Issue
Block a user