Skip to content

Implement FillInMergeRequestTemplate AI action

Patrick Bajao requested to merge 409509-fill-in-merge-request-template-be into master

What does this MR do and why?

Adds support for fillInMergeRequestTemplate input for aiAction that has the following arguments:

  • resourceId (required) - project where the MR will be created on
  • title (required) - title of the MR to be created
  • sourceProjectId (optional, defaults to resource)
  • sourceBranch (required)
  • targetBranch (required)
  • content (required)

The sourceBranch and targetBranch will be used to compare the changes between those branches so we can get the diff to send to the AI provider. That's why it's required.

The sourceProjectId is needed for forks so we can compare the changes made on the fork's source branch with the target branch.

Sections in the template content can add <!-- AI Skip --> to the body to ensure that AI won't touch the section.

This uses Vertex AI as the AI provider.

This is behind the fill_in_mr_template feature flag.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Follow https://docs.gitlab.com/ee/development/ai_features.html#configure-gcp-vertex-access for configuring local environment to be able to work with VertexAI.

  2. Follow testing guide for AI features: https://docs.gitlab.com/ee/development/ai_features.html#test-ai-features-locally.

  3. Enable fill_in_mr_template feature flag.

  4. Push some changes to a branch (e.g. dev).

  5. Make a GraphQL request:

    Example (test it with other arguments as well):

    mutation {
      aiAction(input: {fillInMergeRequestTemplate: {resourceId: "gid://gitlab/Project/<project ID>", sourceBranch: "dev", targetBranch: "main", title: "Add some files", content: "## What does this MR do and why?\n\n_Describe in detail what your merge request does and why._"}}) {
        errors
      }    
    }
  6. Watch log/llm.log (tail -f log/llm.log under gitlab/ directory) and see that it makes a request to Vertex AI and see its response.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #409509 (closed)

Edited by Patrick Bajao

Merge request reports

Loading