Skip to content
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

fix gitlab automatic deletion bug #1905

Merged
merged 4 commits into from
Mar 17, 2025

Conversation

motatoes
Copy link
Contributor

@motatoes motatoes commented Mar 17, 2025

When mergerequest in gitlab has automatic deletion of source branch then digger would try to load the branch digger.yml and then post an error comment of failing to load digger.yml. We add additional check to avoid this so if the source branch does not exist we ignore that event all together

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Added functionality to automatically handle merged pull requests by checking branch existence and managing deletion.
    • Enhanced GitLab integration with new methods for retrieving branch information and verifying branch existence.
  • Bug Fixes
    • Improved error handling for branch retrieval and existence checks, ensuring graceful failure and logging.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here: app.greptile.com/review/github.

3 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Copy link
Contributor

coderabbitai bot commented Mar 17, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The changes update pull request event handling by introducing a new action variable to identify merge actions in the payload. When a merge event is detected, the system retrieves the source branch name and checks its existence. Errors during retrieval or a missing branch trigger logged error comments and cause an early return. Additionally, in the GitLab service, the GetBranchName method is enhanced to fetch complete branch details with proper error logging, and a new CheckBranchExists method is implemented to verify branch existence via the GitLab API.

Changes

File(s) Change Summary
ee/backend/controllers/gitlab.go Added variable action to detect merge actions; updated logic to retrieve the source branch and check its existence, with error handling and logging for merge events.
libs/ci/gitlab/gitlab.go Enhanced GetBranchName to fetch branch details with improved logging and error handling; added new CheckBranchExists method to verify branch existence using the GitLab API.

Sequence Diagram(s)

sequenceDiagram
    participant G as GitLab Event
    participant C as Controller (handlePullRequestEvent)
    participant S as GitLabService
    G->>C: Trigger pull request event (merge)
    C->>S: GetBranchName(prNumber)
    S-->>C: Return branch name & SHA
    C->>S: CheckBranchExists(branchName)
    S-->>C: Return branch existence result
    alt Branch exists
        C->>G: Proceed with merge handling
    else Branch missing
        C->>C: Log error and exit gracefully
    end
Loading

Poem

I hopped through the code with glee,
Merging events as smooth as can be.
Branches checked with a twinkle in my eye,
Errors logged as they float by.
In lines of code, we joyfully play—
A rabbit’s ode to a brand new day! 🐇

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3a5f514 and f3a2a72.

📒 Files selected for processing (2)
  • ee/backend/controllers/gitlab.go (2 hunks)
  • libs/ci/gitlab/gitlab.go (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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

@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 (3)
.github/workflows/ee_cli_release_multiarch.yml (1)

29-44: Consolidated Build and Publish Step – Verify Matrix Usage for ldflags

The new step using wangyoucao577/go-release-action is clearly a welcome simplification for building and publishing multi-architecture binaries. However, the parameter

ldflags: ${{ matrix.ldflags }}

raises a concern because the static analysis hints indicate that the ldflags property might not be defined in the current object type. Please verify that your workflow matrix actually defines an ldflags variable or consider providing a default value if it is optional.

🧰 Tools
🪛 actionlint (1.7.4)

40-40: property "ldflags" is not defined in object type {arch: string; os: string}

(expression)

.github/workflows/cli_release.yml (1)

19-34: Updated Single-Architecture Release Step – Validate ldflags Parameter Source

The consolidation of the build and release process using the wangyoucao577/go-release-action makes the workflow both cleaner and more maintainable. One concern is the use of the expression

ldflags: ${{ matrix.ldflags }}

even though this job appears to target a fixed architecture without an explicitly defined matrix. Please double-check whether the ldflags value is coming from another source or if it should be replaced by a constant or parameter more appropriate to this static configuration.

🧰 Tools
🪛 actionlint (1.7.4)

30-30: property "ldflags" is not defined in object type {}

(expression)

.github/workflows/ee_cli_release.yml (1)

25-40: EE CLI Release Step – Confirm Environment Setup and Parameter Consistency

The revised step using wangyoucao577/go-release-action effectively combines the build and release operations. Two points need attention:

  1. The use of
    ldflags: ${{ matrix.ldflags }}
    
    again suggests a dependency on a matrix variable, yet the job does not show an explicit matrix definition. Please verify whether this is intentional or if a fixed value should be set.
  2. The workflow still includes a “Download Go” step (lines 16–20). Since the new action encapsulates environment setup, consider whether this step is redundant and can be removed to further streamline the workflow.
🧰 Tools
🪛 actionlint (1.7.4)

36-36: property "ldflags" is not defined in object type {}

(expression)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b5d23f9 and 3a5f514.

📒 Files selected for processing (3)
  • .github/workflows/cli_release.yml (1 hunks)
  • .github/workflows/ee_cli_release.yml (1 hunks)
  • .github/workflows/ee_cli_release_multiarch.yml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/ee_cli_release_multiarch.yml

40-40: property "ldflags" is not defined in object type {arch: string; os: string}

(expression)

.github/workflows/cli_release.yml

30-30: property "ldflags" is not defined in object type {}

(expression)

.github/workflows/ee_cli_release.yml

36-36: property "ldflags" is not defined in object type {}

(expression)

⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Build
  • GitHub Check: Build
  • GitHub Check: Build
  • GitHub Check: Build
  • GitHub Check: Build
  • GitHub Check: Build
  • GitHub Check: Build
  • GitHub Check: Build
  • GitHub Check: Build
  • GitHub Check: Build

@motatoes motatoes changed the title add binaries to published artefacts fix gitlab automatic deletion bug Mar 17, 2025
@motatoes motatoes merged commit b38a438 into develop Mar 17, 2025
11 checks passed
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