Removed old code for creating pull requests
This commit is contained in:
parent
57f442284f
commit
aa14a3e5e7
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue
Block a user