From c3c2480dc8742619759ab6cf3f138d0c489ede8f Mon Sep 17 00:00:00 2001 From: CEbbinghaus Date: Tue, 15 Oct 2024 16:31:16 +1100 Subject: [PATCH] Fixed renaming if the branch names are identical --- github/resource_github_branch_default.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/github/resource_github_branch_default.go b/github/resource_github_branch_default.go index 91df5694f..e3888128e 100644 --- a/github/resource_github_branch_default.go +++ b/github/resource_github_branch_default.go @@ -147,6 +147,12 @@ func resourceGithubBranchDefaultUpdate(d *schema.ResourceData, meta interface{}) if err != nil { return err } + + // We don't want to rename branch if its already the default branch + if defaultBranch == *repository.DefaultBranch { + return nil + } + if _, _, err := client.Repositories.RenameBranch(ctx, owner, repoName, *repository.DefaultBranch, defaultBranch); err != nil { return err }