@@ -17,9 +17,10 @@ import (
1717
1818// BranchingModel is the data we need to send to create a new branching model for the repository
1919type BranchingModel struct {
20- Development * BranchModel `json:"development,omitempty"`
21- Production * BranchModel `json:"production,omitempty"`
22- BranchTypes []* BranchType `json:"branch_types"`
20+ Development * BranchModel `json:"development,omitempty"`
21+ Production * BranchModel `json:"production,omitempty"`
22+ BranchTypes []* BranchType `json:"branch_types"`
23+ DefaultBranchDeletion * bool `json:"default_branch_deletion,omitempty"`
2324}
2425
2526type BranchModel struct {
@@ -138,6 +139,10 @@ func resourceBranchingModel() *schema.Resource {
138139 },
139140 },
140141 },
142+ "default_branch_deletion" : {
143+ Type : schema .TypeBool ,
144+ Optional : true ,
145+ },
141146 },
142147 }
143148}
@@ -172,7 +177,7 @@ func resourceBranchingModelsPut(ctx context.Context, d *schema.ResourceData, m i
172177 return diag .FromErr (decodeerr )
173178 }
174179
175- d .SetId (string ( fmt .Sprintf ("%s/%s" , d .Get ("owner" ).(string ), d .Get ("repository" ).(string ) )))
180+ d .SetId (fmt .Sprintf ("%s/%s" , d .Get ("owner" ).(string ), d .Get ("repository" ).(string )))
176181
177182 return resourceBranchingModelsRead (ctx , d , m )
178183}
@@ -221,6 +226,7 @@ func resourceBranchingModelsRead(ctx context.Context, d *schema.ResourceData, m
221226
222227 d .Set ("owner" , owner )
223228 d .Set ("repository" , repo )
229+ d .Set ("default_branch_deletion" , branchingModel .DefaultBranchDeletion )
224230 d .Set ("development" , flattenBranchModel (branchingModel .Development , "development" ))
225231 d .Set ("branch_type" , flattenBranchTypes (branchingModel .BranchTypes ))
226232 d .Set ("production" , flattenBranchModel (branchingModel .Production , "production" ))
@@ -262,6 +268,11 @@ func expandBranchingModel(d *schema.ResourceData) *BranchingModel {
262268 model .BranchTypes = make ([]* BranchType , 0 )
263269 }
264270
271+ //nolint:staticcheck
272+ if v , ok := d .GetOkExists ("default_branch_deletion" ); ok {
273+ model .DefaultBranchDeletion = v .(* bool )
274+ }
275+
265276 return model
266277}
267278
@@ -383,7 +394,7 @@ func branchingModelId(id string) (string, string, error) {
383394 parts := strings .Split (id , "/" )
384395
385396 if len (parts ) != 2 {
386- return "" , "" , fmt .Errorf ("Unexpected format of ID (%q), expected OWNER/REPOSITORY" , id )
397+ return "" , "" , fmt .Errorf ("unexpected format of ID (%q), expected OWNER/REPOSITORY" , id )
387398 }
388399
389400 return parts [0 ], parts [1 ], nil
0 commit comments