Skip to content

azuredevops_git_repository - Support author for the initial commit of Clean initialization - #1634

Open
Niclas Grande (ngrande) wants to merge 1 commit into
microsoft:mainfrom
ngrande:feat/git-repository-initialization-author
Open

Niclas Grande (ngrande) wants to merge 1 commit into
microsoft:mainfrom
ngrande:feat/git-repository-initialization-author

Conversation

@ngrande

@ngrande Niclas Grande (ngrande) commented Dec 4, 2026 •

Copy link
Copy Markdown

All Submissions:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My code follows the code style of this project.
  • Have you checked to ensure there aren't other open PRs for the same update/change?

Description

With init_type = "Clean", the provider creates the initial commit through the Push API without an author or committer. Azure DevOps then uses the identity that creates the repository. For a service principal (a typical pipeline identity), that commit has an empty author email.

If the project has a commit author email policy (azuredevops_repository_policy_author_email_pattern), the push is rejected:

Error: initializing repository in Azure DevOps: VS403702: The push was rejected because one or more commits contain author email '' which does not match the policy-specified patterns.

The repository is created but stays tainted in the state. The next plan replaces it, and the replacement fails the same way. Today the only ways out are to weaken the policy or to create repositories by hand.

This PR adds two optional arguments to the initialization block:

  • author_name
  • author_email

If either is set, they are used as author and committer of the initial commit. If neither is set, the behaviour is unchanged (no author sent).

resource "azuredevops_git_repository" "example" {
  project_id     = azuredevops_project.example.id
  name           = "example"
  default_branch = "refs/heads/main"

  initialization {
    init_type    = "Clean"
    author_name  = "Pipeline"
    author_email = "pipeline@example.com"
  }
}

Does this introduce a breaking change?

  • Yes
  • No

Both arguments are optional; without them the request is identical to today's.

Test Result

Unit tests (go test -tags all ./azuredevops/internal/service/git/):

--- PASS: TestGitRepo_Initialize_UsesTheDefaultBranch (0.00s)
--- PASS: TestGitRepo_Initialize_UsesTheConfiguredAuthor (0.00s)
--- PASS: TestGitRepo_InitializationAuthor_NilWhenNotConfigured (0.00s)
ok  	github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/service/git

go build ./..., go vet and gofmt are clean. golangci-lint v2.12 on the package reports only the six findings that already exist on main.

Acceptance tests not run: I have no Azure DevOps organization set up for them.

Related Issue(s)

None found for this case.

🤖 Generated with Claude Code

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