-
Notifications
You must be signed in to change notification settings - Fork 56
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 Forgejo Issues support #896
base: main
Are you sure you want to change the base?
Conversation
# Conflicts: # ogr/services/forgejo/issue.py
for more information, see https://pre-commit.ci
Build failed. ❌ pre-commit FAILURE in 2m 49s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC the docs are inherited from the abstract classes, so we're left with just the pagination and tests
|
||
@property | ||
def status(self) -> IssueStatus: | ||
return IssueStatus[self._raw_issue.state] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this maps as it should?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did manually test this, looked at generated openapi spec from forgejo and had similar doubts, I will check again and add some checks
@staticmethod | ||
def get(project: "forgejo.ForgejoProject", issue_id: int) -> _issue: | ||
if not project.has_issues: | ||
raise IssueTrackerDisabled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise IssueTrackerDisabled | |
raise IssueTrackerDisabled() |
owner=project.namespace, repo=project.repo, index=issue_id, | ||
) | ||
except Exception as ex: | ||
raise OperationNotSupported(f"Issue {issue_id} not found") from ex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
operation not supported when the issue is not found?
labels: Optional[list[str]] = None, | ||
) -> list["Issue"]: | ||
if not project.has_issues: | ||
raise IssueTrackerDisabled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise IssueTrackerDisabled | |
raise IssueTrackerDisabled() |
raise IssueTrackerDisabled | ||
|
||
parameters: dict[str, Union[str, list[str], bool]] = { | ||
"state": status if status != IssueStatus.open else "open", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really sure if this produces what you think it does… looking at the definition of IssueStatus
, it is an IntEnum
, I think you'll find out when you start testing it.
issues = project.service.api.issue.list_issues( | ||
owner=project.namespace, repo=project.repo, **parameters, | ||
) | ||
return [ForgejoIssue(issue, project) for issue in issues] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part here is a bit tricky… See packit/packit#2543 (comment) and related notes…
- You don't get a full list, cause it is paginated
- Once you start fetching everything page-by-page, don't construct a list, implement this as an iterator (I'll be committing similar code for
ForgejoProject
today, so you should be able to see basic outline of how it looks like)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally missed it, will do the changes
) | ||
return ForgejoIssueComment(self, comment) | ||
|
||
def _get_all_comments(self) -> list[IssueComment]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here with the pagination
for comment in comments | ||
] | ||
|
||
def _issue_api_call(self, method, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eh… OK… I would probably even go with something like:
def _issue_api_call(self, method, **kwargs): | |
def _api_call(self, method, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m still new to this and learning the ropes, so I appreciate your patience. I’ll implement the suggested changes and do my best to improve, though there might still be a few rookie mistakes along the way. Thanks for understanding! Thanks for the detailed review means a lot !
TODO:
packit/packit.dev
.Fixes #880
RELEASE NOTES BEGIN
ogr now supports Forgejo Issues
RELEASE NOTES END