From aa14a3e5e74b3bcec254e131e86b95d20d69467b Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Sun, 13 Apr 2025 16:37:16 +0200 Subject: [PATCH] Removed old code for creating pull requests --- aider_gitea/__main__.py | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/aider_gitea/__main__.py b/aider_gitea/__main__.py index 20d4730..f8514f9 100644 --- a/aider_gitea/__main__.py +++ b/aider_gitea/__main__.py @@ -92,14 +92,6 @@ class GiteaClient: ] return issues - def create_pull_request(self, owner, repo, title, head, base, body): - """Create a pull request for the given branch.""" - url = f"{self.gitea_url}/repos/{owner}/{repo}/pulls" - json_data = {"title": title, "head": head, "base": base, "body": body} - response = self.session.post(url, json=json_data) - response.raise_for_status() - return response.json() - def parse_args(): parser = argparse.ArgumentParser(description="Download issues and create pull requests for a Gitea repository.") parser.add_argument("--gitea-url", required=True, help="Base URL for the Gitea instance, e.g., https://gitfub.space/api/v1") @@ -108,7 +100,7 @@ def parse_args(): parser.add_argument("--base-branch", default="main", help="Base branch to use for new branches (default: main)") return parser.parse_args() -def push_changes(branch_name: str, issue_title: str, issue_description: str, base_branch: str) -> None: +def push_changes(branch_name: str, issue_number: str, issue_title: str, issue_description: str, base_branch: str) -> None: cmd = [ "git", "push", @@ -119,7 +111,7 @@ def push_changes(branch_name: str, issue_title: str, issue_description: str, bas "-o", f"title={issue_title}", "-o", - f"description={issue_description}" + f"description=\"This pull request resolves #{issue_number}\"" ] run_cmd(cmd) @@ -135,7 +127,7 @@ def process_issue(args, tmpdirname: Path, branch_name: str, issue_title: str, is run_cmd(["git", "checkout", "-b", branch_name], tmpdirname) run_cmd(create_aider_command(f'# {issue_title}\n{issue_description}'), tmpdirname) run_cmd(["git", "add", "."], tmpdirname) - push_changes(branch_name, issue_title, issue_description, args.base_branch) + push_changes(branch_name, issue_number, issue_title, issue_description, args.base_branch) def main(): logging.basicConfig(level='INFO') @@ -161,18 +153,9 @@ def main(): try: with tempfile.TemporaryDirectory() as tmpdirname: process_issue(args, Path(tmpdirname), branch_name, title, issue_description, issue_number) - logger.info(f"Created branch {branch_name} for issue {issue_number}.") except Exception: logger.exception('Error processing issue') sys.exit(1) - body = f"This pull request resolves {issue.get('html_url', 'unknown')}" - try: - pr = client.create_pull_request(args.owner, args.repo, f"[Issue {issue_number}] {title}", branch_name, args.base_branch, body) - logger.info(f"Created pull request: {pr.get('html_url', 'unknown')} for issue {issue_number}.") - except Exception: - logger.exception('"Error creating pull request for branch') - sys.exit(1) - if __name__ == "__main__": main()