@@ -465,32 +465,28 @@ func calculateSecurityAndAnalysis(d *schema.ResourceData) *github.SecurityAndAna
465
465
466
466
func resourceGithubRepositoryObject (d * schema.ResourceData ) * github.Repository {
467
467
return & github.Repository {
468
- Name : github .String (d .Get ("name" ).(string )),
469
- Description : github .String (d .Get ("description" ).(string )),
470
- Homepage : github .String (d .Get ("homepage_url" ).(string )),
471
- Visibility : github .String (calculateVisibility (d )),
472
- HasDownloads : github .Bool (d .Get ("has_downloads" ).(bool )),
473
- HasIssues : github .Bool (d .Get ("has_issues" ).(bool )),
474
- HasDiscussions : github .Bool (d .Get ("has_discussions" ).(bool )),
475
- HasProjects : github .Bool (d .Get ("has_projects" ).(bool )),
476
- HasWiki : github .Bool (d .Get ("has_wiki" ).(bool )),
477
- IsTemplate : github .Bool (d .Get ("is_template" ).(bool )),
478
- AllowMergeCommit : github .Bool (d .Get ("allow_merge_commit" ).(bool )),
479
- AllowSquashMerge : github .Bool (d .Get ("allow_squash_merge" ).(bool )),
480
- AllowRebaseMerge : github .Bool (d .Get ("allow_rebase_merge" ).(bool )),
481
- AllowAutoMerge : github .Bool (d .Get ("allow_auto_merge" ).(bool )),
482
- SquashMergeCommitTitle : github .String (d .Get ("squash_merge_commit_title" ).(string )),
483
- SquashMergeCommitMessage : github .String (d .Get ("squash_merge_commit_message" ).(string )),
484
- MergeCommitTitle : github .String (d .Get ("merge_commit_title" ).(string )),
485
- MergeCommitMessage : github .String (d .Get ("merge_commit_message" ).(string )),
486
- DeleteBranchOnMerge : github .Bool (d .Get ("delete_branch_on_merge" ).(bool )),
487
- AutoInit : github .Bool (d .Get ("auto_init" ).(bool )),
488
- LicenseTemplate : github .String (d .Get ("license_template" ).(string )),
489
- GitignoreTemplate : github .String (d .Get ("gitignore_template" ).(string )),
490
- Archived : github .Bool (d .Get ("archived" ).(bool )),
491
- Topics : expandStringList (d .Get ("topics" ).(* schema.Set ).List ()),
492
- AllowUpdateBranch : github .Bool (d .Get ("allow_update_branch" ).(bool )),
493
- SecurityAndAnalysis : calculateSecurityAndAnalysis (d ),
468
+ Name : github .String (d .Get ("name" ).(string )),
469
+ Description : github .String (d .Get ("description" ).(string )),
470
+ Homepage : github .String (d .Get ("homepage_url" ).(string )),
471
+ Visibility : github .String (calculateVisibility (d )),
472
+ HasDownloads : github .Bool (d .Get ("has_downloads" ).(bool )),
473
+ HasIssues : github .Bool (d .Get ("has_issues" ).(bool )),
474
+ HasDiscussions : github .Bool (d .Get ("has_discussions" ).(bool )),
475
+ HasProjects : github .Bool (d .Get ("has_projects" ).(bool )),
476
+ HasWiki : github .Bool (d .Get ("has_wiki" ).(bool )),
477
+ IsTemplate : github .Bool (d .Get ("is_template" ).(bool )),
478
+ AllowMergeCommit : github .Bool (d .Get ("allow_merge_commit" ).(bool )),
479
+ AllowSquashMerge : github .Bool (d .Get ("allow_squash_merge" ).(bool )),
480
+ AllowRebaseMerge : github .Bool (d .Get ("allow_rebase_merge" ).(bool )),
481
+ AllowAutoMerge : github .Bool (d .Get ("allow_auto_merge" ).(bool )),
482
+ DeleteBranchOnMerge : github .Bool (d .Get ("delete_branch_on_merge" ).(bool )),
483
+ AutoInit : github .Bool (d .Get ("auto_init" ).(bool )),
484
+ LicenseTemplate : github .String (d .Get ("license_template" ).(string )),
485
+ GitignoreTemplate : github .String (d .Get ("gitignore_template" ).(string )),
486
+ Archived : github .Bool (d .Get ("archived" ).(bool )),
487
+ Topics : expandStringList (d .Get ("topics" ).(* schema.Set ).List ()),
488
+ AllowUpdateBranch : github .Bool (d .Get ("allow_update_branch" ).(bool )),
489
+ SecurityAndAnalysis : calculateSecurityAndAnalysis (d ),
494
490
}
495
491
}
496
492
@@ -523,6 +519,24 @@ func resourceGithubRepositoryCreate(d *schema.ResourceData, meta interface{}) er
523
519
}
524
520
}
525
521
522
+ // only configure merge commit if we are in commit merge strategy
523
+ allowMergeCommit , ok := d .Get ("allow_merge_commit" ).(bool )
524
+ if ok {
525
+ if allowMergeCommit {
526
+ repoReq .MergeCommitTitle = github .String (d .Get ("merge_commit_title" ).(string ))
527
+ repoReq .MergeCommitMessage = github .String (d .Get ("merge_commit_message" ).(string ))
528
+ }
529
+ }
530
+
531
+ // only configure squash commit if we are in squash merge strategy
532
+ allowSquashMerge , ok := d .Get ("allow_squash_merge" ).(bool )
533
+ if ok {
534
+ if allowSquashMerge {
535
+ repoReq .SquashMergeCommitTitle = github .String (d .Get ("squash_merge_commit_title" ).(string ))
536
+ repoReq .SquashMergeCommitMessage = github .String (d .Get ("squash_merge_commit_message" ).(string ))
537
+ }
538
+ }
539
+
526
540
repoReq .Private = github .Bool (isPrivate )
527
541
528
542
if template , ok := d .GetOk ("template" ); ok {
0 commit comments