Skip to content

Commit 98629a4

Browse files
authored
Merge branch 'main' into explicit_web_commit_signoff_required
2 parents 192ce70 + 256cdd8 commit 98629a4

12 files changed

Lines changed: 627 additions & 204 deletions

github/repository_utils.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@ import (
99
"strings"
1010

1111
"github.com/google/go-github/v82/github"
12+
"github.com/hashicorp/terraform-plugin-log/tflog"
1213
)
1314

1415
// checkRepositoryBranchExists tests if a branch exists in a repository.
15-
func checkRepositoryBranchExists(client *github.Client, owner, repo, branch string) error {
16-
ctx := context.WithValue(context.Background(), ctxId, buildTwoPartID(repo, branch))
16+
func checkRepositoryBranchExists(ctx context.Context, client *github.Client, owner, repo, branch string) error {
17+
tflog.Debug(ctx, "Checking if branch exists", map[string]any{
18+
"branch": branch,
19+
"owner": owner,
20+
"repo": repo,
21+
})
1722
_, _, err := client.Repositories.GetBranch(ctx, owner, repo, branch, 2)
1823
if err != nil {
1924
var ghErr *github.ErrorResponse

github/resource_github_emu_group_mapping.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func resourceGithubEMUGroupMapping() *schema.Resource {
2424
Description: "Manages the mapping of an external group to a GitHub team.",
2525
Schema: map[string]*schema.Schema{
2626
"team_id": {
27-
Type: schema.TypeString,
27+
Type: schema.TypeInt,
2828
Computed: true,
2929
Description: "ID of the GitHub team.",
3030
},
@@ -99,7 +99,7 @@ func resourceGithubEMUGroupMappingCreate(ctx context.Context, d *schema.Resource
9999
return diag.FromErr(err)
100100
}
101101

102-
if err := d.Set("team_id", teamID); err != nil {
102+
if err := d.Set("team_id", int(teamID)); err != nil {
103103
return diag.FromErr(err)
104104
}
105105

@@ -334,7 +334,7 @@ func resourceGithubEMUGroupMappingImport(ctx context.Context, d *schema.Resource
334334
return nil, err
335335
}
336336

337-
if err := d.Set("team_id", teamID); err != nil {
337+
if err := d.Set("team_id", int(teamID)); err != nil {
338338
return nil, err
339339
}
340340

github/resource_github_emu_group_mapping_migration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func resourceGithubEMUGroupMappingStateUpgradeV0(ctx context.Context, rawState m
5656
if err != nil {
5757
return nil, err
5858
}
59-
rawState["team_id"] = teamID
59+
rawState["team_id"] = int(teamID)
6060
resourceID, err := buildID(strconv.FormatInt(teamID, 10), teamSlug, strconv.FormatInt(group.GetGroupID(), 10))
6161
if err != nil {
6262
return nil, err

github/resource_github_repository.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -628,9 +628,11 @@ func resourceGithubRepositoryObject(d *schema.ResourceData) *github.Repository {
628628
}
629629

630630
// only configure allow forking if repository is not public
631-
if allowForking, ok := d.GetOkExists("allow_forking"); ok && visibility != "public" { //nolint:staticcheck,SA1019 // We sometimes need to use GetOkExists for booleans
632-
if val, ok := allowForking.(bool); ok {
633-
repository.AllowForking = github.Ptr(val)
631+
if visibility != "public" && (d.IsNewResource() || d.HasChange("allow_forking")) {
632+
if allowForking, ok := d.GetOkExists("allow_forking"); ok { //nolint:staticcheck,SA1019 // We sometimes need to use GetOkExists for booleans
633+
if val, ok := allowForking.(bool); ok {
634+
repository.AllowForking = github.Ptr(val)
635+
}
634636
}
635637
}
636638

0 commit comments

Comments
 (0)