Skip to content

Commit 6a69124

Browse files
committed
Added RequiredConversationResolution protection field
Fixes #1945 - added a new field for `Protection` struct to parse `required_conversation_resolution` JSON field from API response for branch protection rules. Updated test.
1 parent 05e95d3 commit 6a69124

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

github/github-accessors.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-accessors_test.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/repos.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -751,13 +751,14 @@ type Branch struct {
751751

752752
// Protection represents a repository branch's protection.
753753
type Protection struct {
754-
RequiredStatusChecks *RequiredStatusChecks `json:"required_status_checks"`
755-
RequiredPullRequestReviews *PullRequestReviewsEnforcement `json:"required_pull_request_reviews"`
756-
EnforceAdmins *AdminEnforcement `json:"enforce_admins"`
757-
Restrictions *BranchRestrictions `json:"restrictions"`
758-
RequireLinearHistory *RequireLinearHistory `json:"required_linear_history"`
759-
AllowForcePushes *AllowForcePushes `json:"allow_force_pushes"`
760-
AllowDeletions *AllowDeletions `json:"allow_deletions"`
754+
RequiredStatusChecks *RequiredStatusChecks `json:"required_status_checks"`
755+
RequiredPullRequestReviews *PullRequestReviewsEnforcement `json:"required_pull_request_reviews"`
756+
EnforceAdmins *AdminEnforcement `json:"enforce_admins"`
757+
Restrictions *BranchRestrictions `json:"restrictions"`
758+
RequireLinearHistory *RequireLinearHistory `json:"required_linear_history"`
759+
AllowForcePushes *AllowForcePushes `json:"allow_force_pushes"`
760+
AllowDeletions *AllowDeletions `json:"allow_deletions"`
761+
RequiredConversationResolution *RequiredConversationResolution `json:"required_conversation_resolution"`
761762
}
762763

763764
// ProtectionRequest represents a request to create/edit a branch's protection.
@@ -849,6 +850,11 @@ type AllowForcePushes struct {
849850
Enabled bool `json:"enabled"`
850851
}
851852

853+
// RequiredConversationResolution, if enabled, requires all comments on the pull request to be resolved before it can be merged to a protected branch.
854+
type RequiredConversationResolution struct {
855+
Enabled bool `json:"enabled"`
856+
}
857+
852858
// AdminEnforcement represents the configuration to enforce required status checks for repository administrators.
853859
type AdminEnforcement struct {
854860
URL *string `json:"url,omitempty"`

github/repos_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,9 @@ func TestRepositoriesService_GetBranchProtection(t *testing.T) {
959959
"restrictions":{
960960
"users":[{"id":1,"login":"u"}],
961961
"teams":[{"id":2,"slug":"t"}]
962+
},
963+
"required_conversation_resolution": {
964+
"enabled": true
962965
}
963966
}`)
964967
})
@@ -999,6 +1002,9 @@ func TestRepositoriesService_GetBranchProtection(t *testing.T) {
9991002
{Slug: String("t"), ID: Int64(2)},
10001003
},
10011004
},
1005+
RequiredConversationResolution: &RequiredConversationResolution{
1006+
Enabled: true,
1007+
},
10021008
}
10031009
if !cmp.Equal(protection, want) {
10041010
t.Errorf("Repositories.GetBranchProtection returned %+v, want %+v", protection, want)

0 commit comments

Comments
 (0)