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 Forgejo Issues support #896

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

p0tat0chip
Copy link

@p0tat0chip p0tat0chip commented Mar 8, 2025

TODO:

  • Write new tests or update the old ones to cover new functionality.
  • Update or write new documentation in packit/packit.dev.

Fixes #880

RELEASE NOTES BEGIN

ogr now supports Forgejo Issues

  • comment
  • assign labels
  • set title
  • close issue
  • get issues

RELEASE NOTES END

Copy link
Contributor

Copy link
Member

@mfocko mfocko left a 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]
Copy link
Member

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?

Copy link
Author

@p0tat0chip p0tat0chip Mar 10, 2025

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
raise IssueTrackerDisabled
raise IssueTrackerDisabled()

raise IssueTrackerDisabled

parameters: dict[str, Union[str, list[str], bool]] = {
"state": status if status != IssueStatus.open else "open",
Copy link
Member

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.

Comment on lines +128 to +131
issues = project.service.api.issue.list_issues(
owner=project.namespace, repo=project.repo, **parameters,
)
return [ForgejoIssue(issue, project) for issue in issues]
Copy link
Member

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…

  1. You don't get a full list, cause it is paginated
  2. 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)

Copy link
Author

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]:
Copy link
Member

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):
Copy link
Member

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:

Suggested change
def _issue_api_call(self, method, **kwargs):
def _api_call(self, method, **kwargs):

Copy link
Author

@p0tat0chip p0tat0chip Mar 10, 2025

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 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement support for Forgejo issues
2 participants