Skip to content

Commit

Permalink
🎨 Format Python code with Black
Browse files Browse the repository at this point in the history
  • Loading branch information
tituspijean authored and OniriCorpe committed Aug 18, 2024
1 parent 6c04f70 commit 35eb4d3
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions tools/webhooks/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,17 @@ def bump_revision(request: Request, pr_infos: dict) -> HTTPResponse:
repo.remote().push(quiet=False, all=True)
return response.text("ok")


def reject_wishlist(request: Request, pr_infos: dict, reason=None) -> HTTPResponse:
data = request.json
repository = data["repository"]["full_name"]
branch = pr_infos["head"]["ref"]

if repository == "YunoHost/apps" and branch.startswith("add-to-wishlist"):

logging.info(f"Will put the suggested app in the rejected list on {repository} branch {branch}...")
logging.info(
f"Will put the suggested app in the rejected list on {repository} branch {branch}..."
)
with tempfile.TemporaryDirectory() as folder_str:
folder = Path(folder_str)
repo = Repo.clone_from(
Expand All @@ -221,14 +224,14 @@ def reject_wishlist(request: Request, pr_infos: dict, reason=None) -> HTTPRespon
)
repo.git.checkout(branch)

rejectedlist_file = (folder / "rejectedlist.toml")
rejectedlist_file = folder / "rejectedlist.toml"
rejectedlist = tomlkit.load(rejectedlist_file.open("r", encoding="utf-8"))

wishlist_file = (folder / "wishlist.toml")
wishlist_file = folder / "wishlist.toml"
wishlist = tomlkit.load(wishlist_file.open("r", encoding="utf-8"))

suggestedapp_slug = branch.replace("add-to-wishlist-", "")
suggestedapp = {suggestedapp_slug:wishlist[suggestedapp_slug]}
suggestedapp = {suggestedapp_slug: wishlist[suggestedapp_slug]}
suggestedapp[suggestedapp_slug]["rejection_pr"] = pr_infos["html_url"]
suggestedapp[suggestedapp_slug]["reason"] = reason

Expand All @@ -242,12 +245,16 @@ def reject_wishlist(request: Request, pr_infos: dict, reason=None) -> HTTPRespon
repo.git.add("wishlist.toml")

suggestedapp_name = suggestedapp[suggestedapp_slug]["name"]
repo.index.commit(f"Reject {suggestedapp_name} from catalog", author=Actor("yunohost-bot", "[email protected]"))
repo.index.commit(
f"Reject {suggestedapp_name} from catalog",
author=Actor("yunohost-bot", "[email protected]"),
)

logging.debug(f"Pushing {repository}")
repo.remote().push(quiet=False, all=True, force=True)
return response.text("ok")


def generate_and_commit_readmes(repo: Repo) -> bool:
assert repo.working_tree_dir is not None
generate_READMEs(Path(repo.working_tree_dir))
Expand Down

0 comments on commit 35eb4d3

Please sign in to comment.