Skip to content

Commit 8a9115e

Browse files
authored
Merge pull request #220 from michalschott/master
Allow repository mainbranch configuration
2 parents ecc6b68 + 571ef5d commit 8a9115e

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

bitbucket/resource_repository.go

+13
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ func resourceRepository() *schema.Resource {
7777
Default: "allow_forks",
7878
ValidateFunc: validation.StringInSlice([]string{"allow_forks", "no_public_forks", "no_forks"}, false),
7979
},
80+
"mainbranch": {
81+
Type: schema.TypeString,
82+
Optional: true,
83+
Computed: true,
84+
},
8085
"language": {
8186
Type: schema.TypeString,
8287
Optional: true,
@@ -173,6 +178,13 @@ func newRepositoryFromResource(d *schema.ResourceData) *bitbucket.Repository {
173178
repo.Project = project
174179
}
175180

181+
if v, ok := d.GetOk("mainbranch"); ok && v.(string) != "" {
182+
mainbranch := &bitbucket.Branch{
183+
Name: v.(string),
184+
}
185+
repo.Mainbranch = mainbranch
186+
}
187+
176188
return repo
177189
}
178190

@@ -364,6 +376,7 @@ func resourceRepositoryRead(ctx context.Context, d *schema.ResourceData, m inter
364376
d.Set("slug", repoRes.Slug)
365377
d.Set("language", repoRes.Language)
366378
d.Set("fork_policy", repoRes.ForkPolicy)
379+
d.Set("mainbranch", repoRes.Mainbranch.Name)
367380
// d.Set("website", repoRes.Website)
368381
d.Set("description", repoRes.Description)
369382
d.Set("project_key", repoRes.Project.Key)

docs/resources/repository.md

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ The following arguments are supported:
5959
* `link` - (Optional) A set of links to a resource related to this object. See [Link](#link) Below.
6060
* `inherit_default_merge_strategy` - (Optional) Whether to inherit default merge strategy from project.
6161
* `inherit_branching_model` - (Optional) Whether to inherit branching model from project.
62+
* `mainbranch` - (Optional) Name of main branch.
6263

6364
### Link
6465

0 commit comments

Comments
 (0)