Removed old code for creating pull requests
All checks were successful
Run Python tests (through Pytest) / Test (push) Successful in 25s
Verify Python project can be installed, loaded and have version checked / Test (push) Successful in 22s

This commit is contained in:
Jon Michael Aanes 2025-04-13 16:37:16 +02:00
parent 57f442284f
commit aa14a3e5e7

View File

@ -92,14 +92,6 @@ class GiteaClient:
] ]
return issues 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(): def parse_args():
parser = argparse.ArgumentParser(description="Download issues and create pull requests for a Gitea repository.") 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") 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)") parser.add_argument("--base-branch", default="main", help="Base branch to use for new branches (default: main)")
return parser.parse_args() 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 = [ cmd = [
"git", "git",
"push", "push",
@ -119,7 +111,7 @@ def push_changes(branch_name: str, issue_title: str, issue_description: str, bas
"-o", "-o",
f"title={issue_title}", f"title={issue_title}",
"-o", "-o",
f"description={issue_description}" f"description=\"This pull request resolves #{issue_number}\""
] ]
run_cmd(cmd) 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(["git", "checkout", "-b", branch_name], tmpdirname)
run_cmd(create_aider_command(f'# {issue_title}\n{issue_description}'), tmpdirname) run_cmd(create_aider_command(f'# {issue_title}\n{issue_description}'), tmpdirname)
run_cmd(["git", "add", "."], 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(): def main():
logging.basicConfig(level='INFO') logging.basicConfig(level='INFO')
@ -161,18 +153,9 @@ def main():
try: try:
with tempfile.TemporaryDirectory() as tmpdirname: with tempfile.TemporaryDirectory() as tmpdirname:
process_issue(args, Path(tmpdirname), branch_name, title, issue_description, issue_number) 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: except Exception:
logger.exception('Error processing issue') logger.exception('Error processing issue')
sys.exit(1) 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__": if __name__ == "__main__":
main() main()