Skip to content

Commit 182f8e0

Browse files
alilezanickfloyd
andauthored
feat: add delete branch on merge option on datasource github repository (#2046)
* add delete branch on merge option on datasource github repository * add allow update branch option as well * Add allow_update_branch and delete_branch_on_merge attributes to github_repository test --------- Co-authored-by: Nick Floyd <[email protected]>
1 parent fe95ce2 commit 182f8e0

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

github/data_source_github_repository.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ func dataSourceGithubRepository() *schema.Resource {
9090
Type: schema.TypeBool,
9191
Computed: true,
9292
},
93+
"allow_update_branch": {
94+
Type: schema.TypeBool,
95+
Computed: true,
96+
},
9397
"squash_merge_commit_title": {
9498
Type: schema.TypeString,
9599
Computed: true,
@@ -326,6 +330,10 @@ func dataSourceGithubRepository() *schema.Resource {
326330
Type: schema.TypeInt,
327331
Computed: true,
328332
},
333+
"delete_branch_on_merge": {
334+
Type: schema.TypeBool,
335+
Computed: true,
336+
},
329337
},
330338
}
331339
}
@@ -395,6 +403,8 @@ func dataSourceGithubRepositoryRead(d *schema.ResourceData, meta interface{}) er
395403
d.Set("node_id", repo.GetNodeID())
396404
d.Set("repo_id", repo.GetID())
397405
d.Set("has_projects", repo.GetHasProjects())
406+
d.Set("delete_branch_on_merge", repo.GetDeleteBranchOnMerge())
407+
d.Set("allow_update_branch", repo.GetAllowUpdateBranch())
398408

399409
if repo.GetHasPages() {
400410
pages, _, err := client.Repositories.GetPagesInfo(context.TODO(), owner, repoName)

github/data_source_github_repository_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ func TestAccGithubRepositoryDataSource(t *testing.T) {
140140
resource.TestCheckResourceAttr(
141141
"data.github_repository.test", "fork", "false",
142142
),
143+
resource.TestCheckResourceAttr(
144+
"data.github_repository.test", "allow_update_branch", "true",
145+
),
146+
resource.TestCheckResourceAttr(
147+
"data.github_repository.test", "delete_branch_on_merge", "true",
148+
),
143149
)
144150

145151
testCase := func(t *testing.T, mode string) {

0 commit comments

Comments
 (0)