-
Notifications
You must be signed in to change notification settings - Fork 68
[feat] Forgejo issues and comment / reactions #959
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
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @mfocko, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces robust support for Forgejo's issue and comment functionalities within the ogr library. It provides a complete set of tools for interacting with Forgejo issues, including their creation, retrieval, modification, and lifecycle management, as well as handling comments and reactions for both issues and pull requests. These enhancements aim to integrate Forgejo more deeply into the ogr ecosystem, offering a consistent interface for managing project discussions and tasks. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request adds support for Forgejo issues, comments, and reactions. The implementation looks good overall, but there are a few issues to address. I've found a critical issue in the test setup that would prevent tests from running, a couple of high-severity bugs in the comments and pull_request modules that would lead to runtime errors or incorrect behavior, and several medium-severity issues related to code clarity, redundancy, and exception handling. Please see my detailed comments for suggestions on how to fix them.
| def _get_owner_and_repo(self): | ||
| issue_url = self._raw_comment.issue_url | ||
| parts = urlparse(issue_url).path.strip("/").split("/") | ||
| namespace, repo = parts[0], parts[1] | ||
| return (namespace, repo) |
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.
ogr/services/forgejo/issue.py
Outdated
| 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.
Catching a generic Exception is too broad and can hide other unexpected errors. It's better to catch the specific NotFoundError that pyforgejo is expected to raise when an issue is not found. You are already importing NotFoundError in this file.
| except Exception as ex: | |
| raise OperationNotSupported(f"Issue {issue_id} not found") from ex | |
| except NotFoundError as ex: | |
| raise OperationNotSupported(f"Issue {issue_id} not found") from ex |
| project: "forgejo.ForgejoProject", | ||
| ): | ||
| super().__init__(raw_pr, project) | ||
| self.project = project |
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.
| ) | ||
| ) | ||
| except NotFoundError as ex: | ||
| raise NotFoundError(f"{ex}") 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.
ogr/services/forgejo/pull_request.py
Outdated
| filename: Optional[str] = None, | ||
| row: Optional[int] = None, | ||
| ) -> "PRComment": | ||
| ): |
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.
|
Build failed. ✔️ pre-commit SUCCESS in 2m 59s |
| repo=project.repo, | ||
| title=title, | ||
| body=body, | ||
| labels=labels, |
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.
The labels parameter of the create_issue method is of the Optional[Sequence[int]] type, but the variable that is passed here is of the type Optional[list[str]]. Some sort of conversion is required here.
The docstring of the create_issue method:
labels : typing.Optional[typing.Sequence[int]]
list of label ids
|
Hi @mynk8, I'm following up on your progress on these Forgejo-related features. Is this something you still plan to work on, or would you like us to step in and finish the rest? |
|
Hi, thanks for the follow-up. Please feel free to continue and complete the remaining work. I’m currently focused on other things and won’t be able to take this forward right now. |
Thanks for the quick response. I'll try to finish the remaining parts of this PR, then. Thank you again for your contribution. 🙏 |
|
✔️ pre-commit SUCCESS in 2m 53s |
5c3e840 to
f7ccdf9
Compare
|
✔️ pre-commit SUCCESS in 2m 49s |
|
Build succeeded. ✔️ pre-commit SUCCESS in 3m 22s |
|
❌ pre-commit FAILURE in 2m 45s |
5cc2daf to
8961a0a
Compare
|
Build succeeded. ✔️ pre-commit SUCCESS in 2m 43s |
Co-authored-by: Matej Focko <mfocko@users.noreply.github.com>
In order to be able to record tests and make changes to the testing repo (in order to add more tests), the Packit team's testing repo is now in use. Most failing tests have been fixed and tests were edited to reflect the current state of the testing repo.
Added a method for commenting on issues and fixed the retrieval of comments for compatibility with existing code. Added one test to ensure functionality of these edits.
Previously, the raw issue returned by the Forgejo API wasn't assigned inside the close method, meaning the ForgejoIssue instance wasn't updated and accessing the status property led to receiving the outdated "open" value rather than the expected "closed" value.
8961a0a to
bbcb2cf
Compare
|
Build succeeded. ✔️ pre-commit SUCCESS in 2m 49s |
|
Build succeeded. ✔️ pre-commit SUCCESS in 3m 16s |
It is now possible to delete reactions on comments. During testing, it has been discovered that whenever the get_reactions method is called on a comment with no reactions, pyforgejo raises ApiError. It has also been discovered that re-recording tests results in ValidationError from pydantic, though this error isn't raised again when re-running tests. Further investigation is required.
|
Build succeeded. ✔️ pre-commit SUCCESS in 3m 05s |
TODO:
packit/packit.dev.Fixes #880
Fixes #883
Related to #866
Merge before/after
RELEASE NOTES BEGIN
Ogr now supports Forgejo issues, comments and comment reactions.
RELEASE NOTES END