Skip to content

Commit

Permalink
Fixed logic
Browse files Browse the repository at this point in the history
  • Loading branch information
CEbbinghaus committed Oct 15, 2024
1 parent c3c2480 commit 354adbb
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions github/resource_github_branch_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,10 @@ func resourceGithubBranchDefaultUpdate(d *schema.ResourceData, meta interface{})
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
if defaultBranch != *repository.DefaultBranch {
if _, _, err := client.Repositories.RenameBranch(ctx, owner, repoName, *repository.DefaultBranch, defaultBranch); err != nil {
return err
}
}
} else {
repository := &github.Repository{
Expand Down

0 comments on commit 354adbb

Please sign in to comment.