finetune repos
This commit is contained in:
@ -17,6 +17,7 @@ import argparse
|
||||
import logging
|
||||
import os
|
||||
import pathlib
|
||||
import requests
|
||||
import subprocess
|
||||
import warnings
|
||||
|
||||
@ -32,6 +33,8 @@ import otc_metadata.services
|
||||
|
||||
data = otc_metadata.services.Services()
|
||||
|
||||
api_session = requests.Session()
|
||||
|
||||
|
||||
def process_repositories(args, service):
|
||||
"""Checkout repositories
|
||||
@ -119,7 +122,7 @@ def process_repositories(args, service):
|
||||
try:
|
||||
new_branch = repo_to.create_head(branch_name, 'main')
|
||||
except Exception:
|
||||
logging.warn(f"Skipping service {service}")
|
||||
logging.warning(f"Skipping service {service}")
|
||||
return
|
||||
new_branch.checkout()
|
||||
|
||||
@ -160,6 +163,35 @@ def process_repositories(args, service):
|
||||
cwd=copy_to,
|
||||
check=True
|
||||
)
|
||||
elif 'gitea' in url_to and args.token:
|
||||
open_pr(
|
||||
args,
|
||||
repo["repo"],
|
||||
dict(
|
||||
head=branch_name,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def open_pr(args, repository, pr_data):
|
||||
req = dict(
|
||||
base=pr_data.get("base", "main"),
|
||||
head=pr_data["head"],
|
||||
)
|
||||
if "title" in pr_data:
|
||||
req["title"] = pr_data["title"]
|
||||
if "body" in pr_data:
|
||||
req["body"] = pr_data["body"].replace("\\n", "\n")
|
||||
if "assignees" in pr_data:
|
||||
req["assignees"] = pr_data["assignees"]
|
||||
if "labels" in pr_data:
|
||||
req["labels"] = pr_data["labels"]
|
||||
rsp = api_session.post(
|
||||
f"{args.api_url}/repos/{repository}/pulls", json=req
|
||||
)
|
||||
if rsp.status_code != 201:
|
||||
print(rsp.text)
|
||||
print(f"Going to open PR with title {pr_data['title']} in {repository}")
|
||||
|
||||
|
||||
def main():
|
||||
@ -189,7 +221,8 @@ def main():
|
||||
action='store_true',
|
||||
help='Whether to force branch recreation.'
|
||||
)
|
||||
|
||||
parser.add_argument("--token", metavar="token", help="API token")
|
||||
parser.add_argument("--api-url", help="API base url of the Git hoster")
|
||||
|
||||
args = parser.parse_args()
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
|
Reference in New Issue
Block a user