Skip to content

[BUG] Cannot switch default branch back to master #193

@ghost

Description

Switching default branch to something other than master, then attempting to switch it back to master again results in success being reported, but the default branch not changing back to master.

Problem is here: https://github.com/terraform-providers/terraform-provider-github/blob/master/github/resource_github_repository.go#L248 - it will only ever update default branch if it's NOT master.

Terraform Version

Terraform v0.11.11

  • provider.github v1.3.0

Affected Resource(s)

  • github_repository

Terraform Configuration Files

resource "github_repository" "main" {
    name          = "my-repo-12345"
    private       = true
    auto_init     = true
}

then create develop branch and:

resource "github_repository" "main" {
    name           = "my-repo-12345"
    private        = true
    auto_init      = true
    default_branch = "develop"
}

then:

resource "github_repository" "main" {
    name           = "my-repo-12345"
    private        = true
    auto_init      = true
    default_branch = "master"
}

Expected Behavior

Default branch should be switched back to master once the third step above is run.

Actual Behavior

Default branch is left as develop.

Steps to Reproduce

See config files above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugSomething isn't working as documentedsize/S

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions