Add automatic_rebase_enabled to gitlab_project
What does this MR do and why?
Related issues:
- #6883 — this change
- gitlab-org/api/client-go#2299 (closed) — add
AutomaticRebaseEnabledtoEditProjectOptions, which will let the raw-HTTP helper here be removed - gitlab#623568 (closed) — expose
automatic_rebase_enabledon project read endpoints, which will remove the no-import / no-drift-detection caveat
Adds support for GitLab's automatic rebase before merge
project setting to the gitlab_project resource, so it can be managed with Terraform.
When enabled, GitLab rebases the source branch onto the target branch at merge time if the source branch is behind the target. It applies when the merge method is Fast-forward merge or Merge commit with semi-linear history.
Why the implementation is unusual
automatic_rebase_enabled was added to the projects API in GitLab 19.4 by
gitlab!250632 (merged), and it does not behave like other project attributes:
- It is accepted only by
PUT /projects/:id. The create endpoint ignores it (asserted by an upstream spec inspec/requests/api/projects_spec.rb). - It is never returned by any read endpoint. It is not exposed in
lib/api/entities/project.rb, and not in GraphQL either. The upstream spec for the update path explicitly assertsexpect(json_response).not_to have_key('automatic_rebase_enabled'). - It is not part of
gitlab.EditProjectOptionsinclient-go(checked againstclient-gomain, provider currently pins v2.58.1).
Consequences, all documented on the attribute itself:
- The value is applied with a dedicated raw HTTP
PUTafter create and on update, following the existing raw-HTTP precedent ininternal/provider/resource_gitlab_group_integration_mattermost.go. The helper carries aTODOto switch toeditProjectOptions.AutomaticRebaseEnabledonceclient-gosupports the field. Readdoes not refresh the attribute, because there is nothing to read. Therefore it cannot be imported and changes made outside of Terraform are not detected. Defaults tofalse, matching the GitLab default.
Testing
TestAccGitlabProject_AutomaticRebaseEnabled covers create / import / update / import.
It is gated with testutil.RunIfAtLeast(t, "19.4") and skips on older instances, so it
will not run in CI until GitLab 19.4 is released. Import verification ignores
automatic_rebase_enabled for the reason above.
Verified locally (Go 1.27, make reviewable exit 0):
go build ./...,go vet ./internal/...,go vet -tags acceptance ./internal/provider/sdk/...gofmt -w -s .(no changes),golangci-lint run --build-tags acceptance(0 issues)terraform fmt -recursive ./examples(no changes)tfplugindocs generate(docs in this MR are the generated output)go test ./internal/provider/... ./scripts/...(all pass)
Not run: the new acceptance test, since no released GitLab has the attribute yet.
MR checklist
- Resource attributes match the GitLab API 1:1
- Examples updated (
examples/resources/gitlab_project/resource.tf);import.shalready present - Test with create / update / import steps
- No new
//lintignorecomments