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.

Comment on lines 132 to 144
except Exception as ex:
raise OperationNotSupported(f"Issue {issue_id} not found") 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

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.

Suggested change
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
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.

)
)
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

filename: Optional[str] = None,
row: Optional[int] = None,
) -> "PRComment":
):
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 return type annotation -> "PRComment" was removed from the method signature. It should be restored for type consistency and clarity.

Suggested change
):
) -> "PRComment":

@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

mynk8 and others added 8 commits December 19, 2025 10:41
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.
@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.
@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

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