Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'actions' unit to RepoUnits and update related parsers #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion gitea/apiobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class RepoUnits:
pulls: str = "none"
releases: str = "none"
ext_wiki: str = "none"
actions: str = "none"

def to_dict(self) -> dict[str, str]:
"""Return the correctly prefixed (added "repo.") representation for gitea Repository runit Rights"""
Expand All @@ -26,7 +27,7 @@ def to_dict(self) -> dict[str, str]:
def from_dict(cls, unit_dict: dict[str, str]) -> "RepoUnits":
"""Parse all known repo units from the dictionary returned by the api"""
return RepoUnits(
**{k[5:]: v for k, v in unit_dict.items() if k[5:] in fields(cls)}
**{k[5:]: v for k, v in unit_dict.items() if k[5:] in {field.name for field in fields(cls)}}
)


Expand Down Expand Up @@ -415,6 +416,7 @@ def request(cls, gitea: "Gitea", owner: str, name: str):
"enable_prune",
"external_tracker",
"external_wiki",
"has_actions",
"has_issues",
"has_projects",
"has_pull_requests",
Expand Down Expand Up @@ -946,6 +948,10 @@ def __hash__(self):
"units_map": lambda gitea, o: RepoUnits.from_dict(o),
}

_parsers_to_fields = {
"units_map": lambda m: RepoUnits.to_dict(m),
}

_patchable_fields = {
"can_create_org_repo",
"description",
Expand Down