This commit is contained in:
Jon Michael Aanes 2025-04-13 18:06:56 +02:00
parent bdee056b67
commit 8a77769500
4 changed files with 16 additions and 17 deletions

View File

@ -4,18 +4,17 @@ This script downloads issues from a given Gitea repository and produces a pull r
It assumes that the default branch (default "main") exists and that you have a valid API token if authentication is required. It assumes that the default branch (default "main") exists and that you have a valid API token if authentication is required.
""" """
import logging
from pathlib import Path
import argparse import argparse
import requests import logging
import sys
import dataclasses
import tempfile
import subprocess
import os
import time
import re import re
import subprocess
import sys
import tempfile
import time
from pathlib import Path
import requests
from . import secrets from . import secrets
from .seen_issues_db import SeenIssuesDB from .seen_issues_db import SeenIssuesDB
@ -133,7 +132,7 @@ class GiteaClient:
def parse_args(): def parse_args():
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description='Download issues and create pull requests for a Gitea repository.' description='Download issues and create pull requests for a Gitea repository.',
) )
parser.add_argument( parser.add_argument(
'--gitea-url', '--gitea-url',
@ -214,7 +213,8 @@ def process_issue(
issue_number: str, issue_number: str,
): ):
repo_url = f'{args.gitea_url}:{args.owner}/{args.repo}.git'.replace( repo_url = f'{args.gitea_url}:{args.owner}/{args.repo}.git'.replace(
'https://', 'git@' 'https://',
'git@',
) )
run_cmd(['git', 'clone', repo_url, tmpdirname]) run_cmd(['git', 'clone', repo_url, tmpdirname])
run_cmd(['bash', '-c', AIDER_TEST], tmpdirname) run_cmd(['bash', '-c', AIDER_TEST], tmpdirname)
@ -285,7 +285,7 @@ def main():
if args.daemon: if args.daemon:
logger.info( logger.info(
f'Starting daemon mode, checking for new issues every {args.interval} seconds' f'Starting daemon mode, checking for new issues every {args.interval} seconds',
) )
try: try:
while True: while True:

View File

@ -28,7 +28,8 @@ class SeenIssuesDB:
def has_seen(self, issue_text: str) -> bool: def has_seen(self, issue_text: str) -> bool:
issue_hash = self._compute_hash(issue_text) issue_hash = self._compute_hash(issue_text)
cursor = self.conn.execute( cursor = self.conn.execute(
'SELECT 1 FROM seen_issues WHERE issue_hash = ?', (issue_hash,) 'SELECT 1 FROM seen_issues WHERE issue_hash = ?',
(issue_hash,),
) )
return cursor.fetchone() is not None return cursor.fetchone() is not None

View File

@ -1,4 +1,3 @@
import pytest
from aider_gitea.__main__ import generate_branch_name from aider_gitea.__main__ import generate_branch_name

View File

@ -1,6 +1,5 @@
import sys
import unittest import unittest
from pathlib import Path
from aider_gitea.seen_issues_db import SeenIssuesDB from aider_gitea.seen_issues_db import SeenIssuesDB