Skip to content

gitlab mr 状态可配置 #52

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MellowCo
Copy link

@MellowCo MellowCo commented Jul 19, 2025

满足不同gitlab版本state,merge_status

Summary by CodeRabbit

  • New Features

    • Added support for configurable GitLab merge request status handling, allowing for more flexible recognition of merge request states.
  • Documentation

    • Updated configuration documentation to describe the new GitLab merge request status parameter and provide additional reference information.

Copy link

coderabbitai bot commented Jul 19, 2025

Walkthrough

A new configuration constant, GITLAB_MERGE_REQUEST_STATUS, was introduced to centralize GitLab merge request state/merge status combinations. The function is_merge_request_opened was refactored to use this new configuration for status checks, and related documentation was updated to describe the new parameter.

Changes

File(s) Change Summary
config/config.py Added GITLAB_MERGE_REQUEST_STATUS constant for GitLab merge request state/status combinations.
doc/config.md Documented the new GITLAB_MERGE_REQUEST_STATUS config parameter and made a minor formatting fix.
gitlab_integration/gitlab_fetcher.py Refactored is_merge_request_opened to use the new config constant; added relevant import.

Sequence Diagram(s)

sequenceDiagram
    participant GitLab
    participant Fetcher as gitlab_fetcher.py
    participant Config as config.py

    GitLab->>Fetcher: Send merge request payload
    Fetcher->>Config: Access GITLAB_MERGE_REQUEST_STATUS
    Fetcher->>Fetcher: Check payload's state/merge_status against config list
    alt Match found
        Fetcher->>GitLab: Return True (opened)
    else No match
        Fetcher->>GitLab: Return False (not opened)
    end
Loading

Possibly related PRs

Poem

In the warren of code, a change takes root,
Configs now guide what statuses suit.
No more hardcoded, the logic is neat—
Merge requests checked by a list complete.
With docs refreshed and functions refined,
This rabbit hops forward, with clarity in mind! 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
config/config.py (1)

88-93: Consider clarifying the commented-out merge status entry.

The Chinese comment questioning whether review is needed after merge suggests uncertainty about the business logic. Consider either:

  1. Removing the commented code if post-merge review isn't required
  2. Adding clear documentation about when this configuration should be enabled
- # 这个好像是合并后触发的状态,合并后还需要review吗?
- # {
- #   "state": "merged",
- #   "merge_status": "can_be_merged"
- # }
+ # Uncomment the following entry if post-merge review is required
+ # {
+ #   "state": "merged", 
+ #   "merge_status": "can_be_merged"
+ # }
gitlab_integration/gitlab_fetcher.py (1)

12-12: Remove redundant import.

This explicit import is unnecessary since line 9 already imports all symbols from config.config using from config.config import *.

-from config.config import GITLAB_MERGE_REQUEST_STATUS
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f6a03a9 and 2716b22.

📒 Files selected for processing (3)
  • config/config.py (1 hunks)
  • doc/config.md (1 hunks)
  • gitlab_integration/gitlab_fetcher.py (2 hunks)
🔇 Additional comments (4)
config/config.py (1)

76-93: Well-structured configuration for GitLab version compatibility.

The new GITLAB_MERGE_REQUEST_STATUS constant provides a clean, extensible way to handle different GitLab version requirements. The structure with dictionaries containing state and merge_status pairs is intuitive and maintainable.

doc/config.md (2)

81-81: Good documentation addition with helpful reference.

The documentation clearly describes the new configuration parameter and provides a link to the relevant GitHub issue for additional context about GitLab version differences.


85-85: Minor formatting improvement.

Adding the newline improves consistency in the documentation format.

gitlab_integration/gitlab_fetcher.py (1)

213-222: Excellent refactoring to use configuration-driven approach.

The function now dynamically checks merge request status against the configurable GITLAB_MERGE_REQUEST_STATUS list, making it much more maintainable and adaptable to different GitLab versions. The logic is clear and the exception handling is preserved appropriately.

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.

1 participant