diff --git a/AUTHORS b/AUTHORS index 74a21dc604e..0197b94a23a 100644 --- a/AUTHORS +++ b/AUTHORS @@ -303,6 +303,7 @@ Matt Gaunt Matt Landis Matt Moore Matt Simons +Matthew Reidy Maxime Bury Michael Meng Michael Spiegel @@ -484,4 +485,4 @@ Zach Latta zhouhaibing089 六开箱 缘生 -蒋航 +蒋航 \ No newline at end of file diff --git a/github/orgs_rules_test.go b/github/orgs_rules_test.go index 50ba4e20c01..0ed54ca8d27 100644 --- a/github/orgs_rules_test.go +++ b/github/orgs_rules_test.go @@ -123,6 +123,9 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoNames(t *testing.T) { "type": "deletion" }, + { + "type": "merge_queue" + }, { "type": "required_linear_history" }, @@ -238,6 +241,7 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoNames(t *testing.T) UpdateAllowsFetchAndMerge: true, }), NewDeletionRule(), + NewMergeQueueRule(), NewRequiredLinearHistoryRule(), NewRequiredDeploymentsRule(&RequiredDeploymentEnvironmentsRuleParameters{ RequiredDeploymentEnvironments: []string{"test"}, @@ -324,6 +328,7 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoNames(t *testing.T) UpdateAllowsFetchAndMerge: true, }), NewDeletionRule(), + NewMergeQueueRule(), NewRequiredLinearHistoryRule(), NewRequiredDeploymentsRule(&RequiredDeploymentEnvironmentsRuleParameters{ RequiredDeploymentEnvironments: []string{"test"}, @@ -437,6 +442,9 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoIDs(t *testing.T) { { "type": "deletion" }, + { + "type": "merge_queue" + }, { "type": "required_linear_history" }, @@ -550,6 +558,7 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoIDs(t *testing.T) { UpdateAllowsFetchAndMerge: true, }), NewDeletionRule(), + NewMergeQueueRule(), NewRequiredLinearHistoryRule(), NewRequiredDeploymentsRule(&RequiredDeploymentEnvironmentsRuleParameters{ RequiredDeploymentEnvironments: []string{"test"}, @@ -634,6 +643,7 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoIDs(t *testing.T) { UpdateAllowsFetchAndMerge: true, }), NewDeletionRule(), + NewMergeQueueRule(), NewRequiredLinearHistoryRule(), NewRequiredDeploymentsRule(&RequiredDeploymentEnvironmentsRuleParameters{ RequiredDeploymentEnvironments: []string{"test"}, diff --git a/github/repos_rules.go b/github/repos_rules.go index 34711dda979..6f046a356a6 100644 --- a/github/repos_rules.go +++ b/github/repos_rules.go @@ -134,7 +134,7 @@ func (r *RepositoryRule) UnmarshalJSON(data []byte) error { r.Type = RepositoryRule.Type switch RepositoryRule.Type { - case "creation", "deletion", "required_linear_history", "required_signatures", "non_fast_forward": + case "creation", "deletion", "merge_queue", "non_fast_forward", "required_linear_history", "required_signatures": r.Parameters = nil case "update": if RepositoryRule.Parameters == nil { @@ -210,6 +210,13 @@ func (r *RepositoryRule) UnmarshalJSON(data []byte) error { return nil } +// NewMergeQueueRule creates a rule to only allow merges via a merge queue. +func NewMergeQueueRule() (rule *RepositoryRule) { + return &RepositoryRule{ + Type: "merge_queue", + } +} + // NewCreationRule creates a rule to only allow users with bypass permission to create matching refs. func NewCreationRule() (rule *RepositoryRule) { return &RepositoryRule{ diff --git a/github/repos_rules_test.go b/github/repos_rules_test.go index cbc3e5ce617..23ffd3ed5c1 100644 --- a/github/repos_rules_test.go +++ b/github/repos_rules_test.go @@ -67,6 +67,13 @@ func TestRepositoryRule_UnmarshalJSON(t *testing.T) { Parameters: nil, }, }, + "Valid merge_queue": { + data: `{"type":"merge_queue"}`, + want: &RepositoryRule{ + Type: "merge_queue", + Parameters: nil, + }, + }, "Valid non_fast_forward": { data: `{"type":"non_fast_forward"}`, want: &RepositoryRule{