-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c04f70
commit 35eb4d3
Showing
1 changed file
with
12 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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( | ||
|
@@ -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 | ||
|
||
|
@@ -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)) | ||
|