Add automatic_rebase_enabled to gitlab_project

What does this MR do and why?

Related issues:

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:

  1. It is accepted only by PUT /projects/:id. The create endpoint ignores it (asserted by an upstream spec in spec/requests/api/projects_spec.rb).
  2. 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 asserts expect(json_response).not_to have_key('automatic_rebase_enabled').
  3. It is not part of gitlab.EditProjectOptions in client-go (checked against client-go main, provider currently pins v2.58.1).

Consequences, all documented on the attribute itself:

  • The value is applied with a dedicated raw HTTP PUT after create and on update, following the existing raw-HTTP precedent in internal/provider/resource_gitlab_group_integration_mattermost.go. The helper carries a TODO to switch to editProjectOptions.AutomaticRebaseEnabled once client-go supports the field.
  • Read does 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 to false, 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.sh already present
  • Test with create / update / import steps
  • No new //lintignore comments

Merge request reports

Loading
Loading