Implement FillInMergeRequestTemplate AI action
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 toresource
) -
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.
-
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.
-
Follow testing guide for AI features: https://docs.gitlab.com/ee/development/ai_features.html#test-ai-features-locally.
-
Enable
fill_in_mr_template
feature flag. -
Push some changes to a branch (e.g.
dev
). -
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 } }
-
Watch
log/llm.log
(tail -f log/llm.log
undergitlab/
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.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #409509 (closed)