Skip to content

feat: Add comment strategy support for Gitea provider#2503

Merged
chmouel merged 3 commits intotektoncd:mainfrom
chmouel:SRVKP-10900-add-gitea-comment-strategy
Feb 25, 2026
Merged

feat: Add comment strategy support for Gitea provider#2503
chmouel merged 3 commits intotektoncd:mainfrom
chmouel:SRVKP-10900-add-gitea-comment-strategy

Conversation

@chmouel
Copy link
Copy Markdown
Member

@chmouel chmouel commented Feb 24, 2026

📝 Description of the Change

Added comment_strategy configuration to the Gitea provider settings to control how pipeline result comments are handled on pull requests.

Features:

  • disable_all: Prevents status comments from being created on pull requests
  • update: Modifies a single existing comment per PipelineRun instead of creating new ones on every trigger

Changes:

  • Added comment_strategy field to repository configuration
  • Implemented comment strategy support in Gitea provider
  • Updated status creation methods to accept execution context for proper comment handling
  • Fixed update marker regex by escaping meta characters
  • Added comprehensive unit and e2e tests

Gitea provider now supports configuration of how pipeline status comments are created on pull requests through the new comment_strategy field. This allows users to either disable comments entirely or update a single comment per PipelineRun instead of creating multiple comments.

👨🏻‍ Linked Jira

Jira: https://issues.redhat.com/browse/SRVKP-10900

🔗 Linked GitHub Issue

🚀 Type of Change

  • ✨ New feature (feat:)

🧪 Testing Strategy

  • Unit tests
  • End-to-end tests

🤖 AI Assistance

  • I have used AI assistance for this PR.

Which LLM was used?

  • Claude (Anthropic)

Extent of AI Assistance:

  • Code generation (parts of the code)

✅ Submitter Checklist

  • 📝 My commit messages are clear, informative, and follow the project's How to write a git commit message guide. The Gitlint linter ensures in CI it's properly validated
  • ✨ I have ensured my commit message prefix (e.g., fix:, feat:) matches the "Type of Change" I selected above.
  • ♽ I have run make test and make lint locally to check for and fix any issues. For an efficient workflow, I have considered installing pre-commit and running pre-commit install to automate these checks.
  • 📖 I have added or updated documentation for any user-facing changes.
  • 🧪 I have added sufficient unit tests for my code changes.
  • 🎁 I have added end-to-end tests where feasible. See README for more details.
  • 🔎 I have addressed any CI test flakiness or provided a clear reason to bypass it.
  • If adding a provider feature, I have filled in the following and updated the provider documentation:
    • Gitea/Forgejo

Copilot AI review requested due to automatic review settings February 24, 2026 08:52
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @chmouel, 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 enhances the Gitea provider by introducing configurable comment strategies for pipeline results on pull requests. Users can now choose to disable all comments or have a single comment updated for each PipelineRun, providing more control over the communication flow. The changes also include necessary refactoring to pass execution context to status creation methods and a crucial fix for regex handling to ensure robust comment management.

Highlights

  • Gitea Comment Strategy Configuration: Introduced a new comment_strategy field within the Gitea settings for repositories, allowing users to control how pipeline result comments are managed on Gitea/Forgejo pull requests. Supported options include disable_all to prevent any status comments and update to modify a single existing comment per PipelineRun instead of creating new ones.
  • Context Propagation for Status Creation: Modified the CreateStatus and createStatusCommit methods in the Gitea provider to accept context.Context, enabling better control and cancellation of operations, particularly for the new comment update functionality.
  • Regex Fix for Update Marker: Corrected a potential bug in the Gitea provider by escaping meta characters in the updateMarker regex using regexp.QuoteMeta, ensuring accurate matching and preventing unintended behavior when updating comments.
  • Comment Formatting and Normalization: Implemented a new formatPipelineComment function to standardize the appearance of pipeline status comments, including emoji based on status and proper newline normalization for HTML <br> tags.
Changelog
  • config/300-repositories.yaml
    • Added gitea section to repository settings schema, including comment_strategy with disable_all and update enum options.
  • pkg/apis/pipelinesascode/v1alpha1/types.go
    • Introduced GiteaSettings struct to define Gitea-specific configurations.
    • Added Gitea field to the Settings struct.
    • Implemented merge logic for GiteaSettings within the Merge method.
  • pkg/provider/gitea/gitea.go
    • Fixed updateMarker regex by wrapping it with regexp.QuoteMeta to correctly escape special characters.
    • Updated CreateStatus and createStatusCommit function signatures to accept context.Context.
    • Implemented logic within createStatusCommit to handle disable_all and update comment strategies.
    • Added a new formatPipelineComment function to format pipeline status comments with emojis and proper markdown.
  • pkg/provider/gitea/gitea_test.go
    • Imported pkg/provider and gotest.tools/v3/golden packages.
    • Updated calls to createStatusCommit to pass context.Background().
    • Added TestCreateStatusUpdateCommentNormalizesBreaks to verify HTML <br> tags are converted to newlines in comments.
    • Added TestFormatPipelineCommentEmoji to test the correct emoji selection based on pipeline status.
  • pkg/provider/gitea/testdata/TestCreateStatusUpdateCommentNormalizesBreaks.golden
    • Added a golden file containing the expected JSON body for a Gitea comment after normalization.
  • pkg/provider/provider.go
    • Updated IsCommentStrategyUpdate function to check for Gitea settings in addition to GitLab and GitHub.
  • pkg/webhook/validation.go
    • Added allowedGiteaCommentStrategyOnPr set for validating Gitea comment strategies.
    • Implemented validation logic for Gitea comment_strategy in the Admit function.
  • test/gitea_gitops_commands_test.go
    • Imported pkg/provider package.
    • Configured CommentStrategy to provider.UpdateCommentStrategy for Gitea settings in TestGiteaRetestAll.
Activity
  • The pull request description includes a detailed checklist for various aspects like commit messages, testing, documentation, and AI assistance, indicating thorough self-review by the author.
  • No human comments or reviews have been posted on this pull request yet.
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.

@pipelines-as-code
Copy link
Copy Markdown

pipelines-as-code bot commented Feb 24, 2026

🔍 PR Lint Feedback

Note: This automated check helps ensure your PR follows our contribution guidelines.

⚠️ Items that need attention:

🤖 AI attribution

The following commits lack an explicit AI attribution footer:

  • cdf8e93 feat: Add comment strategy support for Foregejo

If no AI assistance was used for a commit, you can ignore this warning.
Otherwise add an Assisted-by: or Co-authored-by: footer referencing the AI used.


ℹ️ Next Steps

  • Review and address the items above
  • Push new commits to update this PR
  • This comment will be automatically updated when issues are resolved
🔧 Admin Tools (click to expand)

Automated Issue/Ticket Creation:

  • /issue-create - Generate a GitHub issue from this PR content using AI
  • /jira-create - Create a SRVKP Jira ticket from this PR content using AI

⚠️ Important: Always review and edit generated content before finalizing tickets/issues.
The AI-generated content should be used as a starting point and may need adjustments.

These commands are available to maintainers and will post the generated content as PR comments for review.

🤖 This feedback was generated automatically by the PR CI system

@pipelines-as-code pipelines-as-code bot added enhancement New feature or request feature New feature or request gitea labels Feb 24, 2026
- roles
- secret_ref
type: object
gitea:
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I can't remember the reasoning we have gitea or gitlab or githu specific settings when we could have just settings.comment_strategy shared across, i hate it, but this ship has sailed i guess

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I am changing this to forgejo, since this is user changes and we don't want to introduce a backward compatibility

Copy link
Copy Markdown

@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 comment_strategy to the Gitea provider, aligning its functionality with other providers like GitHub and GitLab. The changes include updates to the CRD, Go types, Gitea provider implementation, and validation webhook. The implementation correctly handles the disable_all and update strategies. Additionally, a bug in the comment update logic has been fixed by properly escaping regex meta-characters. The test coverage for the new functionality is good.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds comment_strategy configuration support to the Gitea/Forgejo provider, bringing it to feature parity with the existing GitHub and GitLab providers. The implementation allows users to control how pipeline result comments are posted on pull requests by supporting two strategies: disable_all (prevents all status comments) and update (updates a single comment per PipelineRun instead of creating new ones on every trigger).

Changes:

  • Added GiteaSettings type with CommentStrategy field to repository settings API
  • Implemented comment strategy logic in the Gitea provider to support disable_all and update strategies
  • Fixed the update marker regex by escaping meta characters using regexp.QuoteMeta for proper comment matching

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/apis/pipelinesascode/v1alpha1/types.go Added GiteaSettings struct with CommentStrategy field and updated Settings.Merge to handle Gitea settings
config/300-repositories.yaml Added CRD schema definition for gitea.comment_strategy with validation enum
pkg/webhook/validation.go Added validation logic to ensure only valid comment strategy values are accepted for Gitea
pkg/provider/provider.go Extended IsCommentStrategyUpdate function to check Gitea settings alongside GitHub and GitLab
pkg/provider/gitea/gitea.go Implemented comment strategy handling, added formatPipelineComment method, and fixed regex escaping
pkg/provider/gitea/gitea_test.go Added tests for comment formatting and
normalization in update comments
test/gitea_gitops_commands_test.go Added integration test using update comment strategy
pkg/provider/gitea/testdata/TestCreateStatusUpdateCommentNormalizesBreaks.golden Golden file for test verification

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chmouel chmouel force-pushed the SRVKP-10900-add-gitea-comment-strategy branch from 8fc2cc0 to 1d1f047 Compare February 24, 2026 09:16
Copy link
Copy Markdown

@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 comment_strategy to the Gitea provider, allowing users to control how pipeline status comments are posted on pull requests. The implementation is clean and includes new configurations in the CRD, provider logic to handle the strategies (disable_all, update), and comprehensive tests. The changes are consistent with existing features for other providers. The previously identified minor issue regarding an incomplete merge function remains valid and has been kept.

Comment on lines +213 to +215
if newSettings.Gitea != nil && s.Gitea == nil {
s.Gitea = newSettings.Gitea
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This Merge function is missing logic for Github and Gitlab settings. While adding the merge logic for Gitea, we should also add it for the other providers for consistency and to ensure global settings are correctly applied as defaults.

	if newSettings.Gitea != nil && s.Gitea == nil {
		s.Gitea = newSettings.Gitea
	}
	if newSettings.Github != nil && s.Github == nil {
		s.Github = newSettings.Github
	}
	if newSettings.Gitlab != nil && s.Gitlab == nil {
		s.Gitlab = newSettings.Gitlab
	}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

we maybe need to double check this

@chmouel chmouel force-pushed the SRVKP-10900-add-gitea-comment-strategy branch from 1d1f047 to 1dbe476 Compare February 24, 2026 10:13
@chmouel chmouel force-pushed the SRVKP-10900-add-gitea-comment-strategy branch from 1dbe476 to 975723b Compare February 24, 2026 13:10
Added `comment_strategy` configuration to the Foregejo/Gitea provider settings
to control how pipeline result comments were handled on pull requests.
Supported options included `disable_all` to prevent status comments
and `update` to modify a single existing comment per PipelineRun
instead of creating new ones on every trigger. Passed the execution
context to the status creation methods to support the updated comment
functionality and fixed the update marker regex by escaping meta
characters.

Jira: https://issues.redhat.com/browse/SRVKP-10900
Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
@chmouel chmouel force-pushed the SRVKP-10900-add-gitea-comment-strategy branch from 975723b to cdf8e93 Compare February 24, 2026 13:15
@chmouel chmouel merged commit e5302e0 into tektoncd:main Feb 25, 2026
5 checks passed
@chmouel chmouel deleted the SRVKP-10900-add-gitea-comment-strategy branch February 25, 2026 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request feature New feature or request gitea

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants