Skip to content

Conversation

@mfocko
Copy link
Member

@mfocko mfocko commented Dec 11, 2025

TODO:

  • Review to check the current state of the PR.
  • Write new tests or update the old ones to cover new functionality.
  • Update doc-strings where appropriate.
  • Update or write new documentation in packit/packit.dev.
  • ‹fill in›

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

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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

  • Forgejo Comments and Reactions: Introduced new classes (ForgejoReaction, ForgejoComment, ForgejoIssueComment, ForgejoPRComment) to provide comprehensive support for managing comments and reactions on Forgejo issues and pull requests.
  • Enhanced Forgejo Issue Management: Significantly expanded the ForgejoIssue class with capabilities to create, retrieve, list, close, and modify issues, including managing assignees and labels.
  • Pull Request Comment Support: Implemented methods for retrieving individual and lists of comments on Forgejo pull requests.
  • API Key Renaming: Standardized the authentication parameter in ForgejoService from api_key to token for consistency.
  • New Integration Tests: Added dedicated integration tests for Forgejo issues, covering listing, creation, closing, and assignee management, ensuring the new functionalities work as expected.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines 43 to 47
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)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This method _get_owner_and_repo is not used anywhere in the codebase. It should be removed to avoid having dead code.

project: "forgejo.ForgejoProject",
):
super().__init__(raw_pr, project)
self.project = project
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The assignment self.project = project is redundant. The parent class BasePullRequest already initializes self._target_project with the project argument, and provides a project property to access it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would leave this be the way it is.

)
)
except NotFoundError as ex:
raise NotFoundError(f"{ex}") from ex
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Re-raising NotFoundError with f"{ex}" as the message is redundant, as it just uses the original exception's message. You can simply re-raise the exception to preserve the original traceback and message.

Suggested change
raise NotFoundError(f"{ex}") from ex
raise

@softwarefactory-project-zuul
Copy link
Contributor

repo=project.repo,
title=title,
body=body,
labels=labels,
Copy link
Contributor

@betulependule betulependule Dec 12, 2025

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

@betulependule
Copy link
Contributor

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?

@mynk8
Copy link
Contributor

mynk8 commented Dec 15, 2025

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.

@betulependule
Copy link
Contributor

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. 🙏

@centosinfra-prod-github-app
Copy link
Contributor

@centosinfra-prod-github-app
Copy link
Contributor

@centosinfra-prod-github-app
Copy link
Contributor

@centosinfra-prod-github-app
Copy link
Contributor

@centosinfra-prod-github-app
Copy link
Contributor

@centosinfra-prod-github-app
Copy link
Contributor

@centosinfra-prod-github-app
Copy link
Contributor

@centosinfra-prod-github-app
Copy link
Contributor

@centosinfra-prod-github-app
Copy link
Contributor

@centosinfra-prod-github-app
Copy link
Contributor

@centosinfra-prod-github-app
Copy link
Contributor

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.
Previously, the title and description setters called the API
properly when editing the title / description. However, the
returned raw issue was discarded, which is no longer the case.
The labels parameter is a list of strings. However, Forgejo API
expects a list of label ids. The implementation of create_issue
has been edited so that when the labels parameter is specified,
the ids of these labels are retrieved from the API. If a label,
that doesn't yet exist, is specified, then a new label is created
via the API and its id is used when creating the issue.
The partial_api would previously add the issue number parameter
when making an API call based on what method was being used.
This part of implementation has been removed to make the code
easier to understand.
Previously, trying to retrieve issues of a nonexistent author, an
empty list was returned. Raising an exception instead makes it more
clear that something went wrong.
It is not necessary to check whether the assignee object has the
login attribute.
Previously when adding an assignee would not update the raw issue
stored inside the Issue object. A test has been added to cover
this fix.
This is so that the exception is the same as when trying the same
via the Github API.
The __update_info method was brought back for this. The add_label
method defined by pyforgejo's API doesn't return the updated issue,
so it  has to be retrieved separately.
Previously, the list of existing labels had to be retrieved from
the API so that ids of labels to be added could be determined.
When adding a non-existent label, it had to be created by a
separate API call as well, leading to somewhat hard-to-understand
code. This code has been removed and instead, an issue is always
created without any labels and then the add_label is called
instead, leading to two more API calls being made whenever labels
are to be added to the issue (regardless of the amount of labels).
@centosinfra-prod-github-app
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: new

Development

Successfully merging this pull request may close these issues.

Implement support for Forgejo comments and reactions on it Implement support for Forgejo issues

4 participants